This commit is contained in:
lq 2024-12-16 17:11:22 +08:00
parent 4cdbf62b8d
commit 4472c138f0
3 changed files with 79 additions and 40 deletions

View File

@ -260,7 +260,6 @@ public class JSONReader : MonoBehaviour
return null; // 如果没有找到符合条件的语言数据,返回 null return null; // 如果没有找到符合条件的语言数据,返回 null
} }
//获取任务 //获取任务
public Task_ GetTaskByID(int id) public Task_ GetTaskByID(int id)
{ {

View File

@ -311,51 +311,59 @@ public class Panel : MonoBehaviour
// 按“|”分隔不同的角色限制部分 // 按“|”分隔不同的角色限制部分
string[] roleLimitSections = npcData.Value.RoleLimit.Split('|'); string[] roleLimitSections = npcData.Value.RoleLimit.Split('|');
bool shouldInstantiate = true; bool shouldInstantiate = true;
// 遍历每个角色限制部分 if(npcData.Value.RoleLimit=="-1")
foreach (var section in roleLimitSections)
{ {
// 按“,”分隔出事故位置ID、职业ID和最低要求人数 break;
string[] roleLimits = section.Split(','); }
if (section.Contains("-1")) else
{
foreach (var section in roleLimitSections)
{ {
if (roleLimits[0] == "-1") // 按“,”分隔出事故位置ID、职业ID和最低要求人数
string[] roleLimits = section.Split(',');
if (section.Contains("-1"))
{ {
shouldInstantiate = false; // 不实例化该NPC if (roleLimits[0] == "-1")
break; // 跳出循环直接处理下一个NPC {
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<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
// 获取当前该位置该职业的人数
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<Button>();
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
sceneItem.sceneId = npcData.Key.ToString();
sceneItem.dutyId = accidentLocationId;
sceneItem.limitNum = minRequired;
sceneItem.sceneName.text = npcData.Value.Note;
peopleList.Add(item);
}
} }
} }
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<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
// 获取当前该位置该职业的人数
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<Button>();
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
sceneItem.sceneId = npcData.Key.ToString();
sceneItem.dutyId = accidentLocationId;
sceneItem.limitNum = minRequired;
sceneItem.sceneName.text = npcData.Value.Note;
peopleList.Add(item);
}
}
} }
// 遍历每个角色限制部分
} }
} }
} }

View File

@ -273,6 +273,38 @@ public class EvacuationPanel : MonoBehaviour
return nonZeroAreas; return nonZeroAreas;
} }
//设置左侧场景显示2.0
public void SetScene()
{
// 清空现有的UI项
foreach (Transform child in personnelContent)
{
Destroy(child.gameObject);
}
// 清空人员列表
personnelItems.Clear();
foreach (var item in js.locationDictionary)
{
if(item.Value.NpcRatio=="-1")
{
break;
}
else
{
string[] npcratio = item.Value.NpcRatio.Split('|');
foreach(var npcLimit in npcratio)
{
string[] limit = npcLimit.Split(',');
if (limit[0] == selectScene.scnenId.ToString()&& limit[1] == selectScene.difficultyId.ToString())
{
}
}
}
}
}
//ÉèÖÃ×ó²à³¡¾°ÏÔʾ //ÉèÖÃ×ó²à³¡¾°ÏÔʾ
public void SetPersonnel() public void SetPersonnel()
{ {