diff --git a/xiaofang/Assets/Scenes/main.unity b/xiaofang/Assets/Scenes/main.unity index 5729eea3..40a32d0e 100644 --- a/xiaofang/Assets/Scenes/main.unity +++ b/xiaofang/Assets/Scenes/main.unity @@ -2232,7 +2232,7 @@ MonoBehaviour: eventSystem: {fileID: 1579865912} ManagerPanel: {fileID: 617308871} peopleCountent: {fileID: 667280287} - peoplePrefab: {fileID: 0} + peoplePrefab: {fileID: 4204671800070690484, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3} panelContent: {fileID: 1145997501} dutyPrefab: {fileID: 3344224972021141760, guid: 4f774e025e4a15442aedb0588ab62396, type: 3} dutyCount: {fileID: 1034927193} @@ -2504,7 +2504,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: -193.59004, y: 309.8263} - m_SizeDelta: {x: 388.1544, y: 58.599} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 1} --- !u!114 &667280288 MonoBehaviour: @@ -5861,6 +5861,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: -62 objectReference: {fileID: 0} + - target: {fileID: 7468736064052287473, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7468736064090762255, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3} propertyPath: eventName value: @@ -5887,12 +5891,16 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7468736064090762355, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3} propertyPath: m_AnchoredPosition.x - value: 564.5 + value: 206 objectReference: {fileID: 0} - target: {fileID: 7468736064090762355, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3} propertyPath: m_AnchoredPosition.y value: -62 objectReference: {fileID: 0} + - target: {fileID: 7468736064090762356, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7468736064179597218, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3} propertyPath: m_AnchorMax.y value: 0 diff --git a/xiaofang/Assets/Script/JSONReader/JSONReader.cs b/xiaofang/Assets/Script/JSONReader/JSONReader.cs index c869cd3f..2a76ce87 100644 --- a/xiaofang/Assets/Script/JSONReader/JSONReader.cs +++ b/xiaofang/Assets/Script/JSONReader/JSONReader.cs @@ -31,15 +31,9 @@ public class JSONReader : MonoBehaviour NPCDictionary = NPCParseJSON(incidentSiteJosnFile.text); foreach (var npc in locationDictionary) { - //.Log($"Scene ID: {npc.Value.ID}"); - //Debug.Log("==========================="); + } - - //打印 NPC 数据 - //PrintNPCData(npcDictionary); - - // 打印 Location 数据 - ////PrintLocationData(locationDictionary); + GetNpcDataByID(8001); } // 解析 JSON 字符串为 NPC 数据 @@ -69,7 +63,7 @@ public class JSONReader : MonoBehaviour return locationDictionary; } - // 解析 JSON 字符串为 Event 数据 + // 解析 JSON 字符串为 Event 数据 public Dictionary EventParseJSON(string json) { EventData[] locationArray = JsonHelper.FromJson(json); @@ -134,43 +128,26 @@ public class JSONReader : MonoBehaviour return locationDictionary; } - // 打印 NPC 数据 - //void PrintNPCData(Dictionary npcDictionary) - //{ - // foreach (var npc in npcDictionary) - // { - // Debug.Log($"NPC ID: {npc.Value.ID}"); - // Debug.Log($"Note: {npc.Value.Note}"); - // Debug.Log($"Name: {npc.Value.Name}"); - // Debug.Log($"ActionMode: {npc.Value.ActionMode}"); - // Debug.Log($"Group: {npc.Value.Group}"); - // Debug.Log($"GroupLeader: {npc.Value.GroupLeader}"); - // Debug.Log($"IsLeadingNPC: {npc.Value.IsLeadingNPC}"); - // Debug.Log($"ICON: {npc.Value.ICON}"); - // Debug.Log($"WeightLimit: {npc.Value.WeightLimit}"); - // Debug.Log($"Stats: {npc.Value.Stats}"); - // Debug.Log($"Skills: {npc.Value.Skills}"); - // Debug.Log($"ResPath: {npc.Value.ResPath}"); - // Debug.Log("------------------------------------"); - // } - //} + //将所有的数据都拿出来方便调用 + // 根据给定的ID获取对应的NPC数据,并返回字典中所有数据 + public void GetNpcDataByID(int id) + { + // 例如,获取 NPC 字典中对应 ID 的数据 + if (npcDictionary.ContainsKey(id)) + { + NPCData npcData = npcDictionary[id]; - // // 打印 Location 数据 - //void PrintLocationData(Dictionary locationDictionary) - //{ - // foreach (var location in locationDictionary) - // { - // Debug.Log($"Location ID: {location.Value.ID}"); - // Debug.Log($"Note: {location.Value.Note}"); - // Debug.Log($"Name: {location.Value.Name}"); - // Debug.Log($"Scene: {location.Value.Scene}"); - // Debug.Log($"NpcRatio: {location.Value.NpcRatio}"); - // Debug.Log($"Oversee: {location.Value.Oversee}"); - // Debug.Log($"RoleLimit: {location.Value.RoleLimit}"); - // Debug.Log($"Level: {location.Value.Level}"); - // Debug.Log("==========================="); - // } - //} + // 遍历并输出字典中的所有数据 + foreach (var npc in npcDictionary) + { + + } + } + else + { + Debug.Log($"No NPC found with ID: {id}"); + } + } } // 帮助类,用于解析 JSON 数组 diff --git a/xiaofang/Assets/Script/Scheduled_03/Panel.cs b/xiaofang/Assets/Script/Scheduled_03/Panel.cs index 50666757..6d9b2aed 100644 --- a/xiaofang/Assets/Script/Scheduled_03/Panel.cs +++ b/xiaofang/Assets/Script/Scheduled_03/Panel.cs @@ -13,13 +13,13 @@ using UnityEngine.UI; public class SelectedInfo { - public string name; - public string duty; - public string scene; - public string leader; + public string name;//角色名 + public string duty;//职责 + public string scene;//场景名 + public string leader;//是否组长 + public int dutyId;//职责的Id } - public class Panel : MonoBehaviour { [Header("组件")] @@ -52,6 +52,7 @@ public class Panel : MonoBehaviour [Header("数据")] public string name, duty, scene; + public int dutyId; public List peopleList = new List(); // 存储所有已加载的人员预制体 private List filteredPeopleList = new List(); // 存储筛选后的人员列表 private GameObject selectedPerson = null; // 当前选中的角色 @@ -69,47 +70,48 @@ public class Panel : MonoBehaviour // Start is called before the first frame update void Start() - { - selectedInfo = new SelectedInfo(); - DynamicLoadingPeople(); - DynamicLoadingDuty(); - DynamicLoadingScene(); - } + { + selectedInfo = new SelectedInfo(); + DynamicLoadingPeople(); + DynamicLoadingDuty(); + DynamicLoadingScene(); + } // Update is called once per frame void Update() - { - GetData(); - SetText(); - //SetInputFile(); - } + { + GetData(); + SetText(); + //SetInputFile(); + } //==================================================================动态加载======================================================= - //动态加载人员 + //动态加载人员 public void DynamicLoadingPeople() - { - for (int i = 0; i < 20; i++) { - GameObject item = GameObject.Instantiate(peoplePrefab, peopleCountent); - PeopleItem peopleItem = item.GetComponent(); - Button peoplebutton = item.transform.Find("TextBtn").GetComponent