疏散人群公布

This commit is contained in:
lq 2024-12-24 18:51:35 +08:00
parent 6f287d0279
commit 9dd5691c73
7 changed files with 198 additions and 117 deletions

View File

@ -2184,7 +2184,7 @@ RectTransform:
- {fileID: 1435623614}
- {fileID: 1120226610}
m_Father: {fileID: 1592869153}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -2256,7 +2256,7 @@ RectTransform:
- {fileID: 5745561351747452950}
- {fileID: 468742197}
m_Father: {fileID: 1592869153}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -2920,7 +2920,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3746951257987266719, guid: e55a074b1a79a9045804c800bf094463, type: 3}
propertyPath: m_RootOrder
value: 5
value: 6
objectReference: {fileID: 0}
- target: {fileID: 3746951257987266719, guid: e55a074b1a79a9045804c800bf094463, type: 3}
propertyPath: m_AnchorMax.x
@ -4091,7 +4091,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1031840000928267012, guid: f7e3ba3643cbe834083789575336030d, type: 3}
propertyPath: m_RootOrder
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1031840000928267012, guid: f7e3ba3643cbe834083789575336030d, type: 3}
propertyPath: m_AnchorMax.x
@ -4111,7 +4111,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1031840000928267012, guid: f7e3ba3643cbe834083789575336030d, type: 3}
propertyPath: m_SizeDelta.x
value: -764
value: -1184
objectReference: {fileID: 0}
- target: {fileID: 1031840000928267012, guid: f7e3ba3643cbe834083789575336030d, type: 3}
propertyPath: m_SizeDelta.y
@ -6201,6 +6201,82 @@ MonoBehaviour:
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &1052243736
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1052243737}
- component: {fileID: 1052243739}
- component: {fileID: 1052243738}
m_Layer: 5
m_Name: MainBg
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1052243737
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1052243736}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1592869153}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 1.984314}
m_SizeDelta: {x: 0, y: -4}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1052243738
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1052243736}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: d04e5f293a8bded4e9e7a61774178a92, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1052243739
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1052243736}
m_CullTransparentMesh: 1
--- !u!1 &1059189496
GameObject:
m_ObjectHideFlags: 0
@ -9213,6 +9289,7 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1052243737}
- {fileID: 618256459}
- {fileID: 7468736064579811971}
- {fileID: 617308872}
@ -13653,7 +13730,7 @@ RectTransform:
m_Children:
- {fileID: 7318934475829044879}
m_Father: {fileID: 1592869153}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -15951,7 +16028,7 @@ RectTransform:
- {fileID: 7468736065836200802}
- {fileID: 7468736064937661070}
m_Father: {fileID: 1592869153}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}

View File

@ -507,7 +507,7 @@ public class LocationData
public string Oversee;
public string EndPoint;
public string RoleLimit;
public int Level;
public string Level;
}
[System.Serializable]
public class EventData

View File

@ -22,6 +22,7 @@ public class SelectedInfo
public string sceneId;//场景Id
public string dutyId;//职责的Id
public string peopleId;//角色Id
public string birthID;//出生地
}
public class Panel : Base

View File

