Compare commits

...

2 Commits

Author SHA1 Message Date
lq
1441e13a50 Merge branch 'main' of http://shu.sheziwanglo.cn:3000/wulongxiao/_xiaofang 2024-12-27 23:42:49 +08:00
lq
61cc379bf1 分管修改 2024-12-27 23:42:19 +08:00
3 changed files with 56 additions and 47 deletions

View File

@ -487,7 +487,7 @@ public class EvacuationPanel : Base
{ {
JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>(); JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
jueseChoicePanel.gameObject.SetActive(true); jueseChoicePanel.gameObject.SetActive(true);
jueseChoicePop.SetClass(); jueseChoicePop.SetClass(classLevel.classname.text);
//jueseChoicePanel.SetClass(); //jueseChoicePanel.SetClass();
}); });

View File

@ -461,7 +461,7 @@ MonoBehaviour:
id: 0 id: 0
name: name:
classmatename: {fileID: 5469669078877023921} classmatename: {fileID: 5469669078877023921}
classText: {fileID: 0} classText: {fileID: 646037399500158430}
s: s:
otherButton: {fileID: 0} otherButton: {fileID: 0}
button: {fileID: 5469669078140634246} button: {fileID: 5469669078140634246}

View File

@ -20,6 +20,8 @@ public class JueseChoicePop : MonoBehaviour
public List<ClassMate> classMateList = new List<ClassMate> (); public List<ClassMate> classMateList = new List<ClassMate> ();
// 存储已实例化的 GameObject 列表 // 存储已实例化的 GameObject 列表
private List<GameObject> instantiatedObjects = new List<GameObject>(); private List<GameObject> instantiatedObjects = new List<GameObject>();
// 用于记录已加载的SceneId或者DutyId
HashSet<string> loadedSceneIds = new HashSet<string>(); // 或者使用字典来记录更多信息
public string s; public string s;
public JSONReader jsonReader; public JSONReader jsonReader;
@ -40,7 +42,7 @@ public class JueseChoicePop : MonoBehaviour
} }
void CLosePop() void CLosePop()
{ {
ClearAll(); //ClearAll();
this.gameObject.SetActive(false); this.gameObject.SetActive(false);
} }
public void openPop() public void openPop()
@ -55,56 +57,63 @@ public class JueseChoicePop : MonoBehaviour
} }
//加载分管人员 //加载分管人员
public void SetClass() public void SetClass(string a)
{
foreach(var all in panel.sceneDataDictionary)
{ {
//if (instantiatedObjects.Any(obj => obj.GetComponent<ClassMate>().id == id)) foreach (var info in all.Value)
//{
// Debug.Log($"这个: {id} 已经被实例化.");
// return; // 如果已实例化,跳过
//}
//foreach (Transform child in content)
//{
// Destroy(child.gameObject);
//}
foreach(var all in panel.sceneDataDictionary)
{ {
foreach (var info in all.Value) Debug.LogError("-------------------------"+ info.sceneId);
LocationData locationData = jsonReader.GetAreaDateById(int.Parse(info.sceneId));
if (locationData.Oversee == "-1")
{ {
Debug.LogError("-------------------------"+ info.sceneId); Debug.Log($"Skipping ID{info.sceneId}: Oversee is -1.");
LocationData locationData = jsonReader.GetAreaDateById(int.Parse(info.sceneId)); continue; // 跳过
if (locationData.Oversee == "-1") }
{
Debug.Log($"Skipping ID{info.sceneId}: Oversee is -1."); string[] overseeParts = locationData.Oversee.Split(',');
continue; // 跳过 string firstElement = overseeParts[0];
} string lastElement = overseeParts[1];
string[] overseeParts = locationData.Oversee.Split(',');
string firstElement = overseeParts[0]; if (overseeParts.Length > 0 && firstElement == info.dutyId && lastElement == "1")
string lastElement = overseeParts[1]; {
if (overseeParts.Length > 0) Debug.LogError(loadedSceneIds.Contains(info.name));
{ // 如果已经加载过,跳过
if (loadedSceneIds.Contains(info.name))
if(firstElement==info.dutyId&&lastElement=="1") {
{ Debug.Log($"Scene ID {info.sceneId} already loaded. Skipping.");
GameObject item = GameObject.Instantiate(classmatePrefab, content); continue; // 如果该sceneId已经加载过就跳过
ClassMate classMate = item.GetComponent<ClassMate>(); }
Button button = item.GetComponent<Button>();
button.onClick.AddListener(() => // 如果没有加载过,实例化预制体
{ GameObject item = GameObject.Instantiate(classmatePrefab, content);
//SetClassMate(classMate, ); ClassMate classMate = item.GetComponent<ClassMate>();
}); Button button = item.GetComponent<Button>();
classMate.name = info.name;
classMate.classmatename.text = classMate.name; button.onClick.AddListener(() =>
//classMate.id = info.dutyId; {
instantiatedObjects.Add(item); SetClassMate(classMate, a);
} });
} classMate.name = info.name;
classMate.classmatename.text = classMate.name;
// classMate.id = info.dutyId;
instantiatedObjects.Add(item);
// 将当前加载的sceneId添加到集合中
loadedSceneIds.Add(info.name);
} }
}
if(panel.sceneDataDictionary.Count==0)
{
WarningPopPanel.OpenPanel("请先添加对应的应急人员配置");
} }
} }
// 如果没有数据,弹出提示框
if (panel.sceneDataDictionary.Count == 0)
{
WarningPopPanel.OpenPanel("请先添加对应的应急人员配置");
}
}
//点击人员后设置位置的方法 //点击人员后设置位置的方法
public void SetClassMate(ClassMate classMate, string a = "") public void SetClassMate(ClassMate classMate, string a = "")
{ {