diff --git a/xiaofang/Assets/Prefabs/HYLPrefabs/TaskItem.cs b/xiaofang/Assets/Prefabs/HYLPrefabs/TaskItem.cs index 71161bcc..cfd2193c 100644 --- a/xiaofang/Assets/Prefabs/HYLPrefabs/TaskItem.cs +++ b/xiaofang/Assets/Prefabs/HYLPrefabs/TaskItem.cs @@ -4,17 +4,29 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +public enum TaskStatus +{ + NotAccepted, // 未接受 + InProgress, // 进行中 + Completed, // 已完成 + Failed // 失败 +} + + public class TaskItem : MonoBehaviour { - + public int taskId; + public string taskName; + public TaskStatus status; + public List triggers; // 存储任务触发条件 public JSONReader jr; - public int id; - public Text tasktxt; - + + + // Start is called before the first frame update void Start() @@ -22,6 +34,21 @@ public class TaskItem : MonoBehaviour } + //构造函数 + public TaskItem(int id, string name) + { + taskId = id; + taskName = name; + status = TaskStatus.NotAccepted; + triggers = new List(); + } + + // 设置任务状态 + public void SetStatus(TaskStatus newStatus) + { + status = newStatus; + } + private void OnClickButton() { @@ -29,7 +56,7 @@ public class TaskItem : MonoBehaviour public void SetInfo(int id,JSONReader js) { - this.id = id; + taskId = id; jr = js; UpdateTxt(); } @@ -37,9 +64,9 @@ public class TaskItem : MonoBehaviour void UpdateTxt() { - Language info = jr.GetTaskByID(id,jr.LanguageDictionary); + Task_ info = jr.GetTaskByID(taskId); - tasktxt.text = info.Text; + tasktxt.text = info.Name; } diff --git a/xiaofang/Assets/Res/HYLUI/TaskPanel.cs b/xiaofang/Assets/Res/HYLUI/TaskPanel.cs index 15781eb7..c667b7a0 100644 --- a/xiaofang/Assets/Res/HYLUI/TaskPanel.cs +++ b/xiaofang/Assets/Res/HYLUI/TaskPanel.cs @@ -8,6 +8,10 @@ using System.Threading.Tasks; public class TaskPanel : Base { + + private List tasks = new List(); + private Dictionary activeTasks = new Dictionary(); + public static TaskPanel instance; public List taskId = new List(); diff --git a/xiaofang/Assets/Script/JSONReader/JSONReader.cs b/xiaofang/Assets/Script/JSONReader/JSONReader.cs index c3aaa6fa..c955bb6f 100644 --- a/xiaofang/Assets/Script/JSONReader/JSONReader.cs +++ b/xiaofang/Assets/Script/JSONReader/JSONReader.cs @@ -234,22 +234,12 @@ public class JSONReader : MonoBehaviour //获取任务 - public Language GetTaskByID(int id,Dictionary dic) + public Task_ GetTaskByID(int id) { - Language info = null; - if (LanguageDictionary.TryGetValue(id, out info)) + Task_ info = null; + if (TaskDictionary.TryGetValue(id.ToString(), out info)) { - // 判断 Note 是否等于 "预定演练" - if (info.Note == "任务") - { - Debug.Log($"Found Language: ID = {info.ID}, Text = {info.Text}, Note = {info.Note}"); - //dic.Add(id, info); - return info; // 返回符合条件的 Language 数据 - } - else - { - Debug.Log($"Language with ID {id} found, but Note is not '预定演练'."); - } + return info; // 返回符合条件的 Task 数据 } else {