应急人员配置修改

This commit is contained in:
lq 2024-12-16 15:57:15 +08:00
parent 5743caeea9
commit 4cdbf62b8d
5 changed files with 1355 additions and 792 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,16 +20,5 @@
"Storeroom": "1011",
"ConfigText": "20034|20035|20036",
"": ""
},
{
"ID": "9004",
"Name": "40003",
"Type": "3",
"IncidentType": "5002",
"ObjList": "7001,7002,7003|7001,7003|7001,7002,7003",
"AreaList": "1012|1013|1014|1015|1017|1018|1019|1020|1021|1022|1023|1024|1025|1026|1027|1028|1029|1030|1076|1031|1032|1033|1034|1036|1037|1038|1039|1040|1041|1077|1078|1079|1080|1081|1082|1083|1084|1085|1086",
"Storeroom": "1011",
"ConfigText": "10039|10040|10039",
"": ""
}
]

View File

@ -48,9 +48,9 @@ public class JSONReader : MonoBehaviour
SelectsDictionary = SelectsJSON(SelectsJsonFile.text);
GetLanguageByID(20008);
foreach (var npc in npcDictionary)
foreach (var npc in sceneDictionary)
{
//Debug.Log(npc.Value.ID);
Debug.Log(npc.Value.ID);
//Debug.Log(npc.Value.Name);
}
GetNpcDataByID(8001);

View File

