Language传入

This commit is contained in:
lq 2024-12-12 19:58:55 +08:00
parent b7948af071
commit 0e0fe09cbc
4 changed files with 225 additions and 193 deletions

View File

@ -1,170 +1,182 @@
[ [
{ {
"ID": 8000, "ID": "8000",
"Note": "主持人", "Note": "主持人",
"Name": "2001,8001|2002,8001|2003,80022", "Name": "2001,1,8000|2001,2,8000|2001,6,8000",
"ActionMode": 0, "ActionMode": "0",
"Group": -1, "Group": "-1",
"GroupLeader": 3, "GroupLeader": "3",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_312", "ICON": "ICON_312",
"WeightLimit": -1, "WeightLimit": "-1",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "-1",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b013.Prefeb" "ResPath": "\\ASSETS\\b013.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8001, "ID": "8001",
"Note": "总指挥", "Note": "总指挥",
"Name": "2001,8001|2002,8001|2003,80010", "Name": "2001,1,8001|2001,2,8001|2001,6,8001",
"ActionMode": 2, "ActionMode": "2",
"Group": -1, "Group": "-1",
"GroupLeader": 2, "GroupLeader": "2",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_313", "ICON": "ICON_313",
"WeightLimit": 6, "WeightLimit": "5",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b001.Prefeb" "ResPath": "\\ASSETS\\b001.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8002, "ID": "8002",
"Note": "抢险救援组", "Note": "抢险救援组",
"Name": "2001,8001|2002,8001|2003,80011", "Name": "2001,1,8002|2001,2,8002|2001,6,8002",
"ActionMode": 2, "ActionMode": "2",
"Group": 8003, "Group": "8003",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_314", "ICON": "ICON_314",
"WeightLimit": 6, "WeightLimit": "5",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b002.Prefeb" "ResPath": "\\ASSETS\\b002.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8003, "ID": "8003",
"Note": "(组长)抢险救援组", "Note": "(组长)抢险救援组",
"Name": "2001,8001|2002,8001|2003,80012", "Name": "2001,1,8003|2001,2,8003|2001,6,8003",
"ActionMode": 2, "ActionMode": "2",
"Group": -1, "Group": "-1",
"GroupLeader": 1, "GroupLeader": "1",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_315", "ICON": "ICON_315",
"WeightLimit": 6, "WeightLimit": "5",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b003.Prefeb" "ResPath": "\\ASSETS\\b003.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8004, "ID": "8004",
"Note": "医疗救护组", "Note": "医疗救护组",
"Name": "2001,8001|2002,8001|2003,80013", "Name": "2001,1,8004|2001,2,8004|2001,6,8004",
"ActionMode": 2, "ActionMode": "2",
"Group": 8005, "Group": "8005",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_316", "ICON": "ICON_316",
"WeightLimit": 6, "WeightLimit": "5",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b004.Prefeb" "ResPath": "\\ASSETS\\b004.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8005, "ID": "8005",
"Note": "(组长)医疗救护组", "Note": "(组长)医疗救护组",
"Name": "2001,8001|2002,8001|2003,80014", "Name": "2001,1,8005|2001,2,8005|2001,6,8005",
"ActionMode": 2, "ActionMode": "2",
"Group": -1, "Group": "-1",
"GroupLeader": 1, "GroupLeader": "1",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_317", "ICON": "ICON_317",
"WeightLimit": 6, "WeightLimit": "5",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b005.Prefeb" "ResPath": "\\ASSETS\\b005.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8006, "ID": "8006",
"Note": "疏散引导组1", "Note": "疏散引导组1",
"Name": "2001,8001|2002,8001|2003,80015", "Name": "2001,1,8005|2001,2,8005|2001,6,8999",
"ActionMode": 1, "ActionMode": "1",
"Group": 8001, "Group": "8001",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 1, "IsLeadingNPC": "1",
"ICON": "ICON_318", "ICON": "ICON_318",
"WeightLimit": -1, "WeightLimit": "-1",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b006.Prefeb" "ResPath": "\\ASSETS\\b006.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8007, "ID": "8007",
"Note": "疏散引导组2", "Note": "疏散引导组2",
"Name": "2001,8001|2002,8001|2003,80016", "Name": "2002,1,8007|2002,2,8007|2002,3,8999",
"ActionMode": 1, "ActionMode": "2",
"Group": 8001, "Group": "8001",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 1, "IsLeadingNPC": "1",
"ICON": "ICON_319", "ICON": "ICON_319",
"WeightLimit": -1, "WeightLimit": "-1",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b007.Prefeb" "ResPath": "\\ASSETS\\b007.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8008, "ID": "8008",
"Note": "后勤保障组", "Note": "后勤保障组",
"Name": "2001,8001|2002,8001|2003,80017", "Name": "2001,1,8008|2001,2,8008|2001,6,8008",
"ActionMode": 2, "ActionMode": "2",
"Group": 8009, "Group": "8009",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_320", "ICON": "ICON_320",
"WeightLimit": 12, "WeightLimit": "10",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b008.Prefeb" "ResPath": "\\ASSETS\\b008.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8009, "ID": "8009",
"Note": "(组长)后勤保障组", "Note": "(组长)后勤保障组",
"Name": "2001,8001|2002,8001|2003,80018", "Name": "2001,1,8009|2001,2,8009|2001,6,8009",
"ActionMode": 2, "ActionMode": "2",
"Group": -1, "Group": "-1",
"GroupLeader": 1, "GroupLeader": "1",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_321", "ICON": "ICON_321",
"WeightLimit": 12, "WeightLimit": "10",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b009.Prefeb" "ResPath": "\\ASSETS\\b009.Prefeb",
"ManageLevel": "-1"
}, },
{ {
"ID": 8010, "ID": "8010",
"Note": "搜寻组", "Note": "搜寻组",
"Name": "2001,8001|2002,8001|2003,80019", "Name": "2001,1,8010|2001,2,8010|2001,6,8010",
"ActionMode": 2, "ActionMode": "2",
"Group": 8001, "Group": "8001",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 0, "IsLeadingNPC": "0",
"ICON": "ICON_322", "ICON": "ICON_322",
"WeightLimit": 6, "WeightLimit": "5",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b010.Prefeb" "ResPath": "\\ASSETS\\b010.Prefeb",
"ManageLevel": "1|2|3|4|5"
}, },
{ {
"ID": 8011, "ID": "8011",
"Note": "学生寝室长", "Note": "学生寝室长",
"Name": "2001,8001|2002,8001|2003,80021", "Name": "2002,1,8011|2002,2,8011|2002,3,8999",
"ActionMode": 1, "ActionMode": "1",
"Group": 8001, "Group": "8001",
"GroupLeader": 0, "GroupLeader": "0",
"IsLeadingNPC": 1, "IsLeadingNPC": "1",
"ICON": "ICON_323", "ICON": "ICON_323",
"WeightLimit": -1, "WeightLimit": "-1",
"Stats": "1,4.5|2,2|3,1|4,0|5,0|6,100", "Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1", "Skills": "4001,-1|4003,202|4005,-1",
"ResPath": "\\ASSETS\\b012.Prefeb" "ResPath": "\\ASSETS\\b012.Prefeb",
"ManageLevel": "-1"
} }
] ]

