应急疏散人员

This commit is contained in:
lq 2024-12-01 15:06:22 +08:00
parent 893f7368c1
commit 350a7e0deb
7 changed files with 95 additions and 81 deletions

View File

@ -255,6 +255,9 @@ MonoBehaviour:
dutyImage: {fileID: 3344224971186253052}
dutyNameText: {fileID: 3344224971532102837}
button: {fileID: 3344224971532102794}
leader: 0
defaultColor: {r: 1, g: 1, b: 1, a: 1}
addedColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
selectedColor: {r: 1, g: 0.92156863, b: 0.015686275, a: 1}
sceneButtonObject: {fileID: 3344224971532102792}
sceneText: {fileID: 3344224971532102837}

View File

@ -2501,7 +2501,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -193.59004, y: 309.8263}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &667280288
MonoBehaviour:
@ -7914,24 +7914,32 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 2
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Mode
value: 2
objectReference: {fileID: 0}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Target
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 617308873}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Target
value:
objectReference: {fileID: 11500000, guid: bf46134b79a6f364eb7461349a15ee8a, type: 3}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnItemClicked
objectReference: {fileID: 0}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName
value:
objectReference: {fileID: 0}
- target: {fileID: 9016252888809016807, guid: a15ee694d5f79864d816998fae77116d, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_TargetAssemblyTypeName
value: ManagerPanel, Assembly-CSharp
@ -9540,7 +9548,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1600693806
RectTransform:
m_ObjectHideFlags: 0
@ -10583,7 +10591,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2102021660636739381, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: -361.72
objectReference: {fileID: 0}
- target: {fileID: 2102021660636739381, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_SizeDelta.y
@ -10679,19 +10687,19 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4764228630658219266, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228630658219266, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228630658219266, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 190.05
objectReference: {fileID: 0}
- target: {fileID: 4764228630658219266, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -23.991
objectReference: {fileID: 0}
- target: {fileID: 4764228630805767484, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_Name
@ -10699,7 +10707,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4764228630805767484, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_IsActive
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4764228630805767485, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_Pivot.x
@ -10787,59 +10795,59 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4764228631245731675, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 249.00002
objectReference: {fileID: 0}
- target: {fileID: 4764228631278755135, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 629.702
objectReference: {fileID: 0}
- target: {fileID: 4764228631451568083, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228631451568083, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228631451568083, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 133.7755
objectReference: {fileID: 0}
- target: {fileID: 4764228631451568083, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -39.08695
objectReference: {fileID: 0}
- target: {fileID: 4764228632225803364, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228632225803364, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228632225803364, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 58.95
objectReference: {fileID: 0}
- target: {fileID: 4764228632225803364, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -23.991
objectReference: {fileID: 0}
- target: {fileID: 4764228632238488446, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228632238488446, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4764228632238488446, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 495.9265
objectReference: {fileID: 0}
- target: {fileID: 4764228632238488446, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -39.08695
objectReference: {fileID: 0}
- target: {fileID: 9196293257107006892, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_IsActive
@ -12809,7 +12817,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_AnchorMin.x
@ -12817,7 +12825,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_SizeDelta.x
@ -12857,11 +12865,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_AnchoredPosition.x
value: 194.0772
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_AnchoredPosition.y
value: -29.2995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204671800070690485, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
@ -14160,10 +14168,10 @@ RectTransform:
m_Father: {fileID: 7318934474885050404}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 21, y: -5.0004883}
m_SizeDelta: {x: -764, y: -343}
m_SizeDelta: {x: 1156, y: 737}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &7318934476091951409
RectTransform:

View File

@ -14,6 +14,7 @@ public class SelectedInfo
public string name;
public string duty;
public string scene;
public string leader;
}
@ -97,6 +98,7 @@ public class Panel : MonoBehaviour
GameObject item = GameObject.Instantiate<GameObject>(dutyPrefab, dutyCount);
DutyItem dutyItem = item.GetComponent<DutyItem>();
dutyItem.dutyNameText.text = npcData.Value.Note;
dutyItem.leader = npcData.Value.GroupLeader;
//Debug.Log("$$$$$$$$$$$$$$" + dutyItem.dutyNameText.text);
peopleList.Add(item);// 将每个实例化的角色添加到列表中
}
@ -107,10 +109,7 @@ public class Panel : MonoBehaviour
{
foreach (var npcData in jsonReader1.locationDictionary)
{
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
sceneItem.sceneName.text = npcData.Value.Note;
// 通过“|”分隔 RoleLimit 字段
// 解析角色限制字段
string roleLimit = npcData.Value.RoleLimit;
if (!string.IsNullOrEmpty(roleLimit))
@ -119,53 +118,47 @@ public class Panel : MonoBehaviour
string[] roleLimitSections = roleLimit.Split('|');
// 遍历每个部分(按“|”分隔后得到的数组)
bool shouldInstantiate = true; // 用于判断是否需要实例化
foreach (string section in roleLimitSections)
{
// 判断当前部分是否包含 "-1"
// 判断当前部分是否包含 "-1" 来决定是否跳过实例化
if (section.Contains("-1"))
{
Debug.Log("角色限制为-1区域限制人数为无限");
sceneItem.limitNum = int.MaxValue;
continue; // 跳过当前部分,不进行后续处理
}
// 判断职业ID或其他条件决定是否跳过
string[] roleLimits = section.Split(',');
// 对每个部分再按“,”分隔
string[] roleLimits = section.Split(',');
// 判断是否有足够的元素至少3个
if (roleLimits.Length >= 3)
{
// 获取第三个元素并进行判断
string thirdElement = roleLimits[2];
Debug.Log("第三个元素的值是:" + thirdElement);
sceneItem.limitNum = int.Parse(thirdElement);
// 判断第三个元素的值
if (thirdElement == "某个特定值") // 这里的 "某个特定值" 你可以根据需求更改
// 这里假设职业ID在第一个位置且为-1时表示不可作为出生点
if (roleLimits[0] == "-1")
{
Debug.Log("第三个元素满足条件!");
//Debug.Log("该职业不能作为出生点,不在预订演练,跳过实例化!");
shouldInstantiate = false; // 不实例化该NPC
break; // 跳出循环直接处理下一个NPC
}
else
// 处理“-1”表示无限制人数的情况
if (roleLimits[2] == "-1")
{
Debug.Log("第三个元素不满足条件!");
//Debug.Log("角色限制为-1区域限制人数为无限");
// 可以选择设置limitNum为无限制
}
}
else
{
Debug.Log("当前部分数据不足3个元素无法检查第三个元素");
}
}
// 如果不满足实例化条件跳过当前NPC的实例化
if (!shouldInstantiate)
{
continue;
}
}
else
{
Debug.Log("RoleLimit is empty for NPC ID: " + npcData.Key);
}
// 实例化NPC预制体
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
sceneItem.sceneName.text = npcData.Value.Note;
// 将每个实例化的角色添加到列表中
peopleList.Add(item);
}
}
//处理人员管理按钮
@ -216,16 +209,23 @@ public class Panel : MonoBehaviour
if (count >= 1) // 如果已经有1个此职责的人选
{
Debug.LogError($"{selectedInfo.duty} 已达最大人数限制");
Debug.LogError($"{selectedInfo.duty} 已达最大人数限制");
isLimitReached = true; // 标记限制已达
}
}
// 如果没有达到上限,则可以添加人员信息
if (!isLimitReached)
{
// 通过创建一个新的 SelectedInfo 实例来避免引用同一个对象
SelectedInfo newSelectedInfo = new SelectedInfo
{
name = selectedInfo.name,
duty = selectedInfo.duty,
scene = selectedInfo.scene
};
// 将当前选中的人员信息添加到对应场景的人员列表中
currentSceneInfo.Add(selectedInfo);
currentSceneInfo.Add(newSelectedInfo);
// 打印当前场景人员信息
Debug.Log($"场景: {sceneName},选中的人员: {selectedInfo.name},职责: {selectedInfo.duty}");
@ -239,7 +239,6 @@ public class Panel : MonoBehaviour
// 改变已添加人员的显示颜色
UpdatePeopleListVisual();
}
}
else
{
@ -249,6 +248,7 @@ public class Panel : MonoBehaviour
// 可以在这里根据需求继续处理选中的数据
}
//处理界面关闭按钮
public void ClickCloseBtn()
{
@ -411,5 +411,7 @@ public class Panel : MonoBehaviour
}
}
}
}

View File

@ -8,6 +8,7 @@ public class DutyItem : MonoBehaviour
public Image dutyImage;
public Text dutyNameText;
public Button button;
public int leader;
public Color defaultColor = Color.white; // 默认颜色
public Color addedColor = Color.gray; // 已添加颜色
public Color selectedColor = Color.yellow; // 选中颜色
@ -21,13 +22,13 @@ public class DutyItem : MonoBehaviour
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Setup(string name, bool added)
{
@ -56,4 +57,5 @@ public class DutyItem : MonoBehaviour
{
onClick?.Invoke();
}
}
}

View File

@ -23,6 +23,9 @@ public class EvacuationPanel : MonoBehaviour
public Button redistributeBtn;
public Button submitBtn;
[Header("Npc数量")]
public int npcNum;
// Start is called before the first frame update
void Start()
{
@ -47,7 +50,6 @@ public class EvacuationPanel : MonoBehaviour
PersonnelItem personnelItem=item.GetComponent<PersonnelItem>();
personnelItem.sceneText.text = sceneEntry.Key;
personnelItem.personnelNum.text = sceneEntry.Value.Count.ToString();
}
}
//判断输入框的数字是否大于1
@ -94,5 +96,9 @@ public class EvacuationPanel : MonoBehaviour
classItem.JuesechoicePop = JuesechoicePop;
}
}
//Npc分配
public void NpcDistribution()
{
}
}

