Json文件读取代码调整,任务相关逻辑的编写
This commit is contained in:
parent
c7cf4332da
commit
980e2e96ac
@ -58,6 +58,7 @@ public class TaskItem : MonoBehaviour
|
|||||||
{
|
{
|
||||||
taskId = id;
|
taskId = id;
|
||||||
jr = js;
|
jr = js;
|
||||||
|
|
||||||
UpdateTxt();
|
UpdateTxt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,8 +66,8 @@ public class TaskItem : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
Task_ info = jr.GetTaskByID(taskId);
|
Task_ info = jr.GetTaskByID(taskId);
|
||||||
|
Debug.Log(info);
|
||||||
tasktxt.text = info.Name;
|
tasktxt.text = info.Note;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,26 +56,26 @@ public class JSONReader : MonoBehaviour
|
|||||||
// 解析 JSON 字符串为 Task 数据
|
// 解析 JSON 字符串为 Task 数据
|
||||||
public Dictionary<string, Task_> TaskJSON(string json)
|
public Dictionary<string, Task_> TaskJSON(string json)
|
||||||
{
|
{
|
||||||
NPCData[] npcArray = JsonHelper.FromJson<NPCData>(json);
|
Task_[] npcArray = JsonHelper.FromJson<Task_>(json);
|
||||||
Dictionary<string, Task_> selectDictionary = new Dictionary<string, Task_>();
|
Dictionary<string, Task_> selectDictionary = new Dictionary<string, Task_>();
|
||||||
|
|
||||||
foreach (var npc in npcArray)
|
foreach (var npc in npcArray)
|
||||||
{
|
{
|
||||||
npcDictionary[npc.ID] = npc;
|
TaskDictionary[npc.ID] = npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectDictionary;
|
return TaskDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析 JSON 字符串为 Select 数据
|
// 解析 JSON 字符串为 Select 数据
|
||||||
public Dictionary<string, Select> SelectJSON(string json)
|
public Dictionary<string, Select> SelectJSON(string json)
|
||||||
{
|
{
|
||||||
NPCData[] npcArray = JsonHelper.FromJson<NPCData>(json);
|
Select[] npcArray = JsonHelper.FromJson<Select>(json);
|
||||||
Dictionary<string, Select> selectDictionary = new Dictionary<string, Select>();
|
Dictionary<string, Select> selectDictionary = new Dictionary<string, Select>();
|
||||||
|
|
||||||
foreach (var npc in npcArray)
|
foreach (var npc in npcArray)
|
||||||
{
|
{
|
||||||
npcDictionary[npc.ID] = npc;
|
SelectDictionary[npc.ID] = npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectDictionary;
|
return selectDictionary;
|
||||||
@ -239,13 +239,9 @@ public class JSONReader : MonoBehaviour
|
|||||||
Task_ info = null;
|
Task_ info = null;
|
||||||
if (TaskDictionary.TryGetValue(id.ToString(), out info))
|
if (TaskDictionary.TryGetValue(id.ToString(), out info))
|
||||||
{
|
{
|
||||||
return info; // 返回符合条件的 Task 数据
|
return info;
|
||||||
}
|
}
|
||||||
else
|
else return null;
|
||||||
{
|
|
||||||
Debug.Log($"No Language found with ID: {id}");
|
|
||||||
}
|
|
||||||
return null; // 如果没有找到符合条件的语言数据,返回 null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocationData GetAreaDateById(int id)
|
public LocationData GetAreaDateById(int id)
|
||||||
|
Loading…
Reference in New Issue
Block a user