Compare commits

..

No commits in common. "dd2c810c5e92c18176f642b1c74c536b4d52425c" and "f47393fa9f7c20c638b4a13a21d1b9e165953523" have entirely different histories.

5 changed files with 124 additions and 130 deletions

View File

@ -2665,8 +2665,6 @@ MonoBehaviour:
sceneLable: {fileID: 5900002971020626571, guid: 297444ab6ae692b4dbcb38d34e0c5716, type: 3} sceneLable: {fileID: 5900002971020626571, guid: 297444ab6ae692b4dbcb38d34e0c5716, type: 3}
content: {fileID: 788248231} content: {fileID: 788248231}
closeBtn: {fileID: 349260647} closeBtn: {fileID: 349260647}
panel: {fileID: 618256462}
selectScenePanel: {fileID: 7468736064579811982}
jsonReader: {fileID: 1417128757} jsonReader: {fileID: 1417128757}
--- !u!1 &569417021 stripped --- !u!1 &569417021 stripped
GameObject: GameObject:

View File

@ -101,7 +101,7 @@ public class Panel : Base
public SelectScenePanel selectScenePanel; public SelectScenePanel selectScenePanel;
public DatePanel datePanel; public DatePanel datePanel;
public WarningPopPanel warningPopPanel; public WarningPopPanel warningPopPanel;
public RequirementPanel requirementPanel; //public RequirementPanel requirementPanel;
private bool isPersonSelected = false; // 标志是否选择了人员 private bool isPersonSelected = false; // 标志是否选择了人员
private bool isDutySelected = false; // 标志是否选择了职责 private bool isDutySelected = false; // 标志是否选择了职责
@ -126,7 +126,7 @@ public class Panel : Base
//SetInputFile(); //SetInputFile();
} }
//==================================================================动态加载======================================================= //==================================================================动态加载=======================================================
//动态加载人员 //动态加载人员
public async void DynamicLoadingPeople() public async void DynamicLoadingPeople()
{ {
//for (int i = 0; i < 10; i++) //for (int i = 0; i < 10; i++)
@ -153,7 +153,7 @@ public class Panel : Base
} }
//动态加载职责 //动态加载职责
public void DynamicLoadingDuty(int id, int idcidentId) public void DynamicLoadingDuty(int id,int idcidentId)
{ {
if (selectScenePanel.difficultyToRoles.ContainsKey(id)) if (selectScenePanel.difficultyToRoles.ContainsKey(id))
{ {
@ -169,12 +169,12 @@ public class Panel : Base
var npcInfo = jsonReader1.npcDictionary[roleId]; var npcInfo = jsonReader1.npcDictionary[roleId];
// 创建DutyItem实例 // 创建DutyItem实例
string[] roleLimitSections = npcData.Name.Split('|'); string[] roleLimitSections = npcData.Name.Split('|');
foreach (string plopleInfo in roleLimitSections) foreach(string plopleInfo in roleLimitSections)
{ {
string[] peopleLimit = plopleInfo.Split(','); string[] peopleLimit = plopleInfo.Split(',');
if (peopleLimit[0] == idcidentId.ToString() && peopleLimit[1] == id.ToString()) if (peopleLimit[0] == idcidentId.ToString() && peopleLimit[1]==id.ToString())
{ {
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount); GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
DutyItem dutyItem = item.GetComponent<DutyItem>(); DutyItem dutyItem = item.GetComponent<DutyItem>();
@ -183,7 +183,7 @@ public class Panel : Base
dutuybutton.onClick.AddListener(() => dutuybutton.onClick.AddListener(() =>
{ {
OnDutyItemClicked(item, Color.red, selectedDuty); OnDutyItemClicked(item, Color.red, selectedDuty);
if (dutyItem.dutyNameText.text == "主持人") if(dutyItem.dutyNameText.text=="主持人")
{ {
peopleList.Clear(); peopleList.Clear();
foreach (Transform child in sceneCount) foreach (Transform child in sceneCount)
@ -216,7 +216,7 @@ public class Panel : Base
foreach (var region in jsonReader1.sceneDictionary) foreach (var region in jsonReader1.sceneDictionary)
{ {
string[] roleLimitSections = region.Value.AreaList.Split('|'); string[] roleLimitSections = region.Value.AreaList.Split('|');
foreach (string npcData in roleLimitSections) foreach(string npcData in roleLimitSections)
{ {
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount); GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>(); SceneItem sceneItem = item.GetComponent<SceneItem>();
@ -224,7 +224,7 @@ public class Panel : Base
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene)); scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// 设置limitNum // 设置limitNum
sceneItem.sceneId = npcData.ToString(); sceneItem.sceneId = npcData.ToString();
LocationData locationData = jsonReader1.GetAreaDateById(int.Parse(npcData)); LocationData locationData= jsonReader1.GetAreaDateById(int.Parse(npcData));
sceneItem.sceneName.text = jsonReader1.SetUIText(locationData.Name.ToString()); sceneItem.sceneName.text = jsonReader1.SetUIText(locationData.Name.ToString());
//Debug.LogError(sceneItem.sceneId); //Debug.LogError(sceneItem.sceneId);
// 将每个实例化的角色添加到列表中 // 将每个实例化的角色添加到列表中
@ -251,60 +251,60 @@ public class Panel : Base
// // 将每个实例化的角色添加到列表中 // // 将每个实例化的角色添加到列表中
// peopleList.Add(item); // peopleList.Add(item);
// } // }
//if (!string.IsNullOrEmpty(roleLimit)) //if (!string.IsNullOrEmpty(roleLimit))
//{ //{
// // 先按“|”分隔 // // 先按“|”分隔
// string[] roleLimitSections = roleLimit.Split('|'); // string[] roleLimitSections = roleLimit.Split('|');
// // 遍历每个部分(按“|”分隔后得到的数组) // // 遍历每个部分(按“|”分隔后得到的数组)
// bool shouldInstantiate = true; // 用于判断是否需要实例化 // bool shouldInstantiate = true; // 用于判断是否需要实例化
// foreach (string section in roleLimitSections) // foreach (string section in roleLimitSections)
// { // {
// string[] roleLimits = section.Split(','); // string[] roleLimits = section.Split(',');
// // 判断当前部分是否包含 "-1" 来决定是否跳过实例化 // // 判断当前部分是否包含 "-1" 来决定是否跳过实例化
// if (section.Contains("-1")) // if (section.Contains("-1"))
// { // {
// if (roleLimits[0] == "-1") // if (roleLimits[0] == "-1")
// { // {
// shouldInstantiate = false; // 不实例化该NPC // shouldInstantiate = false; // 不实例化该NPC
// break; // 跳出循环直接处理下一个NPC // break; // 跳出循环直接处理下一个NPC
// } // }
// } // }
// else // else
// { // {
// if (selectScenePanel.scnenId== sceneLimit) // if (selectScenePanel.scnenId== sceneLimit)
// { // {
// if(selectScenePanel.difficultyId == int.Parse(roleLimits[1])) // if(selectScenePanel.difficultyId == int.Parse(roleLimits[1]))
// { // {
// Debug.LogWarning("roleLimits[0]"+ roleLimits[0]); // Debug.LogWarning("roleLimits[0]"+ roleLimits[0]);
// Debug.LogWarning("roleLimits[1]" + roleLimits[1]); // Debug.LogWarning("roleLimits[1]" + roleLimits[1]);
// Debug.LogWarning("roleLimits[2]" + roleLimits[2]); // Debug.LogWarning("roleLimits[2]" + roleLimits[2]);
// Debug.LogWarning("roleLimits[3]" + roleLimits[3]); // Debug.LogWarning("roleLimits[3]" + roleLimits[3]);
// GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount); // GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
// SceneItem sceneItem = item.GetComponent<SceneItem>(); // SceneItem sceneItem = item.GetComponent<SceneItem>();
// Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>(); // Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
// scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene)); // scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// // 设置limitNum // // 设置limitNum
// sceneItem.sceneId = npcData.Key.ToString(); // sceneItem.sceneId = npcData.Key.ToString();
// sceneItem.dutyId = roleLimits[1]; // sceneItem.dutyId = roleLimits[1];
// sceneItem.limitNum = int.Parse(roleLimits[2]); // sceneItem.limitNum = int.Parse(roleLimits[2]);
// sceneItem.sceneName.text = npcData.Value.Note; // sceneItem.sceneName.text = npcData.Value.Note;
// // 将每个实例化的角色添加到列表中 // // 将每个实例化的角色添加到列表中
// peopleList.Add(item); // peopleList.Add(item);
// } // }
// } // }
// } // }
// } // }
// // 如果不满足实例化条件跳过当前NPC的实例化 // // 如果不满足实例化条件跳过当前NPC的实例化
// if (!shouldInstantiate) // if (!shouldInstantiate)
// { // {
// continue; // continue;
// } // }
//} //}
} }
//=============================================================按钮和点击事件================================================== //=============================================================按钮和点击事件==================================================
//处理人员管理按钮 //处理人员管理按钮
public void ClickPersonnelManagement() public void ClickPersonnelManagement()
{ {
if (sceneDataDictionary.Count != 0) if (sceneDataDictionary.Count != 0)
@ -335,7 +335,7 @@ public class Panel : Base
public void SetScene(int id) public void SetScene(int id)
{ {
peopleList.Clear(); peopleList.Clear();
foreach (Transform child in sceneCount) foreach(Transform child in sceneCount)
{ {
Destroy(child.gameObject); Destroy(child.gameObject);
} }
@ -348,7 +348,7 @@ public class Panel : Base
// 按“|”分隔不同的角色限制部分 // 按“|”分隔不同的角色限制部分
string[] roleLimitSections = npcData.Value.RoleLimit.Split('|'); string[] roleLimitSections = npcData.Value.RoleLimit.Split('|');
bool shouldInstantiate = true; bool shouldInstantiate = true;
if (npcData.Value.RoleLimit == "-1") if(npcData.Value.RoleLimit=="-1")
{ {
continue; continue;
} }
@ -396,7 +396,7 @@ public class Panel : Base
} }
// 获取当前该位置该职业的已添加人数 // 获取当前该位置该职业的已添加人数
private int GetCurrentPeopleCount(string accidentLocationId, string roleId) private int GetCurrentPeopleCount(string accidentLocationId, string roleId)
{ {
int count = 0; int count = 0;
// 遍历场景数据字典,统计该事故位置和职业的人员数量 // 遍历场景数据字典,统计该事故位置和职业的人员数量
@ -517,9 +517,9 @@ public class Panel : Base
//获取鼠标点击位置的信息 //获取鼠标点击位置的信息
public void GetData() public void GetData()
{ {
ManagerPanel managerPanel = new ManagerPanel(); ManagerPanel managerPanel = new ManagerPanel();
// 当鼠标左键按下时进行检测 // 当鼠标左键按下时进行检测
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
{ {
// 确保 raycaster 和 eventSystem 不为空 // 确保 raycaster 和 eventSystem 不为空
@ -561,14 +561,14 @@ public class Panel : Base
scene = buttonText.text; scene = buttonText.text;
SceneItem sceneItem = buttonText.gameObject.GetComponentInParent<SceneItem>(); SceneItem sceneItem = buttonText.gameObject.GetComponentInParent<SceneItem>();
selectedInfo.scene = scene; selectedInfo.scene = scene;
selectedInfo.sceneId = sceneItem.sceneId; selectedInfo.sceneId= sceneItem.sceneId;
isSceneSelected = true; // 选择了场景 isSceneSelected = true; // 选择了场景
} }
else if (buttonText != null && buttonText.tag == Tags.duty) // 获取标签为职责的信息 else if (buttonText != null && buttonText.tag == Tags.duty) // 获取标签为职责的信息
{ {
duty = buttonText.text; duty = buttonText.text;
DutyItem item = clickedButton.GetComponentInParent<DutyItem>(); DutyItem item = clickedButton.GetComponentInParent<DutyItem>();
if (duty == "主持人") if(duty=="主持人")
{ {
isDutySelected = true; // 选择了职责 isDutySelected = true; // 选择了职责
isSceneSelected = true; isSceneSelected = true;
@ -595,7 +595,7 @@ public class Panel : Base
//判断是否能够点击按钮 //判断是否能够点击按钮
public void PanelToggelSet() public void PanelToggelSet()
{ {
if (selectScenePanel.isSure) if(selectScenePanel.isSure)
{ {
panelToggle[1].interactable = selectScenePanel.isSure; // 启用第二个Toggle panelToggle[1].interactable = selectScenePanel.isSure; // 启用第二个Toggle
panelToggle[1].gameObject.transform.GetComponent<Image>().sprite = toggleImage[1]; panelToggle[1].gameObject.transform.GetComponent<Image>().sprite = toggleImage[1];
@ -617,46 +617,46 @@ public class Panel : Base
//判断确认按钮是否可以点击 //判断确认按钮是否可以点击
private void UpdateConfirmButtonState() private void UpdateConfirmButtonState()
{ {
if (isDutySelected) if(isDutySelected)
// 如果人员、职责和场景都已选择,则启用确认按钮,否则禁用 // 如果人员、职责和场景都已选择,则启用确认按钮,否则禁用
sureBtn.interactable = isPersonSelected && isDutySelected && isSceneSelected; sureBtn.interactable = isPersonSelected && isDutySelected && isSceneSelected;
ChangeImage(sureBtn.interactable); ChangeImage(sureBtn.interactable);
} }
//设置安排文字 //设置安排文字
public void SetText() public void SetText()
{ {
arrangeText.text = "[" + name + "]担任[" + duty + "],位于[" + scene + "]"; arrangeText.text = "[" + name + "]担任[" + duty + "],位于[" + scene + "]";
} }
//筛选 //筛选
public void SetInputFile() public void SetInputFile()
{
// 获取输入框内容
string filterText = shaixuaninputField.text.Trim();
// 遍历所有已实例化的人员预制体
foreach (Transform child in peopleCountent)
{ {
// 获取该子物体上的 Text 组件 // 获取输入框内容
Text personNameText = child.GetComponentInChildren<Text>(); string filterText = shaixuaninputField.text.Trim();
if (personNameText != null) // 遍历所有已实例化的人员预制体
foreach (Transform child in peopleCountent)
{ {
// 比较输入框中的内容与人员姓名 // 获取该子物体上的 Text 组件
if (personNameText.text.Contains(filterText)) Text personNameText = child.GetComponentInChildren<Text>();
if (personNameText != null)
{ {
// 如果匹配,显示该人员 // 比较输入框中的内容与人员姓名
child.gameObject.SetActive(true); if (personNameText.text.Contains(filterText))
} {
else // 如果匹配,显示该人员
{ child.gameObject.SetActive(true);
// 如果不匹配,隐藏该人员 }
child.gameObject.SetActive(false); else
{
// 如果不匹配,隐藏该人员
child.gameObject.SetActive(false);
}
} }
} }
} }
}
//==========================================================点击变色============================================================ //==========================================================点击变色============================================================
public void OnPeopleItemClicked(GameObject clickedItem, Color color, GameObject select) public void OnPeopleItemClicked(GameObject clickedItem, Color color, GameObject select)
@ -808,6 +808,7 @@ public class Panel : Base
public void WhetherToMeet() public void WhetherToMeet()
{ {
bool allRequirementsMet = true; // 标记是否所有需求都满足 bool allRequirementsMet = true; // 标记是否所有需求都满足
// 遍历所有的场景数据 // 遍历所有的场景数据
foreach (var item in jsonReader1.locationDictionary) foreach (var item in jsonReader1.locationDictionary)
{ {
@ -867,6 +868,7 @@ public class Panel : Base
{ {
// 如果没有找到该场景的职业数据,列出所缺职业 // 如果没有找到该场景的职业数据,列出所缺职业
Debug.Log($"场景 {item.Key} 的职业数据未找到,列出缺少的职业和人数:"); Debug.Log($"场景 {item.Key} 的职业数据未找到,列出缺少的职业和人数:");
// 根据 RoleLimit 列出缺少的职业及其要求人数 // 根据 RoleLimit 列出缺少的职业及其要求人数
foreach (var entryInLimit in limit) foreach (var entryInLimit in limit)
{ {
@ -906,7 +908,7 @@ public class Panel : Base
public void OnclickRequirementsBtn() public void OnclickRequirementsBtn()
{ {
requirementsPrefab.gameObject.SetActive(true); requirementsPrefab.gameObject.SetActive(true);
requirementPanel.LoadingSceneLable(); //requirementPanel.LoadingSceneLable();
} }
} }

View File

@ -41,7 +41,7 @@ public class DistributionPanel : MonoBehaviour
{ {
GameObject managerPanelInstance = Instantiate(personnelLable, personnelContent); GameObject managerPanelInstance = Instantiate(personnelLable, personnelContent);
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>(); PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
scenetext.personelPanelText.text = jsonReader.SetUIText(sceneEntry.Key); scenetext.personelPanelText.text = sceneEntry.Key;
scenetext.personelNumText.text = sceneEntry.Value.Count.ToString(); scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
scenetext.CreatePeopleItem(sceneEntry.Value); scenetext.CreatePeopleItem(sceneEntry.Value);
foreach(var scene in sceneEntry.Value) foreach(var scene in sceneEntry.Value)

View File

@ -1,6 +1,5 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -51,12 +50,4 @@ public class PersonnelPanel : MonoBehaviour
{ {
transform.gameObject.SetActive(false); transform.gameObject.SetActive(false);
} }
//动态加载最低配置的人员
public void LoadingpersonelItem(Transform personContent,string name)
{
GameObject gameObject = Instantiate(personelItem, personContent);
PersonnelInfo personnelInfo = gameObject.GetComponent<PersonnelInfo>();
personnelInfo.name = name;
}
} }

View File

@ -439,8 +439,11 @@ public class SelectScenePanel : Base
public void SubmitBtn() public void SubmitBtn()
{ {
datePanel.evetId = this.eventId.ToString(); datePanel.evetId = this.eventId.ToString();
Debug.LogError("datePanel.evetId"+datePanel.evetId);
datePanel.placeId = this.scnenId.ToString(); datePanel.placeId = this.scnenId.ToString();
Debug.LogError("datePanel.placeId" + datePanel.placeId);
datePanel.disasterLocation = this.idcidentId.ToString(); datePanel.disasterLocation = this.idcidentId.ToString();
Debug.LogError("datePanel.disasterLocation" + datePanel.disasterLocation);
SelsctDifficulty(); SelsctDifficulty();
SetDataPanelInfo(); SetDataPanelInfo();
SetPanel(); SetPanel();