View File

@ -70,17 +70,14 @@ public class ManagerPanel : MonoBehaviour
RectTransform rt = currentSelectedItem.GetComponent<RectTransform>();
rt.localScale = originalScale; // 恢复原始大小
}
// 记录当前选中项的原始大小
RectTransform clickedItemRT = clickedItem.GetComponent<RectTransform>();
if (originalScale == Vector3.zero)
{
originalScale = clickedItemRT.localScale; // 只记录一次原始大小
}
// 更新当前选中的项
currentSelectedItem = clickedItem;
// 放大当前选中的项
clickedItemRT.localScale = originalScale * 1.2f; // 放大1.2倍
// 使当前选中的项居中显示
@ -135,7 +132,6 @@ public class ManagerPanel : MonoBehaviour
//关闭人员窗口
public void OnCloseWindowsBtn()
{
Debug.Log("111111111111111");
peopleWindowsPrefab.gameObject.SetActive(false);
}

View File

@ -34,9 +34,6 @@ public class PersonnelPanel : MonoBehaviour
}
public void CreatePersonelItem(SelectedInfo person, Transform parentTransform)
{
//Transform contentTransform = parentTransform.transform.Find("Scroll View/Viewport/Content");
Debug.Log("============"+ parentTransform == null);
// 实例化一个人员项并将其作为场景面板的子物体
GameObject item = Instantiate(personelItem, parentTransform);
PersonnelInfo personnelItem = item.GetComponent<PersonnelInfo>();