Compare commits
3 Commits
f47393fa9f
...
dd2c810c5e
Author | SHA1 | Date | |
---|---|---|---|
dd2c810c5e | |||
51abcfd89a | |||
8707309163 |
@ -2665,6 +2665,8 @@ MonoBehaviour:
|
||||
sceneLable: {fileID: 5900002971020626571, guid: 297444ab6ae692b4dbcb38d34e0c5716, type: 3}
|
||||
content: {fileID: 788248231}
|
||||
closeBtn: {fileID: 349260647}
|
||||
panel: {fileID: 618256462}
|
||||
selectScenePanel: {fileID: 7468736064579811982}
|
||||
jsonReader: {fileID: 1417128757}
|
||||
--- !u!1 &569417021 stripped
|
||||
GameObject:
|
||||
|
@ -29,25 +29,25 @@ public class SelectedInfo
|
||||
public class Panel : Base
|
||||
{
|
||||
[Header("组件")]
|
||||
[Header("设置人员")]
|
||||
[Header("设置人员")]
|
||||
public Button setName;//设置人员
|
||||
[Header("设置职责")]
|
||||
public Button setDuty;//设置职责
|
||||
[Header("设置场景")]
|
||||
[Header("设置场景")]
|
||||
public Button setScene;//设置场景
|
||||
[Header("整体安排")]
|
||||
[Header("整体安排")]
|
||||
public Text arrangeText;//整体安排
|
||||
[Header("确认信息按钮")]
|
||||
[Header("确认信息按钮")]
|
||||
public Button sureBtn;//确认信息按钮
|
||||
[Header("最少人员要求警告")]
|
||||
public Button requirementsBtn;
|
||||
[Header("场景的ToggleGroup")]
|
||||
[Header("场景的ToggleGroup")]
|
||||
public ToggleGroup scenetoggleGroup;//场景的ToggleGroup
|
||||
[Header("筛选输入框")]
|
||||
[Header("筛选输入框")]
|
||||
public InputField shaixuaninputField;//筛选输入框
|
||||
[Header("画布上的射线投射器")]
|
||||
[Header("画布上的射线投射器")]
|
||||
public GraphicRaycaster raycaster; // 画布上的射线投射器
|
||||
[Header("事件系统")]
|
||||
[Header("事件系统")]
|
||||
public EventSystem eventSystem; // 事件系统
|
||||
public ToggleGroup chooseGroup;
|
||||
[Header("面板选择")]
|
||||
@ -60,23 +60,23 @@ public class Panel : Base
|
||||
|
||||
|
||||
[Header("物体")]
|
||||
[Header("人员管理界面")]
|
||||
[Header("人员管理界面")]
|
||||
public GameObject ManagerPanel;//人员管理界面
|
||||
[Header("人员的窗口")]
|
||||
[Header("人员的窗口")]
|
||||
public Transform peopleCountent;//人员的窗口
|
||||
[Header("人员的预制体")]
|
||||
[Header("人员的预制体")]
|
||||
public GameObject peoplePrefab;//人员的预制体
|
||||
[Header("物体")]
|
||||
[Header("物体")]
|
||||
public Transform panelContent;
|
||||
[Header("职责预制体")]
|
||||
[Header("职责预制体")]
|
||||
public GameObject dutyPrefab;//职责预制体
|
||||
[Header("职责的窗口")]
|
||||
[Header("职责的窗口")]
|
||||
public Transform dutyCount;//职责的窗口
|
||||
[Header("场景预制体")]
|
||||
[Header("场景预制体")]
|
||||
public GameObject scenePrefab;//场景预制体
|
||||
[Header("存放场景预制体")]
|
||||
[Header("存放场景预制体")]
|
||||
public Transform sceneCount;//存放场景预制体的地方
|
||||
[Header("人员管理面板")]
|
||||
[Header("人员管理面板")]
|
||||
public GameObject ManagerPanelPrefab; // 预制体,包含人员管理面板
|
||||
[Header("最低配置面板")]
|
||||
public GameObject requirementsPrefab; // 预制体,最低配置面板
|
||||
@ -101,7 +101,7 @@ public class Panel : Base
|
||||
public SelectScenePanel selectScenePanel;
|
||||
public DatePanel datePanel;
|
||||
public WarningPopPanel warningPopPanel;
|
||||
//public RequirementPanel requirementPanel;
|
||||
public RequirementPanel requirementPanel;
|
||||
|
||||
private bool isPersonSelected = false; // 标志是否选择了人员
|
||||
private bool isDutySelected = false; // 标志是否选择了职责
|
||||
@ -126,7 +126,7 @@ public class Panel : Base
|
||||
//SetInputFile();
|
||||
}
|
||||
//==================================================================动态加载=======================================================
|
||||
//动态加载人员
|
||||
//动态加载人员
|
||||
public async void DynamicLoadingPeople()
|
||||
{
|
||||
//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))
|
||||
{
|
||||
@ -169,12 +169,12 @@ public class Panel : Base
|
||||
var npcInfo = jsonReader1.npcDictionary[roleId];
|
||||
// 创建DutyItem实例
|
||||
string[] roleLimitSections = npcData.Name.Split('|');
|
||||
foreach(string plopleInfo in roleLimitSections)
|
||||
foreach (string plopleInfo in roleLimitSections)
|
||||
{
|
||||
|
||||
|
||||
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);
|
||||
DutyItem dutyItem = item.GetComponent<DutyItem>();
|
||||
@ -183,7 +183,7 @@ public class Panel : Base
|
||||
dutuybutton.onClick.AddListener(() =>
|
||||
{
|
||||
OnDutyItemClicked(item, Color.red, selectedDuty);
|
||||
if(dutyItem.dutyNameText.text=="主持人")
|
||||
if (dutyItem.dutyNameText.text == "主持人")
|
||||
{
|
||||
peopleList.Clear();
|
||||
foreach (Transform child in sceneCount)
|
||||
@ -200,11 +200,11 @@ public class Panel : Base
|
||||
dutyItem.dutyNameText.text = showText;
|
||||
dutyItem.leader = npcData.GroupLeader;
|
||||
dutyItem.dutyId = npcData.ID;
|
||||
dutyItem.dutyImage.sprite = Resources.Load<Sprite>(npcData.ICON);
|
||||
dutyItem.dutyImage.sprite = Resources.Load<Sprite>(npcData.ICON);
|
||||
peopleList.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ public class Panel : Base
|
||||
foreach (var region in jsonReader1.sceneDictionary)
|
||||
{
|
||||
string[] roleLimitSections = region.Value.AreaList.Split('|');
|
||||
foreach(string npcData in roleLimitSections)
|
||||
foreach (string npcData in roleLimitSections)
|
||||
{
|
||||
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
|
||||
SceneItem sceneItem = item.GetComponent<SceneItem>();
|
||||
@ -224,7 +224,7 @@ public class Panel : Base
|
||||
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
|
||||
// 设置limitNum
|
||||
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());
|
||||
//Debug.LogError(sceneItem.sceneId);
|
||||
// 将每个实例化的角色添加到列表中
|
||||
@ -251,60 +251,60 @@ public class Panel : Base
|
||||
// // 将每个实例化的角色添加到列表中
|
||||
// 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 (!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;
|
||||
// }
|
||||
//}
|
||||
// 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()
|
||||
{
|
||||
if (sceneDataDictionary.Count != 0)
|
||||
@ -335,7 +335,7 @@ public class Panel : Base
|
||||
public void SetScene(int id)
|
||||
{
|
||||
peopleList.Clear();
|
||||
foreach(Transform child in sceneCount)
|
||||
foreach (Transform child in sceneCount)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
@ -348,7 +348,7 @@ public class Panel : Base
|
||||
// 按“|”分隔不同的角色限制部分
|
||||
string[] roleLimitSections = npcData.Value.RoleLimit.Split('|');
|
||||
bool shouldInstantiate = true;
|
||||
if(npcData.Value.RoleLimit=="-1")
|
||||
if (npcData.Value.RoleLimit == "-1")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -356,7 +356,7 @@ public class Panel : Base
|
||||
{
|
||||
foreach (var section in roleLimitSections)
|
||||
{
|
||||
|
||||
|
||||
// 按“,”分隔出事故位置ID、职业ID和最低要求人数
|
||||
string[] roleLimits = section.Split(',');
|
||||
string accidentLocationId = roleLimits[0]; // 事故位置ID
|
||||
@ -390,13 +390,13 @@ public class Panel : Base
|
||||
}
|
||||
}
|
||||
// 遍历每个角色限制部分
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前该位置该职业的已添加人数
|
||||
private int GetCurrentPeopleCount(string accidentLocationId, string roleId)
|
||||
private int GetCurrentPeopleCount(string accidentLocationId, string roleId)
|
||||
{
|
||||
int count = 0;
|
||||
// 遍历场景数据字典,统计该事故位置和职业的人员数量
|
||||
@ -517,9 +517,9 @@ public class Panel : Base
|
||||
//获取鼠标点击位置的信息
|
||||
public void GetData()
|
||||
{
|
||||
ManagerPanel managerPanel = new ManagerPanel();
|
||||
ManagerPanel managerPanel = new ManagerPanel();
|
||||
|
||||
// 当鼠标左键按下时进行检测
|
||||
// 当鼠标左键按下时进行检测
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
// 确保 raycaster 和 eventSystem 不为空
|
||||
@ -544,7 +544,7 @@ public class Panel : Base
|
||||
{
|
||||
// 检测到点击了按钮
|
||||
Button clickedButton = result.gameObject.GetComponent<Button>();
|
||||
|
||||
|
||||
if (clickedButton != null)
|
||||
{
|
||||
Text buttonText = clickedButton.GetComponentInChildren<Text>();
|
||||
@ -561,14 +561,14 @@ public class Panel : Base
|
||||
scene = buttonText.text;
|
||||
SceneItem sceneItem = buttonText.gameObject.GetComponentInParent<SceneItem>();
|
||||
selectedInfo.scene = scene;
|
||||
selectedInfo.sceneId= sceneItem.sceneId;
|
||||
selectedInfo.sceneId = sceneItem.sceneId;
|
||||
isSceneSelected = true; // 选择了场景
|
||||
}
|
||||
else if (buttonText != null && buttonText.tag == Tags.duty) // 获取标签为职责的信息
|
||||
{
|
||||
duty = buttonText.text;
|
||||
DutyItem item = clickedButton.GetComponentInParent<DutyItem>();
|
||||
if(duty=="主持人")
|
||||
if (duty == "主持人")
|
||||
{
|
||||
isDutySelected = true; // 选择了职责
|
||||
isSceneSelected = true;
|
||||
@ -595,7 +595,7 @@ public class Panel : Base
|
||||
//判断是否能够点击按钮
|
||||
public void PanelToggelSet()
|
||||
{
|
||||
if(selectScenePanel.isSure)
|
||||
if (selectScenePanel.isSure)
|
||||
{
|
||||
panelToggle[1].interactable = selectScenePanel.isSure; // 启用第二个Toggle
|
||||
panelToggle[1].gameObject.transform.GetComponent<Image>().sprite = toggleImage[1];
|
||||
@ -617,46 +617,46 @@ public class Panel : Base
|
||||
//判断确认按钮是否可以点击
|
||||
private void UpdateConfirmButtonState()
|
||||
{
|
||||
if(isDutySelected)
|
||||
// 如果人员、职责和场景都已选择,则启用确认按钮,否则禁用
|
||||
sureBtn.interactable = isPersonSelected && isDutySelected && isSceneSelected;
|
||||
if (isDutySelected)
|
||||
// 如果人员、职责和场景都已选择,则启用确认按钮,否则禁用
|
||||
sureBtn.interactable = isPersonSelected && isDutySelected && isSceneSelected;
|
||||
ChangeImage(sureBtn.interactable);
|
||||
}
|
||||
|
||||
//设置安排文字
|
||||
public void SetText()
|
||||
{
|
||||
arrangeText.text = "[" + name + "]担任[" + duty + "],位于[" + scene + "]";
|
||||
}
|
||||
{
|
||||
arrangeText.text = "[" + name + "]担任[" + duty + "],位于[" + scene + "]";
|
||||
}
|
||||
|
||||
//筛选
|
||||
public void SetInputFile()
|
||||
{
|
||||
// 获取输入框内容
|
||||
string filterText = shaixuaninputField.text.Trim();
|
||||
|
||||
// 遍历所有已实例化的人员预制体
|
||||
foreach (Transform child in peopleCountent)
|
||||
{
|
||||
// 获取输入框内容
|
||||
string filterText = shaixuaninputField.text.Trim();
|
||||
// 获取该子物体上的 Text 组件
|
||||
Text personNameText = child.GetComponentInChildren<Text>();
|
||||
|
||||
// 遍历所有已实例化的人员预制体
|
||||
foreach (Transform child in peopleCountent)
|
||||
if (personNameText != null)
|
||||
{
|
||||
// 获取该子物体上的 Text 组件
|
||||
Text personNameText = child.GetComponentInChildren<Text>();
|
||||
|
||||
if (personNameText != null)
|
||||
// 比较输入框中的内容与人员姓名
|
||||
if (personNameText.text.Contains(filterText))
|
||||
{
|
||||
// 比较输入框中的内容与人员姓名
|
||||
if (personNameText.text.Contains(filterText))
|
||||
{
|
||||
// 如果匹配,显示该人员
|
||||
child.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果不匹配,隐藏该人员
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
// 如果匹配,显示该人员
|
||||
child.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果不匹配,隐藏该人员
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//==========================================================点击变色============================================================
|
||||
|
||||
public void OnPeopleItemClicked(GameObject clickedItem, Color color, GameObject select)
|
||||
@ -749,7 +749,7 @@ public class Panel : Base
|
||||
// 如果该人员已经被添加到场景,改变颜色为灰色
|
||||
if (isPersonAdded)
|
||||
{
|
||||
|
||||
|
||||
personText.color = Color.blue; // 已添加人员的颜色
|
||||
}
|
||||
else
|
||||
@ -808,7 +808,6 @@ public class Panel : Base
|
||||
public void WhetherToMeet()
|
||||
{
|
||||
bool allRequirementsMet = true; // 标记是否所有需求都满足
|
||||
|
||||
// 遍历所有的场景数据
|
||||
foreach (var item in jsonReader1.locationDictionary)
|
||||
{
|
||||
@ -868,7 +867,6 @@ public class Panel : Base
|
||||
{
|
||||
// 如果没有找到该场景的职业数据,列出所缺职业
|
||||
Debug.Log($"场景 {item.Key} 的职业数据未找到,列出缺少的职业和人数:");
|
||||
|
||||
// 根据 RoleLimit 列出缺少的职业及其要求人数
|
||||
foreach (var entryInLimit in limit)
|
||||
{
|
||||
@ -908,7 +906,7 @@ public class Panel : Base
|
||||
public void OnclickRequirementsBtn()
|
||||
{
|
||||
requirementsPrefab.gameObject.SetActive(true);
|
||||
//requirementPanel.LoadingSceneLable();
|
||||
requirementPanel.LoadingSceneLable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class DistributionPanel : MonoBehaviour
|
||||
{
|
||||
GameObject managerPanelInstance = Instantiate(personnelLable, personnelContent);
|
||||
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
|
||||
scenetext.personelPanelText.text = sceneEntry.Key;
|
||||
scenetext.personelPanelText.text = jsonReader.SetUIText(sceneEntry.Key);
|
||||
scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
|
||||
scenetext.CreatePeopleItem(sceneEntry.Value);
|
||||
foreach(var scene in sceneEntry.Value)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -50,4 +51,12 @@ public class PersonnelPanel : MonoBehaviour
|
||||
{
|
||||
transform.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
//动态加载最低配置的人员
|
||||
public void LoadingpersonelItem(Transform personContent,string name)
|
||||
{
|
||||
GameObject gameObject = Instantiate(personelItem, personContent);
|
||||
PersonnelInfo personnelInfo = gameObject.GetComponent<PersonnelInfo>();
|
||||
personnelInfo.name = name;
|
||||
}
|
||||
}
|
||||
|
@ -439,11 +439,8 @@ public class SelectScenePanel : Base
|
||||
public void SubmitBtn()
|
||||
{
|
||||
datePanel.evetId = this.eventId.ToString();
|
||||
Debug.LogError("datePanel.evetId"+datePanel.evetId);
|
||||
datePanel.placeId = this.scnenId.ToString();
|
||||
Debug.LogError("datePanel.placeId" + datePanel.placeId);
|
||||
datePanel.disasterLocation = this.idcidentId.ToString();
|
||||
Debug.LogError("datePanel.disasterLocation" + datePanel.disasterLocation);
|
||||
SelsctDifficulty();
|
||||
SetDataPanelInfo();
|
||||
SetPanel();
|
||||
|
Loading…
Reference in New Issue
Block a user