应急人员配置数据串联
This commit is contained in:
parent
441a9a200c
commit
5db2740f34
@ -143,6 +143,8 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
schoolId: 0
|
||||
schoolName: {fileID: 8240735975125479954}
|
||||
maskImage: {fileID: 0}
|
||||
isOpen: 0
|
||||
--- !u!1 &8240735974858230823
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -312,7 +314,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &8240735975124526756
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"ID": 2001,
|
||||
"ID": "2001",
|
||||
"Note": "厨房起火",
|
||||
"Name": 2001,
|
||||
"Name": "2001",
|
||||
"Scene": "9003",
|
||||
"Position": "36,1,2",
|
||||
"Volume": "-1",
|
||||
@ -12,9 +12,9 @@
|
||||
"GeneralRole": "8000,8001,8002,8003,8004,8005,8006,8008,8009,8010"
|
||||
},
|
||||
{
|
||||
"ID": 2002,
|
||||
"ID": "2002",
|
||||
"Note": "学生宿舍起火",
|
||||
"Name": 2002,
|
||||
"Name": "2002",
|
||||
"Scene": "9002",
|
||||
"Position": "0,0,0",
|
||||
"Volume": "-1",
|
||||
@ -22,5 +22,29 @@
|
||||
"SpecialEvent": "-1,-1,-1,-1|1,50,10,20|1,50,20,20",
|
||||
"Role": "8000,8001,8002,8003,8004,8005,8007,8011|8000,8001,8002,8003,8004,8005,8007,8011|8000,8001,8002,8003,8004,8005,8007,8011",
|
||||
"GeneralRole": "8000,8001,8002,8003,8004,8005,8007,8010,8011"
|
||||
},
|
||||
{
|
||||
"ID": "2003",
|
||||
"Note": "test1",
|
||||
"Name": "2003",
|
||||
"Scene": "9003",
|
||||
"Position": "1,1,1",
|
||||
"Volume": "-1",
|
||||
"Difficulty": "2|3",
|
||||
"SpecialEvent": "-1,-1,-1,-1|1,50,10,20",
|
||||
"Role": "8001,8002,8003,8004,8005|8001,8002,8003,8004,8005",
|
||||
"GeneralRole": "8010"
|
||||
},
|
||||
{
|
||||
"ID": "2004",
|
||||
"Note": "test2",
|
||||
"Name": "2004",
|
||||
"Scene": "9003",
|
||||
"Position": "2,2,2",
|
||||
"Volume": "-1",
|
||||
"Difficulty": "1|5|6",
|
||||
"SpecialEvent": "-1,-1,-1,-1|1,50,10,20|1,50,20,20",
|
||||
"Role": "8000,8001,8002,8003,8004,8005,8006,8008,8009|8000,8001,8002,8003,8004,8005,8006,8008,8009|8000,8001,8002,8003,8004,8005,8006,8008,8009,8010",
|
||||
"GeneralRole": "8010"
|
||||
}
|
||||
]
|
@ -4,13 +4,13 @@
|
||||
"Note": "火灾",
|
||||
"Name": "5001",
|
||||
"Role": "8000|8001|8002|8003|8004|8005|8006|8008|8009|8010",
|
||||
"DisasterLocation": "2001"
|
||||
"DisasterLocation": "2001|2002|2003"
|
||||
},
|
||||
{
|
||||
"ID": "5002",
|
||||
"Note": "塌方",
|
||||
"Name": "5002",
|
||||
"Role": "8000|8001|8002|8003|8004|8005|8006|8008|8009|8010",
|
||||
"DisasterLocation": "2004|2002"
|
||||
"DisasterLocation": "2004"
|
||||
}
|
||||
]
|
@ -2133,7 +2133,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &618256459
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -8210,6 +8210,7 @@ MonoBehaviour:
|
||||
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
|
||||
NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3}
|
||||
LanguageJsonFile: {fileID: 4900000, guid: 62a41129c4663ee41a06274114d28feb, type: 3}
|
||||
SelectJsonFile: {fileID: 4900000, guid: 3efd15f4195557144a45659d2baa1ba3, type: 3}
|
||||
--- !u!4 &1417128758
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -14630,9 +14631,9 @@ RectTransform:
|
||||
m_Father: {fileID: 7468736063934366934}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 334.1322, y: -55}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 187, y: 110}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064122132329
|
||||
@ -14913,9 +14914,9 @@ RectTransform:
|
||||
m_Father: {fileID: 7468736063934366934}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 753.3966, y: -55}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 187, y: 110}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064198941274
|
||||
@ -15673,7 +15674,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 3.3229}
|
||||
m_SizeDelta: {x: 1834, y: 1070}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064579811972
|
||||
GameObject:
|
||||
@ -15695,7 +15696,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &7468736064579811982
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -16153,9 +16154,9 @@ RectTransform:
|
||||
m_Father: {fileID: 7468736063934366934}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 543.7644, y: -55}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 187, y: 110}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064659112359
|
||||
@ -16359,9 +16360,9 @@ RectTransform:
|
||||
m_Father: {fileID: 7468736064579811971}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 917, y: -53.335}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 1834, y: 106.67}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064728012045
|
||||
@ -16521,9 +16522,9 @@ RectTransform:
|
||||
m_Father: {fileID: 7468736063934366934}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 124.5, y: -55}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 187, y: 110}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064820222392
|
||||
@ -16934,9 +16935,9 @@ RectTransform:
|
||||
m_Father: {fileID: 7468736064579811971}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 917, y: -588.33496}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 1834, y: 498.685}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7468736064937661071
|
||||
|
@ -42,9 +42,9 @@ public class JSONReader : MonoBehaviour
|
||||
|
||||
|
||||
GetLanguageByID(20008);
|
||||
foreach (var npc in sceneDictionary)
|
||||
foreach (var npc in npcDictionary)
|
||||
{
|
||||
// Debug.Log(npc.Value.ID);
|
||||
//Debug.Log(npc.Value.ID);
|
||||
//Debug.Log(npc.Value.Name);
|
||||
}
|
||||
GetNpcDataByID(8001);
|
||||
@ -271,6 +271,16 @@ public class JSONReader : MonoBehaviour
|
||||
else return null;
|
||||
}
|
||||
|
||||
public NPCData GetRoleDateById(int id)
|
||||
{
|
||||
NPCData info = null;
|
||||
if (npcDictionary.TryGetValue(id, out info))
|
||||
{
|
||||
return info;
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
//设置UI文本的方法
|
||||
public void SetUIText(Text text, int id)
|
||||
{
|
||||
@ -356,7 +366,7 @@ public class MatialData
|
||||
public class SceneData
|
||||
{
|
||||
public int ID;
|
||||
public int Name;
|
||||
public string Name;
|
||||
public int Type;
|
||||
public string IncidentType;
|
||||
public string ObjList;
|
||||
@ -374,6 +384,8 @@ public class IncidentSite
|
||||
public int Volume;
|
||||
public string Difficulty;
|
||||
public string SpecialEvent;
|
||||
public string Role;
|
||||
public string GeneralRole;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -4,6 +4,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
@ -88,16 +89,11 @@ public class Panel : MonoBehaviour
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
selectedInfo = new SelectedInfo();
|
||||
DynamicLoadingPeople();
|
||||
DynamicLoadingDuty();
|
||||
DynamicLoadingScene();
|
||||
for (int i = 1; i < panelToggle.Length; i++)
|
||||
{
|
||||
panelToggle[i].interactable = false;
|
||||
panelToggle[i].gameObject.transform.GetComponent<Image>().sprite = toggleImage[0];
|
||||
}
|
||||
{
|
||||
selectedInfo = new SelectedInfo();
|
||||
DynamicLoadingPeople();
|
||||
DynamicLoadingScene();
|
||||
InstantiateToggle();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -124,71 +120,84 @@ public class Panel : MonoBehaviour
|
||||
}
|
||||
|
||||
//动态加载职责
|
||||
public void DynamicLoadingDuty()
|
||||
public void DynamicLoadingDuty(int id)
|
||||
{
|
||||
foreach (var npcData in jsonReader1.npcDictionary)
|
||||
if (selectScenePanel.difficultyToRoles.ContainsKey(id))
|
||||
{
|
||||
string[] nameSections = npcData.Value.Name.Split('|');
|
||||
foreach (var section in nameSections)
|
||||
{
|
||||
string[] sectionParts = section.Split(',');
|
||||
List<string> rolesForSelectedDifficulty = selectScenePanel.difficultyToRoles[id];
|
||||
|
||||
//判断事件然后确定有哪些职责
|
||||
if (int.Parse(sectionParts[0]) == 2001)
|
||||
// 遍历角色并做相关处理
|
||||
foreach (var role in rolesForSelectedDifficulty)
|
||||
{
|
||||
int roleId = int.Parse(role);
|
||||
NPCData npcData = jsonReader1.GetRoleDateById(roleId);
|
||||
if (jsonReader1.npcDictionary.ContainsKey(roleId))
|
||||
{
|
||||
int key = int.Parse(sectionParts[1]);
|
||||
if (jsonReader1.npcDictionary.ContainsKey(key))
|
||||
var npcInfo = jsonReader1.npcDictionary[roleId];
|
||||
// 创建DutyItem实例
|
||||
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
|
||||
DutyItem dutyItem = item.GetComponent<DutyItem>();
|
||||
Button dutuybutton = item.transform.Find("TextBtn").GetComponent<Button>();
|
||||
dutuybutton.onClick.AddListener(() =>
|
||||
{
|
||||
var npcInfo = jsonReader1.npcDictionary[key];
|
||||
// 创建DutyItem实例
|
||||
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
|
||||
DutyItem dutyItem = item.GetComponent<DutyItem>();
|
||||
Button dutuybutton = item.transform.Find("TextBtn").GetComponent<Button>();
|
||||
dutuybutton.onClick.AddListener(() => OnDutyItemClicked(item, Color.red, selectedDuty));
|
||||
dutyItem.dutyNameText.text = npcData.Value.Note;
|
||||
dutyItem.leader = npcData.Value.GroupLeader;
|
||||
dutyItem.dutyId = npcData.Value.ID;
|
||||
peopleList.Add(item);
|
||||
}
|
||||
OnDutyItemClicked(item, Color.red, selectedDuty);
|
||||
if(dutyItem.dutyNameText.text=="主持人")
|
||||
{
|
||||
peopleList.Clear();
|
||||
foreach (Transform child in sceneCount)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
Debug.Log("无需指定位置");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetScene(dutyItem.dutyId);
|
||||
}
|
||||
});
|
||||
dutyItem.dutyNameText.text = npcData.Note;
|
||||
dutyItem.leader = npcData.GroupLeader;
|
||||
dutyItem.dutyId = npcData.ID;
|
||||
peopleList.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//动态加载场景
|
||||
public void DynamicLoadingScene()
|
||||
{
|
||||
foreach (var npcData in jsonReader1.locationDictionary)
|
||||
{
|
||||
foreach (var npcData in jsonReader1.locationDictionary)
|
||||
// 解析角色限制字段
|
||||
string roleLimit = npcData.Value.RoleLimit;
|
||||
int sceneLimit = npcData.Value.Scene;
|
||||
if (!string.IsNullOrEmpty(roleLimit))
|
||||
{
|
||||
// 解析角色限制字段
|
||||
string roleLimit = npcData.Value.RoleLimit;
|
||||
|
||||
if (!string.IsNullOrEmpty(roleLimit))
|
||||
// 先按“|”分隔
|
||||
string[] roleLimitSections = roleLimit.Split('|');
|
||||
// 遍历每个部分(按“|”分隔后得到的数组)
|
||||
bool shouldInstantiate = true; // 用于判断是否需要实例化
|
||||
foreach (string section in roleLimitSections)
|
||||
{
|
||||
// 先按“|”分隔
|
||||
string[] roleLimitSections = roleLimit.Split('|');
|
||||
// 遍历每个部分(按“|”分隔后得到的数组)
|
||||
bool shouldInstantiate = true; // 用于判断是否需要实例化
|
||||
foreach (string section in roleLimitSections)
|
||||
string[] roleLimits = section.Split(',');
|
||||
// 判断当前部分是否包含 "-1" 来决定是否跳过实例化
|
||||
if (section.Contains("-1"))
|
||||
{
|
||||
string[] roleLimits = section.Split(',');
|
||||
// 判断当前部分是否包含 "-1" 来决定是否跳过实例化
|
||||
if (section.Contains("-1"))
|
||||
if (roleLimits[0] == "-1")
|
||||
{
|
||||
if (roleLimits[0] == "-1")
|
||||
{
|
||||
shouldInstantiate = false; // 不实例化该NPC
|
||||
break; // 跳出循环,直接处理下一个NPC
|
||||
}
|
||||
shouldInstantiate = false; // 不实例化该NPC
|
||||
break; // 跳出循环,直接处理下一个NPC
|
||||
}
|
||||
else
|
||||
}
|
||||
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.dutyId = int.Parse(roleLimits[1]);
|
||||
sceneItem.limitNum = int.Parse(roleLimits[2]);
|
||||
@ -197,14 +206,15 @@ public class Panel : MonoBehaviour
|
||||
peopleList.Add(item);
|
||||
}
|
||||
}
|
||||
// 如果不满足实例化条件,跳过当前NPC的实例化
|
||||
if (!shouldInstantiate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 如果不满足实例化条件,跳过当前NPC的实例化
|
||||
if (!shouldInstantiate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=============================================================按钮和点击事件==================================================
|
||||
//处理人员管理按钮
|
||||
public void ClickPersonnelManagement()
|
||||
@ -226,6 +236,57 @@ public class Panel : MonoBehaviour
|
||||
ManagerPanel.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
//根据选择的职责加载出对应场景
|
||||
public void SetScene(int id)
|
||||
{
|
||||
peopleList.Clear();
|
||||
foreach(Transform child in sceneCount)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
// 遍历所有的 NPC 数据
|
||||
foreach (var npcData in jsonReader1.locationDictionary)
|
||||
{
|
||||
// 判断是否属于当前选择的场景
|
||||
if (npcData.Value.Scene == selectScenePanel.scnenId)
|
||||
{
|
||||
// 按“|”分隔不同的角色限制部分
|
||||
string[] roleLimitSections = npcData.Value.RoleLimit.Split('|');
|
||||
bool shouldInstantiate = true;
|
||||
// 遍历每个角色限制部分
|
||||
foreach (var section in roleLimitSections)
|
||||
{
|
||||
// 按“,”分隔出事故位置ID、职业ID和最低要求人数
|
||||
string[] roleLimits = section.Split(',');
|
||||
if (section.Contains("-1"))
|
||||
{
|
||||
if (roleLimits[0] == "-1")
|
||||
{
|
||||
shouldInstantiate = false; // 不实例化该NPC
|
||||
break; // 跳出循环,直接处理下一个NPC
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int accidentLocationId = int.Parse(roleLimits[0]); // 事故位置ID
|
||||
int roleId = int.Parse(roleLimits[1]); // 职业ID
|
||||
int minRequired = int.Parse(roleLimits[2]); // 最低要求人数
|
||||
if (accidentLocationId == selectScenePanel.idcidentId && roleId == id)
|
||||
{
|
||||
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));
|
||||
sceneItem.dutyId = accidentLocationId;
|
||||
sceneItem.limitNum = minRequired;
|
||||
sceneItem.sceneName.text = npcData.Value.Note;
|
||||
peopleList.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//处理点击确认按钮
|
||||
public void ClickSureBtn()
|
||||
{
|
||||
@ -374,7 +435,17 @@ public class Panel : MonoBehaviour
|
||||
panelToggle[4].interactable = selectScenePanel.isSure; // 启用第三个Toggle
|
||||
}
|
||||
}
|
||||
//设置最初的时候Toggle的状态
|
||||
public void InstantiateToggle()
|
||||
{
|
||||
for (int i = 1; i < panelToggle.Length; i++)
|
||||
{
|
||||
panelToggle[i].interactable = false;
|
||||
panelToggle[i].gameObject.transform.GetComponent<Image>().sprite = toggleImage[0];
|
||||
}
|
||||
}
|
||||
|
||||
//判断确认按钮是否可以点击
|
||||
private void UpdateConfirmButtonState()
|
||||
{
|
||||
// 如果人员、职责和场景都已选择,则启用确认按钮,否则禁用
|
||||
|
@ -5,6 +5,7 @@ using System.Xml.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
using static UnityEditor.Progress;
|
||||
|
||||
public class EvacuationPanel : MonoBehaviour
|
||||
{
|
||||
@ -65,6 +66,11 @@ public class EvacuationPanel : MonoBehaviour
|
||||
nPC.roleId = roleid;
|
||||
createTemplateInfo.Instance.auth_CreateTemplate.npcList = new List<NpcList>();
|
||||
createTemplateInfo.Instance.auth_CreateTemplate.npcList.Add(nPC);
|
||||
//foreach(NpcList item in createTemplateInfo.Instance.auth_CreateTemplate.npcList)
|
||||
//{
|
||||
// Debug.Log("npcType>>>>>>>>>>>>>>>>>" + item.userId);
|
||||
// Debug.Log("roleid>>>>>>>>>>>>>>>>>" + item.roleId);
|
||||
//}
|
||||
}
|
||||
|
||||
public void SetNpcType()
|
||||
|
@ -56,7 +56,9 @@ public class SelectScenePanel : MonoBehaviour
|
||||
public string idcidentName{ get; set; }
|
||||
public string difficulty { get; set; }
|
||||
public string isBuy { get; set; }
|
||||
public int difficultyId { get; set; }
|
||||
public bool isSure { get; set; } = false;//判断是否点击了提交按钮
|
||||
public Dictionary<int, List<string>> difficultyToRoles = new Dictionary<int, List<string>>();
|
||||
public JSONReader jsonReader;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@ -66,7 +68,7 @@ public class SelectScenePanel : MonoBehaviour
|
||||
eventChoiceLable.gameObject.SetActive(false);
|
||||
incidentLable.gameObject.SetActive(false);
|
||||
InstantiateScenePrefab();
|
||||
InstantiateSchoolPrefab();
|
||||
//InstantiateSchoolPrefab();
|
||||
SetEventToggleOpenorClose(incidentInfos);
|
||||
continueBtn.onClick.AddListener(OnClickContinueBtn);
|
||||
SetFirstChoise(scenetoggleList);
|
||||
@ -123,25 +125,59 @@ public class SelectScenePanel : MonoBehaviour
|
||||
toggle.group = sceneGroup;
|
||||
scenetoggleList.Add(toggle); // 使用 Add() 方法添加 Toggle 元素
|
||||
sceneItemList.Add(item);
|
||||
|
||||
}
|
||||
toggle.onValueChanged.AddListener((isSelected) =>
|
||||
{
|
||||
if (isSelected) // 只有当Toggle被选中时,才调用SelectEventBtn
|
||||
{
|
||||
// 清空事件列表
|
||||
schoolInfoList.Clear();
|
||||
foreach (Transform child in schoolList)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
this.scnenId = item.sceneId; // 获取 Text 组件的文本
|
||||
this.sceneName = item.sceneName.text;
|
||||
InstantiateSchoolPrefab(scnenId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//动态加载学校选择预制体(这里面的东西需要判断场景的Id来加载对应的场景)
|
||||
public void InstantiateSchoolPrefab()
|
||||
public void InstantiateSchoolPrefab(int id)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
foreach (var sceneDate in jsonReader.sceneDictionary)
|
||||
{
|
||||
GameObject slot = GameObject.Instantiate<GameObject>(schoolPrefab, schoolList);
|
||||
SchoolInfo item = slot.GetComponent<SchoolInfo>();
|
||||
item.schoolName.text = "南山中学";
|
||||
item.schoolId = i;
|
||||
Toggle toggle = slot.GetComponent<Toggle>();
|
||||
if (toggle != null)
|
||||
if (sceneDate.Key == id)
|
||||
{
|
||||
toggle.group = schoolGroup;
|
||||
schooltoggleList.Add(toggle);
|
||||
schoolInfoList.Add(item);
|
||||
GameObject slot = GameObject.Instantiate<GameObject>(schoolPrefab, schoolList);
|
||||
SchoolInfo item = slot.GetComponent<SchoolInfo>();
|
||||
item.schoolName.text = sceneDate.Value.Name;
|
||||
item.schoolId = sceneDate.Value.ID;
|
||||
Toggle toggle = slot.GetComponent<Toggle>();
|
||||
|
||||
if (toggle != null)
|
||||
{
|
||||
// 将 Toggle 添加到 ToggleGroup 中
|
||||
toggle.group = incidentGroup;
|
||||
toggle.isOn = false;
|
||||
schooltoggleList.Add(toggle);
|
||||
schoolInfoList.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
toggle.onValueChanged.AddListener((isSelected) =>
|
||||
{
|
||||
if (isSelected) // 只有当Toggle被选中时,才调用SelectEventBtn
|
||||
{
|
||||
this.schoolId = item.schoolId; // 获取 Text 组件的文本
|
||||
this.schoolName = item.schoolName.text;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,13 +189,13 @@ public class SelectScenePanel : MonoBehaviour
|
||||
{
|
||||
if (eventData.Key == eventId)
|
||||
{
|
||||
//Debug.Log("<<<<<<<<<<<<<<<<<eventId" + eventData.Key);
|
||||
GameObject slot = GameObject.Instantiate<GameObject>(incidentPrefab, incidentList);
|
||||
IncidentInfo item = slot.GetComponent<IncidentInfo>();
|
||||
item.incidentText.text = eventData.Value.Note;
|
||||
item.incidentID = eventData.Value.ID;
|
||||
this.idcidentId = item.incidentID;
|
||||
this.idcidentName = item.incidentText.text;
|
||||
Toggle toggle = slot.GetComponent<Toggle>();
|
||||
|
||||
if (toggle != null)
|
||||
{
|
||||
// 将 Toggle 添加到 ToggleGroup 中
|
||||
@ -167,10 +203,6 @@ public class SelectScenePanel : MonoBehaviour
|
||||
toggle.isOn = false;
|
||||
eventToggleList.Add(toggle);
|
||||
incidentInfos.Add(item);
|
||||
if (incidentInfos.Count > 1)
|
||||
{
|
||||
//随机按钮设置
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -178,30 +210,43 @@ public class SelectScenePanel : MonoBehaviour
|
||||
}
|
||||
toggle.onValueChanged.AddListener((isSelected) =>
|
||||
{
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
this.idcidentName = item.incidentText.text;
|
||||
this.idcidentId = item.incidentID;
|
||||
datePanel.placeId = item.incidentID;
|
||||
|
||||
string[] difficulty = eventData.Value.Difficulty.Split('|');
|
||||
string[] roleGroups = eventData.Value.Role.Split('|'); // 分割Role字段,得到多个角色组
|
||||
|
||||
// 确保difficultyList和difficulty的长度匹配
|
||||
for (int i = 0; i < difficultyList.Count && i < difficulty.Length; i++)
|
||||
{
|
||||
Toggle item = difficultyList[i]; // 获取对应的Toggle
|
||||
DifficultyInfo difficultyInfo = item.gameObject.GetComponent<DifficultyInfo>();
|
||||
|
||||
if (difficultyInfo == null)
|
||||
{
|
||||
difficultyInfo = item.gameObject.AddComponent<DifficultyInfo>();
|
||||
}
|
||||
|
||||
// 给每个Toggle设置不同的difficulty值
|
||||
difficultyInfo.difficulty = int.Parse(difficulty[i]);
|
||||
|
||||
// 打印出设置的难度值,帮助调试
|
||||
Debug.Log($"Toggle {i} - Difficulty: {difficultyInfo.difficulty}");
|
||||
// 将难度和对应的角色存入字典
|
||||
if (difficultyInfo.difficulty == int.Parse(difficulty[i]))
|
||||
{
|
||||
// 获取与当前难度相关的角色组(根据索引)
|
||||
string[] correspondingRoles = roleGroups[i].Split(',');
|
||||
// 打印或者处理角色
|
||||
List<string> rolesList = new List<string>(correspondingRoles); // 转换为List
|
||||
if (!difficultyToRoles.ContainsKey(difficultyInfo.difficulty))
|
||||
{
|
||||
difficultyToRoles.Add(difficultyInfo.difficulty, rolesList);
|
||||
}
|
||||
else
|
||||
{
|
||||
difficultyToRoles[difficultyInfo.difficulty] = rolesList; // 如果已存在,更新角色列表
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -212,6 +257,11 @@ public class SelectScenePanel : MonoBehaviour
|
||||
//点击继续按钮后更换场景图片及名称
|
||||
public void InstantiateEventPrefab(int id)
|
||||
{
|
||||
incidentInfos.Clear();
|
||||
foreach (Transform child in incidentList)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
text20008.text = sceneName;
|
||||
// 通过 id 获取对应的 sceneData
|
||||
if (jsonReader.sceneDictionary.TryGetValue(id, out var sceneData))
|
||||
@ -228,8 +278,6 @@ public class SelectScenePanel : MonoBehaviour
|
||||
{
|
||||
// 根据 incidentId 获取对应的事件数据
|
||||
EventData eventData=jsonReader.GetEvenById(incidentId);
|
||||
Debug.Log("eventData.ID:" + eventData.ID);
|
||||
Debug.Log("eventData.DisasterLocation:" + eventData.DisasterLocation);
|
||||
string[] incidentIds2 = eventData.DisasterLocation.Split('|');
|
||||
GameObject slot = GameObject.Instantiate<GameObject>(eventPrefab, eventList);
|
||||
EventInfo item = slot.GetComponent<EventInfo>();
|
||||
@ -285,46 +333,6 @@ public class SelectScenePanel : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
//学校选择
|
||||
public void SelectSchoolBtn()
|
||||
{
|
||||
if (isSure)
|
||||
{
|
||||
SchoolInfo gameObject = GetComponentInChildren<SchoolInfo>();
|
||||
foreach (SchoolInfo item in schoolInfoList)
|
||||
{
|
||||
if (item.gameObject.transform.GetComponent<Toggle>().isOn)
|
||||
{
|
||||
this.schoolId = item.schoolId;
|
||||
this.schoolName = item.schoolName.text;
|
||||
title.text = item.schoolName.text;
|
||||
}
|
||||
}
|
||||
Debug.Log("###############1:" + this.schoolId);
|
||||
Debug.Log("###############2:" + this.schoolName);
|
||||
}
|
||||
}
|
||||
|
||||
//场景选择
|
||||
public void SelectSceneBtn()
|
||||
{
|
||||
bool sceneSelected = false; // 检查是否有场景被选择
|
||||
foreach (SceneItem item in sceneItemList)
|
||||
{
|
||||
// 检查当前的 Toggle 是否被选中
|
||||
if (item.gameObject.transform.GetComponent<Toggle>().isOn)
|
||||
{
|
||||
// 设置场景名称
|
||||
this.sceneName = item.sceneName.text; // 获取 Text 组件的文本
|
||||
this.scnenId = item.sceneId;
|
||||
Debug.Log("------------this.scnenId:" + this.scnenId);
|
||||
createTemplateInfo.Instance.auth_CreateTemplate.sceneId = item.sceneId.ToString();
|
||||
sceneSelected = true;
|
||||
break; // 找到选中的场景后退出循环
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//事件及难度选择
|
||||
public void SelectEvent()
|
||||
{
|
||||
@ -337,8 +345,6 @@ public class SelectScenePanel : MonoBehaviour
|
||||
this.eventName = item.eventName.text;
|
||||
}
|
||||
}
|
||||
Debug.Log("%%%%%%%%%%%%%1:" + this.eventId);
|
||||
Debug.Log("%%%%%%%%%%%%%2:" + this.eventName);
|
||||
}
|
||||
|
||||
//随机事件
|
||||
@ -386,6 +392,8 @@ public class SelectScenePanel : MonoBehaviour
|
||||
{
|
||||
if (item.isOn)
|
||||
{
|
||||
DifficultyInfo difficultyInfo = item.GetComponent<DifficultyInfo>();
|
||||
this.difficultyId = difficultyInfo.difficulty;
|
||||
this.difficulty = item.transform.parent.GetComponentInChildren<Text>().text;
|
||||
auth_CreateTemplate.mode = this.difficulty;//给结构体“难度”赋值
|
||||
}
|
||||
@ -395,8 +403,8 @@ public class SelectScenePanel : MonoBehaviour
|
||||
//继续按钮,点击后上传数据
|
||||
public void OnClickContinueBtn()
|
||||
{
|
||||
SelectSchoolBtn();
|
||||
SelectSceneBtn();
|
||||
//SelectSchoolBtn();
|
||||
//SelectSceneBtn();
|
||||
InstantiateEventPrefab(this.scnenId);
|
||||
SetFirstChoise(evnetsceneList);
|
||||
if (continueBtn.interactable)
|
||||
@ -415,12 +423,12 @@ public class SelectScenePanel : MonoBehaviour
|
||||
//提交按钮,点击上传数据和隐藏界面
|
||||
public void SubmitBtn()
|
||||
{
|
||||
SelectEvent();
|
||||
SelsctDifficulty();
|
||||
SetDataPanelInfo();
|
||||
this.gameObject.SetActive(false);
|
||||
panel.gameObject.SetActive(true);
|
||||
DisableUIInteraction();
|
||||
panel.DynamicLoadingDuty(this.difficultyId);
|
||||
isSure = true;
|
||||
}
|
||||
|
||||
@ -456,24 +464,35 @@ public class SelectScenePanel : MonoBehaviour
|
||||
//通过判断Toggle的IsOn是否被打开来判断继续按钮是否置灰
|
||||
public void IsClick()
|
||||
{
|
||||
bool anyToggleSelected = true;
|
||||
|
||||
bool anysceneSelected = false;
|
||||
bool anyschoolSelected = false;
|
||||
bool isOk = false;
|
||||
// 检查场景选择
|
||||
foreach (Toggle toggle in scenetoggleList)
|
||||
{
|
||||
if (toggle.isOn)
|
||||
{
|
||||
anyToggleSelected = true;
|
||||
anysceneSelected = true;
|
||||
break; // 如果有一个场景 Toggle 被选中,停止检查
|
||||
}
|
||||
}
|
||||
foreach (Toggle toggle in schooltoggleList)
|
||||
{
|
||||
if (toggle.isOn)
|
||||
{
|
||||
anyschoolSelected = true;
|
||||
break; // 如果有一个场景 Toggle 被选中,停止检查
|
||||
}
|
||||
}
|
||||
// 根据是否有 Toggle 被选中,设置 ContinueBtn 是否可交互
|
||||
if (continueBtn != null)
|
||||
if (continueBtn != null&& anysceneSelected==true&& anyschoolSelected==true)
|
||||
{
|
||||
continueBtn.interactable = anyToggleSelected; // 如果有选中的 Toggle,继续按钮可交互,否则不可交互
|
||||
isOk = true;
|
||||
continueBtn.interactable = isOk; // 如果有选中的 Toggle,继续按钮可交互,否则不可交互
|
||||
}
|
||||
else
|
||||
{
|
||||
continueBtn.interactable = isOk;
|
||||
Debug.LogError("ContinueBtn 按钮组件未找到!");
|
||||
}
|
||||
}
|
||||
@ -497,7 +516,6 @@ public class SelectScenePanel : MonoBehaviour
|
||||
//检查事件选择
|
||||
foreach (Toggle toggle in eventToggleList)
|
||||
{
|
||||
Debug.LogError("事件选择:" + anyToggleSelected);
|
||||
if (toggle.isOn)
|
||||
{
|
||||
anyeventSelected = true;
|
||||
@ -505,18 +523,15 @@ public class SelectScenePanel : MonoBehaviour
|
||||
break; // 如果有一个场景 Toggle 被选中,停止检查
|
||||
}
|
||||
}
|
||||
Debug.Log(submitBtn != null && anyToggleSelected == true && anyeventSelected == true);
|
||||
// 根据是否有 Toggle 被选中,设置 ContinueBtn 是否可交互
|
||||
if (submitBtn != null && anyToggleSelected == true&& anyeventSelected==true)
|
||||
{
|
||||
Debug.LogError("提交按钮组件未找到!");
|
||||
isOk = true;
|
||||
submitBtn.interactable = isOk; // 如果有选中的 Toggle,继续按钮可交互,否则不可交互
|
||||
}
|
||||
else
|
||||
{
|
||||
submitBtn.interactable = isOk;
|
||||
Debug.LogWarning("提交按钮组件未找到!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,26 +620,35 @@ public class SelectScenePanel : MonoBehaviour
|
||||
// 禁用场景选择中的所有Toggle按钮
|
||||
foreach (Toggle toggle in scenetoggleList)
|
||||
{
|
||||
toggle.interactable = false; // 设置Toggle为不可交互
|
||||
if (toggle != null)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
}
|
||||
}
|
||||
// 禁用学校选择中的所有Toggle按钮
|
||||
foreach (Toggle toggle in schooltoggleList)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
if (toggle != null)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 禁用事件选择中的所有Toggle按钮
|
||||
foreach (Toggle toggle in eventToggleList)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
if (toggle != null)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 禁用事件场景选择中的所有Toggle按钮
|
||||
foreach (Toggle toggle in evnetsceneList)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
if (toggle != null)
|
||||
{
|
||||
toggle.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 禁用继续按钮
|
||||
continueBtn.interactable = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user