From 161b95deda9a8d0b1263ec3186acf6fbf11b0e56 Mon Sep 17 00:00:00 2001 From: lq <3298408835@qq.com> Date: Mon, 16 Dec 2024 17:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=8C=BA-1=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Script/Scheduled_03/Panel.cs | 59 ++++++++----------- .../Script/UI/PanelUI/EvacuationPanel.cs | 43 +++++++++++++- 2 files changed, 66 insertions(+), 36 deletions(-) diff --git a/xiaofang/Assets/Script/Scheduled_03/Panel.cs b/xiaofang/Assets/Script/Scheduled_03/Panel.cs index 359d7e6e..4b5a175d 100644 --- a/xiaofang/Assets/Script/Scheduled_03/Panel.cs +++ b/xiaofang/Assets/Script/Scheduled_03/Panel.cs @@ -321,44 +321,33 @@ public class Panel : MonoBehaviour { // 按“,”分隔出事故位置ID、职业ID和最低要求人数 string[] roleLimits = section.Split(','); - if (section.Contains("-1")) + string accidentLocationId = roleLimits[0]; // 事故位置ID + string difficultyId = roleLimits[1]; + string roleId = roleLimits[2]; // 职业ID + int minRequired = int.Parse(roleLimits[3]); // 最低要求人数 + if (accidentLocationId == selectScenePanel.idcidentId.ToString() && roleId == id.ToString() && difficultyId == selectScenePanel.difficultyId.ToString()) { - if (roleLimits[0] == "-1") - { - shouldInstantiate = false; // 不实例化该NPC - break; // 跳出循环,直接处理下一个NPC - } - } - else - { - string accidentLocationId = roleLimits[0]; // 事故位置ID - string difficultyId = roleLimits[1]; - string roleId = roleLimits[2]; // 职业ID - int minRequired = int.Parse(roleLimits[3]); // 最低要求人数 - if (accidentLocationId == selectScenePanel.idcidentId.ToString() && roleId == id.ToString() && difficultyId == selectScenePanel.difficultyId.ToString()) - { - GameObject item = GameObject.Instantiate(scenePrefab, sceneCount); - SceneItem sceneItem = item.GetComponent(); - // 获取当前该位置该职业的人数 - int currentPeopleCount = GetCurrentPeopleCount(accidentLocationId, roleId); + GameObject item = GameObject.Instantiate(scenePrefab, sceneCount); + SceneItem sceneItem = item.GetComponent(); + // 获取当前该位置该职业的人数 + int currentPeopleCount = GetCurrentPeopleCount(accidentLocationId, roleId); - // 设置推荐标记(如果人数不足) - if (minRequired > currentPeopleCount) - { - sceneItem.sceneImage.gameObject.SetActive(true); // 显示推荐标记 - } - else - { - sceneItem.sceneImage.gameObject.SetActive(false); // 隐藏推荐标记 - } - Button scenebutton = item.transform.Find("TextBtn").GetComponent