From 4472c138f0a0d39f90523f433c18309df997649f Mon Sep 17 00:00:00 2001 From: lq <3298408835@qq.com> Date: Mon, 16 Dec 2024 17:11:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/JSONReader/JSONReader.cs | 1 - xiaofang/Assets/Script/Scheduled_03/Panel.cs | 86 ++++++++++--------- .../Script/UI/PanelUI/EvacuationPanel.cs | 32 +++++++ 3 files changed, 79 insertions(+), 40 deletions(-) diff --git a/xiaofang/Assets/Script/JSONReader/JSONReader.cs b/xiaofang/Assets/Script/JSONReader/JSONReader.cs index 5992e035..0b8611fa 100644 --- a/xiaofang/Assets/Script/JSONReader/JSONReader.cs +++ b/xiaofang/Assets/Script/JSONReader/JSONReader.cs @@ -260,7 +260,6 @@ public class JSONReader : MonoBehaviour return null; // 如果没有找到符合条件的语言数据,返回 null } - //获取任务 public Task_ GetTaskByID(int id) { diff --git a/xiaofang/Assets/Script/Scheduled_03/Panel.cs b/xiaofang/Assets/Script/Scheduled_03/Panel.cs index fb567ec8..359d7e6e 100644 --- a/xiaofang/Assets/Script/Scheduled_03/Panel.cs +++ b/xiaofang/Assets/Script/Scheduled_03/Panel.cs @@ -311,51 +311,59 @@ public class Panel : MonoBehaviour // 按“|”分隔不同的角色限制部分 string[] roleLimitSections = npcData.Value.RoleLimit.Split('|'); bool shouldInstantiate = true; - // 遍历每个角色限制部分 - foreach (var section in roleLimitSections) + if(npcData.Value.RoleLimit=="-1") { - // 按“,”分隔出事故位置ID、职业ID和最低要求人数 - string[] roleLimits = section.Split(','); - if (section.Contains("-1")) + break; + } + else + { + foreach (var section in roleLimitSections) { - if (roleLimits[0] == "-1") + // 按“,”分隔出事故位置ID、职业ID和最低要求人数 + string[] roleLimits = section.Split(','); + if (section.Contains("-1")) { - shouldInstantiate = false; // 不实例化该NPC - break; // 跳出循环,直接处理下一个NPC + 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); + + // 设置推荐标记(如果人数不足) + if (minRequired > currentPeopleCount) + { + sceneItem.sceneImage.gameObject.SetActive(true); // 显示推荐标记 + } + else + { + sceneItem.sceneImage.gameObject.SetActive(false); // 隐藏推荐标记 + } + Button scenebutton = item.transform.Find("TextBtn").GetComponent