View File

@ -296,10 +296,18 @@ public class JSONReader : MonoBehaviour
} }
//设置UI文本的方法 //设置UI文本的方法
public void SetUIText(Text text, int id) public string SetUIText(int id)
{ {
Language languageinfo = GetLanguageByID(id); Language info = null;
text.text = languageinfo.Text; if (LanguageDictionary.TryGetValue(id, out info))
{
return info.Text;
}
else
{
Debug.Log($"No Language found with ID: {id}");
return null;
}
} }
} }

View File

@ -137,7 +137,7 @@ public class Panel : MonoBehaviour
} }
} }
//动态加载职责 //动态加载职责
public void DynamicLoadingDuty(int id) public void DynamicLoadingDuty(int id,int idcidentId)
{ {
if (selectScenePanel.difficultyToRoles.ContainsKey(id)) if (selectScenePanel.difficultyToRoles.ContainsKey(id))
{ {
@ -152,9 +152,18 @@ public class Panel : MonoBehaviour
{ {
var npcInfo = jsonReader1.npcDictionary[roleId]; var npcInfo = jsonReader1.npcDictionary[roleId];
// 创建DutyItem实例 // 创建DutyItem实例
string[] roleLimitSections = npcData.Name.Split('|');
foreach(string plopleInfo in roleLimitSections)
{
string[] peopleLimit = plopleInfo.Split(',');
if (peopleLimit[0] == idcidentId.ToString() && peopleLimit[1]==id.ToString())
{
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount); GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
DutyItem dutyItem = item.GetComponent<DutyItem>(); DutyItem dutyItem = item.GetComponent<DutyItem>();
Button dutuybutton = item.transform.Find("TextBtn").GetComponent<Button>(); Button dutuybutton = item.transform.Find("TextBtn").GetComponent<Button>();
string showText = jsonReader1.SetUIText(int.Parse(peopleLimit[2]));
dutuybutton.onClick.AddListener(() => dutuybutton.onClick.AddListener(() =>
{ {
OnDutyItemClicked(item, Color.red, selectedDuty); OnDutyItemClicked(item, Color.red, selectedDuty);
@ -172,12 +181,15 @@ public class Panel : MonoBehaviour
SetScene(dutyItem.dutyId); SetScene(dutyItem.dutyId);
} }
}); });
dutyItem.dutyNameText.text = npcData.Note; dutyItem.dutyNameText.text = showText;
dutyItem.leader = npcData.GroupLeader; dutyItem.leader = npcData.GroupLeader;
dutyItem.dutyId = npcData.ID; dutyItem.dutyId = npcData.ID;
peopleList.Add(item); peopleList.Add(item);
} }
} }
}
}
} }
} }
//动态加载场景 //动态加载场景

View File

@ -447,7 +447,7 @@ public class SelectScenePanel : MonoBehaviour
DisableUIInteraction(); DisableUIInteraction();
panel.DynamicLoadingPeople(); panel.DynamicLoadingPeople();
panel.DynamicLoadingScene(); panel.DynamicLoadingScene();
panel.DynamicLoadingDuty(this.difficultyId); panel.DynamicLoadingDuty(this.difficultyId,this.idcidentId);
isSure = true; isSure = true;
} }