@ -183,55 +183,96 @@ public class Panel : MonoBehaviour
//动态加载场景
public void DynamicLoadingScene()
{
foreach (var npcData in jsonReader1.locationDictionary)
foreach (var region in jsonReader1.sceneDictionary)
{
// 解析角色限制字段
string roleLimit = npcData.Value.RoleLimit;
int sceneLimit = npcData.Value.Scene;
if (!string.IsNullOrEmpty(roleLimit))
string[] roleLimitSections = region.Value.AreaList.Split('|');
foreach(string npcData in roleLimitSections)
{
// 先按“|”分隔
string[] roleLimitSections = roleLimit.Split('|');
// 遍历每个部分(按“|”分隔后得到的数组)
bool shouldInstantiate = true; // 用于判断是否需要实例化
foreach (string section in roleLimitSections)
{
string[] roleLimits = section.Split(',');
// 判断当前部分是否包含 "-1" 来决定是否跳过实例化
if (section.Contains("-1"))
{
if (roleLimits[0] == "-1")
{
shouldInstantiate = false; // 不实例化该NPC
break; // 跳出循环直接处理下一个NPC
}
}
else
{
if(selectScenePanel.scnenId== sceneLimit)
{
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// 设置limitNum
sceneItem.sceneId = npcData.Key.ToString();
sceneItem.dutyId = roleLimits[1];
sceneItem.limitNum = int.Parse(roleLimits[2]);
sceneItem.sceneName.text = npcData.Value.Note;
// 将每个实例化的角色添加到列表中
peopleList.Add(item);
}
}
}
// 如果不满足实例化条件跳过当前NPC的实例化
if (!shouldInstantiate)
{
continue;
}
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// 设置limitNum
sceneItem.sceneId = npcData.ToString();
LocationData locationData= jsonReader1.GetAreaDateById(int.Parse(npcData));
sceneItem.sceneName.text = jsonReader1.SetUIText(locationData.Name);
Debug.LogError(sceneItem.sceneId);
// 将每个实例化的角色添加到列表中
peopleList.Add(item);
}
}
//foreach (var npcData in jsonReader1.locationDictionary)
//{
// // 解析角色限制字段
// string roleLimit = npcData.Value.RoleLimit;
// int sceneLimit = npcData.Value.Scene;
// Debug.Log("npcData.Value.Scene"+ npcData.Value.Scene);
// if(selectScenePanel.scnenId== sceneLimit)
// {
// GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
// SceneItem sceneItem = item.GetComponent<SceneItem>();
// Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
// scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// // 设置limitNum
// sceneItem.sceneId = npcData.Key.ToString();
// //sceneItem.dutyId = roleLimits[1];
// //sceneItem.limitNum = int.Parse(roleLimits[2]);
// sceneItem.sceneName.text = npcData.Value.Note;
// // 将每个实例化的角色添加到列表中
// peopleList.Add(item);
// }
//if (!string.IsNullOrEmpty(roleLimit))
//{
// // 先按“|”分隔
// string[] roleLimitSections = roleLimit.Split('|');
// // 遍历每个部分(按“|”分隔后得到的数组)
// bool shouldInstantiate = true; // 用于判断是否需要实例化
// foreach (string section in roleLimitSections)
// {
// string[] roleLimits = section.Split(',');
// // 判断当前部分是否包含 "-1" 来决定是否跳过实例化
// if (section.Contains("-1"))
// {
// if (roleLimits[0] == "-1")
// {
// shouldInstantiate = false; // 不实例化该NPC
// break; // 跳出循环直接处理下一个NPC
// }
// }
// else
// {
// if (selectScenePanel.scnenId== sceneLimit)
// {
// if(selectScenePanel.difficultyId == int.Parse(roleLimits[1]))
// {
// Debug.LogWarning("roleLimits[0]"+ roleLimits[0]);
// Debug.LogWarning("roleLimits[1]" + roleLimits[1]);
// Debug.LogWarning("roleLimits[2]" + roleLimits[2]);
// Debug.LogWarning("roleLimits[3]" + roleLimits[3]);
// GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
// SceneItem sceneItem = item.GetComponent<SceneItem>();
// Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
// scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// // 设置limitNum
// sceneItem.sceneId = npcData.Key.ToString();
// sceneItem.dutyId = roleLimits[1];
// sceneItem.limitNum = int.Parse(roleLimits[2]);
// sceneItem.sceneName.text = npcData.Value.Note;
// // 将每个实例化的角色添加到列表中
// peopleList.Add(item);
// }
// }
// }
// }
// // 如果不满足实例化条件跳过当前NPC的实例化
// if (!shouldInstantiate)
// {
// continue;
// }
//}
}
//=============================================================按钮和点击事件==================================================
//处理人员管理按钮
public void ClickPersonnelManagement()
@ -286,9 +327,10 @@ public class Panel : MonoBehaviour
else
{
string accidentLocationId = roleLimits[0]; // 事故位置ID
string roleId = roleLimits[1]; // 职业ID
int minRequired = int.Parse(roleLimits[2]); // 最低要求人数
if (accidentLocationId == selectScenePanel.idcidentId.ToString() && roleId == id.ToString())
string difficultyId = roleLimits[1];
string roleId = roleLimits[2]; // 职业ID
int minRequired = int.Parse(roleLimits[3]); // 最低要求人数
if (accidentLocationId == selectScenePanel.idcidentId.ToString() && roleId == id.ToString()&&difficultyId==selectScenePanel.difficultyId.ToString())
{
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();

View File

@ -101,6 +101,7 @@ public class EvacuationPanel : MonoBehaviour
panel.panelToggle[4].gameObject.transform.GetComponent<Image>().sprite = panel.toggleImage[1];
}
//ノ靹テNpcタ獎ヘ
public void SetNpcType()
{
foreach (var scene in panel.sceneDataDictionary)
@ -271,6 +272,7 @@ public class EvacuationPanel : MonoBehaviour
// 返回符合条件的区域 ID 列表
return nonZeroAreas;
}
//设置左侧场景显示
public void SetPersonnel()
{
@ -350,6 +352,7 @@ public class EvacuationPanel : MonoBehaviour
}
}
}
// 判断重新分配按钮是否可以点击
public void IsRedistribution()
{
@ -507,6 +510,4 @@ public class EvacuationPanel : MonoBehaviour
classCount.gameObject.SetActive(false);
}
}
//
}