diff --git a/xiaofang/Assets/Script/UI/PanelUI/EvacuationPanel.cs b/xiaofang/Assets/Script/UI/PanelUI/EvacuationPanel.cs index 70223ffc..83d737da 100644 --- a/xiaofang/Assets/Script/UI/PanelUI/EvacuationPanel.cs +++ b/xiaofang/Assets/Script/UI/PanelUI/EvacuationPanel.cs @@ -334,6 +334,8 @@ public class EvacuationPanel : MonoBehaviour levelBtn.onClick.AddListener(() => { jueseChoicePanel.gameObject .SetActive(true); + JueseChoicePop jueseChoicePop= jueseChoicePanel.gameObject.GetComponent(); + jueseChoicePop.SetClass(personnelItem.sceneId); }); ClassItem classItem = levelItem.GetComponent(); classItem.classname.text = locationData.Level.ToString(); diff --git a/xiaofang/Assets/yhj/scripts/JueseChoicePop.cs b/xiaofang/Assets/yhj/scripts/JueseChoicePop.cs index 7f9995b4..f782b9cf 100644 --- a/xiaofang/Assets/yhj/scripts/JueseChoicePop.cs +++ b/xiaofang/Assets/yhj/scripts/JueseChoicePop.cs @@ -17,6 +17,7 @@ public class JueseChoicePop : MonoBehaviour public List classMateList = new List (); public string s; + public JSONReader jsonReader; //Start is called before the first frame update void Start() { @@ -47,17 +48,40 @@ public class JueseChoicePop : MonoBehaviour } public void SetClass(int id) { + // 获取指定 ID 的 LocationData + LocationData locationData = jsonReader.GetAreaDateById(id); - for (int i = 0; i < 10; i++) + // 判断 Oversee 字段 + if (locationData.Oversee == "-1") { - GameObject item = GameObject.Instantiate(classmatePrefab, content); + Debug.Log($"Skipping ID {id}: Oversee is -1."); + return; // 跳过 + } - ClassMate classMate = item.GetComponent(); - classMateList.Add(classMate); - //classMate.SetJc(this); + // 分割 Oversee 字段 + string[] overseeParts = locationData.Oversee.Split(','); + foreach (string part in overseeParts) + { + // 检查每个部分的最后一位是否为 "1" + string[] elements = part.Split('|'); + if (elements.Length > 1) + { + string lastElement = elements[elements.Length - 1]; + if (lastElement == "1") // 如果最后一部分是 "1",实例化对象 + { + GameObject item = GameObject.Instantiate(classmatePrefab, content); + ClassMate classMate = item.GetComponent(); + + // 设置 ClassMate 的名称或其他字段 + classMate.classmatename.text = locationData.Note; + + Debug.Log($"Instantiated ClassMate for ID {id} with name {locationData.Name}"); + } + } } } + public void SetClassItem(ClassItem classItem) { this.classItem = classItem;