@ -67,7 +67,7 @@ public class EvacuationPanel : MonoBehaviour
submitBtn.onClick.AddListener(totalSubmit);
StuCountInputField.onEndEdit.AddListener(CheckInput);
SetScene();
SetClass();
//SetClass();
}
void Update()
@ -151,6 +151,7 @@ public class EvacuationPanel : MonoBehaviour
Debug.Log($"Scene ID: {kvp.Key}, Assigned NPC Count: {kvp.Value}");
}
}
ShowLevel();
}
//Npc·ÖÅä
@ -253,25 +254,25 @@ public class EvacuationPanel : MonoBehaviour
ChangeImage(redistributeBtn.interactable);
});
}
foreach (Transform child in sceneCount)
{
Destroy(child.gameObject);
}
// 执行后续的场景级别配置
LocationData locationData = js.GetAreaDateById(personnelItem.sceneId);
if (locationData.Level.ToString() != "0")
{
GameObject levelItem = GameObject.Instantiate(scenePrefab, sceneCount);
Button levelBtn = levelItem.transform.Find("chooseBtn2").GetComponent<Button>();
levelBtn.onClick.AddListener(() =>
{
JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
jueseChoicePop.SetClass(personnelItem.sceneId);
jueseChoicePanel.gameObject.SetActive(true);
});
ClassItem classItem = levelItem.GetComponent<ClassItem>();
classItem.classname.text = locationData.Level.ToString();
}
//foreach (Transform child in sceneCount)
//{
// Destroy(child.gameObject);
//}
//// 执行后续的场景级别配置
//LocationData locationData = js.GetAreaDateById(personnelItem.sceneId);
//if (locationData.Level.ToString() != "0")
//{
// GameObject levelItem = GameObject.Instantiate(scenePrefab, sceneCount);
// Button levelBtn = levelItem.transform.Find("chooseBtn2").GetComponent<Button>();
// levelBtn.onClick.AddListener(() =>
// {
// JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
// jueseChoicePop.SetClass(personnelItem.sceneId, personnelItem.sceneText.text);
// jueseChoicePanel.gameObject.SetActive(true);
// });
// ClassItem classItem = levelItem.GetComponent<ClassItem>();
// classItem.classname.text = locationData.Level.ToString();
//}
});
personnelItems.Add(personnelItem);
}
@ -460,4 +461,52 @@ public class EvacuationPanel : MonoBehaviour
redistributeBtn.transform.GetComponent<Image>().sprite = showImage[0];
}
}
//显示右侧的楼层
public void ShowLevel()
{
// 用于存储已经加载过的楼层名称
HashSet<string> loadedClassNames = new HashSet<string>();
foreach (var level in personnelItems)
{
LocationData locationData = js.GetAreaDateById(level.sceneId);
string[] levelLimit = locationData.Level.Split(',');
// 如果楼层不为0
if (levelLimit[0] != "0")
{
// 获取楼层名称
string className = js.SetUIText(int.Parse(levelLimit[1]));
// 如果楼层名称已经加载过,则跳过
if (loadedClassNames.Contains(className))
{
continue; // 跳过该楼层
}
// 否则,添加到 HashSet
loadedClassNames.Add(className);
// 加载楼层
GameObject levelItem = GameObject.Instantiate(scenePrefab, sceneCount);
ClassItem classLevel = levelItem.GetComponent<ClassItem>();
classLevel.classname.text = className;
Button levelBtn = levelItem.transform.Find("chooseBtn2").GetComponent<Button>();
levelBtn.onClick.AddListener(() =>
{
JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
jueseChoicePanel.gameObject.SetActive(true);
});
ClassItem classItem = levelItem.GetComponent<ClassItem>();
}
else
{
continue;
}
}
}
}

View File

@ -12,38 +12,4 @@ public class ClassItem : MonoBehaviour
public Text NoSelectedBtntext;
public GameObject JuesechoicePop;
public bool isSet = false;
// Start is called before the first frame update
//void Start()
//{
// NoSelectedBtn.onClick.AddListener(OpenJueseChoicePop);
// setClassItem("");
//}
//public void setClassItem(string s)
//{
// if(!isSet)
// {
// NoSelectedBtn.gameObject.SetActive(true);
// SelectedBtn.gameObject.SetActive(false);
// }
// else
// {
// //NoSelectedBtn.gameObject.SetActive(true);
// //SelectedBtn.gameObject.SetActive(false);
// SelectedBtn.gameObject.SetActive(true);
// SelectedBtntext.text = s;
// NoSelectedBtn.gameObject.SetActive(false);
// }
//}
//void OpenJueseChoicePop()
//{
// JuesechoicePop.SetActive(true);
// JueseChoicePop jueseChoicePop = JuesechoicePop.GetComponent<JueseChoicePop>();
// jueseChoicePop.SetClassItem(this);
//}
//// Update is called once per frame
//void Update()
//{
//}
}

View File

