From fb60729d671b3c39d2a19cff193cd4e362ba3f5b Mon Sep 17 00:00:00 2001 From: lq <3298408835@qq.com> Date: Mon, 2 Dec 2024 00:35:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=80=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Scenes/Schedule_03.unity | 12 ++++++ xiaofang/Assets/Script/Scheduled_03/Panel.cs | 43 ++++++++----------- .../Assets/Script/UI/PanelUI/ManagerPanel.cs | 12 +++++- .../Script/UI/PanelUI/SelectScenePanel.cs | 2 +- xiaofang/Assets/Script/UI/SceneItem.cs | 1 + 5 files changed, 44 insertions(+), 26 deletions(-) diff --git a/xiaofang/Assets/Scenes/Schedule_03.unity b/xiaofang/Assets/Scenes/Schedule_03.unity index 625c9d1f..2a2d8a53 100644 --- a/xiaofang/Assets/Scenes/Schedule_03.unity +++ b/xiaofang/Assets/Scenes/Schedule_03.unity @@ -1588,6 +1588,14 @@ PrefabInstance: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 1373529961119931373, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3} + propertyPath: m_FontData.m_Alignment + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 1373529961119931373, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3} + propertyPath: m_FontData.m_VerticalOverflow + value: 1 + objectReference: {fileID: 0} - target: {fileID: 1373529961381015436, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3} propertyPath: m_SizeDelta.x value: 267.551 @@ -2113,6 +2121,7 @@ MonoBehaviour: scenePanelPrefab: {fileID: 6740850324693622957, guid: a15ee694d5f79864d816998fae77116d, type: 3} peopleWindowsPrefab: {fileID: 7318934474885050405} personnelPanel: {fileID: 5900002971020626571, guid: 297444ab6ae692b4dbcb38d34e0c5716, type: 3} + jsonReader: {fileID: 0} sceneText: {fileID: 0} scrollRect: {fileID: 1435623615} panelInfo: {fileID: 618256462} @@ -2241,9 +2250,11 @@ MonoBehaviour: name: duty: scene: + peopleList: [] managerPanel1: {fileID: 617308873} jsonReader1: {fileID: 1417128757} selectScenePanel: {fileID: 1138062886} + datePanel: {fileID: 468742199} --- !u!1 &625672672 GameObject: m_ObjectHideFlags: 0 @@ -8754,6 +8765,7 @@ MonoBehaviour: matialJsonFile: {fileID: 4900000, guid: d98cb351d1a87dc4887a37106b9745d4, type: 3} sceneJsonFile: {fileID: 4900000, guid: 06c09fd1c8b0a0a45951a1065189d922, type: 3} incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3} + NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3} --- !u!4 &1417128758 Transform: m_ObjectHideFlags: 0 diff --git a/xiaofang/Assets/Script/Scheduled_03/Panel.cs b/xiaofang/Assets/Script/Scheduled_03/Panel.cs index c559cc1d..7695acc0 100644 --- a/xiaofang/Assets/Script/Scheduled_03/Panel.cs +++ b/xiaofang/Assets/Script/Scheduled_03/Panel.cs @@ -50,7 +50,7 @@ public class Panel : MonoBehaviour [Header("数据")] public string name, duty, scene; - private List peopleList = new List(); // 存储所有已加载的人员预制体 + public List peopleList = new List(); // 存储所有已加载的人员预制体 private List filteredPeopleList = new List(); // 存储筛选后的人员列表 private GameObject selectedPerson = null; // 当前选中的角色 public SelectedInfo selectedInfo; @@ -58,6 +58,7 @@ public class Panel : MonoBehaviour public ManagerPanel managerPanel1; public JSONReader jsonReader1; public SelectScenePanel selectScenePanel; + public DatePanel datePanel; private bool isPersonSelected = false; // 标志是否选择了人员 private bool isDutySelected = false; // 标志是否选择了职责 private bool isSceneSelected = false; // 标志是否选择了场景 @@ -145,46 +146,41 @@ public class Panel : MonoBehaviour bool shouldInstantiate = true; // 用于判断是否需要实例化 foreach (string section in roleLimitSections) { + string[] roleLimits = section.Split(','); + // 判断当前部分是否包含 "-1" 来决定是否跳过实例化 if (section.Contains("-1")) { - // 判断职业ID或其他条件,决定是否跳过 - string[] roleLimits = section.Split(','); - - // 这里假设职业ID在第一个位置,且为-1时表示不可作为出生点 if (roleLimits[0] == "-1") { - //Debug.Log("该职业不能作为出生点,不在预订演练,跳过实例化!"); shouldInstantiate = false; // 不实例化该NPC break; // 跳出循环,直接处理下一个NPC } - - // 处理“-1”表示无限制人数的情况 - if (roleLimits[2] == "-1") - { - //Debug.Log("角色限制为-1,区域限制人数为无限!"); - // 可以选择设置limitNum为无限制 - } + } + else + { + // 实例化NPC预制体 + GameObject item = GameObject.Instantiate(scenePrefab, sceneCount); + SceneItem sceneItem = item.GetComponent(); + // 设置limitNum + sceneItem.dutyId = int.Parse(roleLimits[1]); + sceneItem.limitNum = int.Parse(roleLimits[2]); + sceneItem.sceneName.text = npcData.Value.Note; + // 将每个实例化的角色添加到列表中 + peopleList.Add(item); } } + // 如果不满足实例化条件,跳过当前NPC的实例化 if (!shouldInstantiate) { continue; } } - - // 实例化NPC预制体 - GameObject item = GameObject.Instantiate(scenePrefab, sceneCount); - SceneItem sceneItem = item.GetComponent(); - sceneItem.sceneName.text = npcData.Value.Note; - - // 将每个实例化的角色添加到列表中 - peopleList.Add(item); } - } + //=============================================================按钮和点击事件================================================== //处理人员管理按钮 public void ClickPersonnelManagement() @@ -226,7 +222,6 @@ public class Panel : MonoBehaviour // 获取当前场景中的所有人员信息 List currentSceneInfo = sceneDataDictionary[sceneName]; - // 如果选中了“主持人”、“各组长”或“总指挥”,则限制数量为1 if (selectedInfo.duty == "主持人" || selectedInfo.duty == "组长" || selectedInfo.duty == "总指挥") { @@ -269,7 +264,7 @@ public class Panel : MonoBehaviour { Debug.LogError("请确保选择了人员、职责和场景!"); } - + datePanel.NumberText.text ="共"+(sceneDataDictionary.Keys.Count * sceneDataDictionary.Values.Count).ToString()+"人参与"; // 可以在这里根据需求继续处理选中的数据 } diff --git a/xiaofang/Assets/Script/UI/PanelUI/ManagerPanel.cs b/xiaofang/Assets/Script/UI/PanelUI/ManagerPanel.cs index 5f63d134..716f4a7b 100644 --- a/xiaofang/Assets/Script/UI/PanelUI/ManagerPanel.cs +++ b/xiaofang/Assets/Script/UI/PanelUI/ManagerPanel.cs @@ -14,6 +14,7 @@ public class ManagerPanel : MonoBehaviour public GameObject scenePanelPrefab; public GameObject peopleWindowsPrefab;//人员弹窗 public GameObject personnelPanel;//不包含职责的区域信息面板 + public JSONReader jsonReader; [Header("组件")] @@ -122,9 +123,18 @@ public class ManagerPanel : MonoBehaviour { GameObject managerPanelInstance = Instantiate(personnelPanel, personnelPanelCount); PersonnelPanel scenetext = managerPanelInstance.GetComponent(); + foreach(var item in panelInfo.peopleList) scenetext.personelPanelText.text = sceneEntry.Key; scenetext.personelNumText.text = sceneEntry.Value.Count.ToString(); - scenetext.CreatePeopleItem(sceneEntry.Value); + //foreach (var item in panelInfo.peopleList) + //{ + // SceneItem sceneItem = item.GetComponent(); + // if(sceneItem.sceneName.text== scenetext.personelPanelText.text) + // { + // if(sceneEntry.Value.duty==) + // } + //} + scenetext.CreatePeopleItem(sceneEntry.Value); } //CreatePeopleItem(); } diff --git a/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs b/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs index aae68203..84c2de32 100644 --- a/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs +++ b/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs @@ -209,7 +209,7 @@ public class SelectScenePanel : MonoBehaviour Toggle toggle = slot.GetComponent(); if (toggle != null) { - toggle.group = eventGroup; + toggle.group = sceneGroup; //toggleList.Add(toggle); sceneItemList.Add(item); } diff --git a/xiaofang/Assets/Script/UI/SceneItem.cs b/xiaofang/Assets/Script/UI/SceneItem.cs index 9ea93f61..21a17653 100644 --- a/xiaofang/Assets/Script/UI/SceneItem.cs +++ b/xiaofang/Assets/Script/UI/SceneItem.cs @@ -13,6 +13,7 @@ public class SceneItem : MonoBehaviour public Image maskImage; public string roleLimit;//场景限制条件 public int limitNum;//限制人数 + public int dutyId; public JSONReader jsonReader; public bool IsOpen { get; set; } = true; // Start is called before the first frame update