任务相关逻辑
This commit is contained in:
parent
a1787fd70d
commit
c7cf4332da
@ -4,17 +4,29 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public enum TaskStatus
|
||||||
|
{
|
||||||
|
NotAccepted, // 未接受
|
||||||
|
InProgress, // 进行中
|
||||||
|
Completed, // 已完成
|
||||||
|
Failed // 失败
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class TaskItem : MonoBehaviour
|
public class TaskItem : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public int taskId;
|
||||||
|
public string taskName;
|
||||||
|
public TaskStatus status;
|
||||||
|
public List<int> triggers; // 存储任务触发条件
|
||||||
|
|
||||||
public JSONReader jr;
|
public JSONReader jr;
|
||||||
|
|
||||||
public int id;
|
|
||||||
|
|
||||||
public Text tasktxt;
|
public Text tasktxt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
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<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置任务状态
|
||||||
|
public void SetStatus(TaskStatus newStatus)
|
||||||
|
{
|
||||||
|
status = newStatus;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnClickButton()
|
private void OnClickButton()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -29,7 +56,7 @@ public class TaskItem : MonoBehaviour
|
|||||||
|
|
||||||
public void SetInfo(int id,JSONReader js)
|
public void SetInfo(int id,JSONReader js)
|
||||||
{
|
{
|
||||||
this.id = id;
|
taskId = id;
|
||||||
jr = js;
|
jr = js;
|
||||||
UpdateTxt();
|
UpdateTxt();
|
||||||
}
|
}
|
||||||
@ -37,9 +64,9 @@ public class TaskItem : MonoBehaviour
|
|||||||
void UpdateTxt()
|
void UpdateTxt()
|
||||||
{
|
{
|
||||||
|
|
||||||
Language info = jr.GetTaskByID(id,jr.LanguageDictionary);
|
Task_ info = jr.GetTaskByID(taskId);
|
||||||
|
|
||||||
tasktxt.text = info.Text;
|
tasktxt.text = info.Name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
public class TaskPanel : Base
|
public class TaskPanel : Base
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private List<TaskItem> tasks = new List<TaskItem>();
|
||||||
|
private Dictionary<int, Task> activeTasks = new Dictionary<int, Task>();
|
||||||
|
|
||||||
public static TaskPanel instance;
|
public static TaskPanel instance;
|
||||||
|
|
||||||
public List<int> taskId = new List<int>();
|
public List<int> taskId = new List<int>();
|
||||||
|
@ -234,22 +234,12 @@ public class JSONReader : MonoBehaviour
|
|||||||
|
|
||||||
|
|
||||||
//»ñÈ¡ÈÎÎñ
|
//»ñÈ¡ÈÎÎñ
|
||||||
public Language GetTaskByID(int id,Dictionary<int,Language> dic)
|
public Task_ GetTaskByID(int id)
|
||||||
{
|
{
|
||||||
Language info = null;
|
Task_ info = null;
|
||||||
if (LanguageDictionary.TryGetValue(id, out info))
|
if (TaskDictionary.TryGetValue(id.ToString(), out info))
|
||||||
{
|
{
|
||||||
// 判断 Note 是否等于 "预定演练"
|
return info; // 返回符合条件的 Task 数据
|
||||||
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 '预定演练'.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user