@ -7,49 +7,11 @@ using UnityEngine.UI;
public class ClassMate : MonoBehaviour
{
public JueseChoicePop jueseChoicePop;
public int id;
public string name;
public Text classmatename;
public string s;
public Button otherButton;
public Button button;
public bool isClear = false;
public bool isBeSet = false;
// Start is called before the first frame update
//void Start()
//{
// button.onClick.AddListener(Click);
// s = classmatename.text;
//}
//public void Click()
//{
// if(isBeSet == false)
// {
// jueseChoicePop.SetClassMate(this);
// }
// else
// {
// //jueseChoicePop.ChangeClassMate();
// }
//}
//public void SetJc(JueseChoicePop jc)
//{
// jueseChoicePop = jc;
//}
//public void setName()
//{
// classmatename.text = s;
//}
//// Update is called once per frame
//void Update()
//{
//}
public bool isBeSet = true;
}

View File

@ -1,8 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.Assertions.Must;
using UnityEngine.Networking.Types;
using UnityEngine.UI;
@ -17,6 +19,8 @@ public class JueseChoicePop : MonoBehaviour
public Transform content;
public List<ClassMate> classMateList = new List<ClassMate> ();
// 存储已实例化的 GameObject 列表
private List<GameObject> instantiatedObjects = new List<GameObject>();
public string s;
public JSONReader jsonReader;
@ -29,6 +33,10 @@ public class JueseChoicePop : MonoBehaviour
Surebtn.onClick.AddListener(CLosePop);
//Surebtn.onClick.AddListener(SetFenguan);
//SetClass();
}
void Update()
{
}
void CLosePop()
{
@ -44,13 +52,17 @@ public class JueseChoicePop : MonoBehaviour
classItem.isSet = true;
//classItem.setClassItem();
}
// Update is called once per frame
void Update()
{
}
public void SetClass(int id)
//加载分管人员
public void SetClass(int id, string scnenName)
{
Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>"+id);
// 检查是否已经实例化过该 id 的对象
if (instantiatedObjects.Any(obj => obj.GetComponent<ClassMate>().id == id))
{
Debug.Log($"这个: {id} 已经被实例化.");
return; // 如果已实例化,跳过
}
// 清除当前内容
foreach (Transform child in content)
{
@ -58,16 +70,19 @@ public class JueseChoicePop : MonoBehaviour
}
// 获取指定 ID 的 LocationData
LocationData locationData = jsonReader.GetAreaDateById(id);
// 判断 Oversee 字段
if (locationData.Oversee == "-1")
{
Debug.Log($"Skipping ID {id}: Oversee is -1.");
return; // 跳过
}
// 分割 Oversee 字段
string[] overseeParts = locationData.Oversee.Split(',');
string firstElement = overseeParts[0];
string lastElement = overseeParts[1];
if (overseeParts.Length > 0)
{
// 判断第一个元素是否为 "1"
@ -81,7 +96,15 @@ public class JueseChoicePop : MonoBehaviour
{
GameObject item = GameObject.Instantiate(classmatePrefab, content);
ClassMate classMate = item.GetComponent<ClassMate>();
classMate.classmatename.text = selectedInfo.name;
Button button = item.GetComponent<Button>();
button.onClick.AddListener(() => {
SetClassMate(classMate, scnenName);
});
classMate.name = selectedInfo.name;
classMate.classmatename.text = classMate.name;
classMate.id = id;
// 将实例化的对象添加到列表中
instantiatedObjects.Add(item);
}
}
}
@ -89,15 +112,18 @@ public class JueseChoicePop : MonoBehaviour
}
}
}
public void SetClassItem(ClassItem classItem)
{
this.classItem = classItem;
}
//点击人员后设置位置的方法
public void SetClassMate(ClassMate classMate, string a = "")
{
classMate.isBeSet = true;
classItem.isSet = true;
this.classMate = classMate;
this.classMate.classmatename.text = classMate.classmatename.text + "(" + classItem.classname.text + ")";
this.classMate.classmatename.text = classMate.name + "(" + a + ")";
classMate.isBeSet = false;
}
public void SetClassItem(ClassItem classItem)
{
this.classItem = classItem;
}
}