_xiaofang/xiaofang/Assets/Prefabs/HYLPrefabs/TaskItem.cs

95 lines
1.5 KiB
C#
Raw Normal View History

2024-12-11 14:24:06 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
2024-12-11 20:16:45 +08:00
public enum TaskStatus
{
NotAccepted, // δ<><CEB4><EFBFBD><EFBFBD>
InProgress, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Completed, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Failed // ʧ<><CAA7>
}
public class TaskItem : MonoBehaviour
{
2024-12-11 20:16:45 +08:00
public int taskId;
public string taskName;
public TaskStatus status;
public List<int> triggers; // <20><EFBFBD><E6B4A2><EFBFBD>񴥷<EFBFBD><F1B4A5B7><EFBFBD><EFBFBD><EFBFBD>
2024-12-11 14:24:06 +08:00
public JSONReader jr;
public Text tasktxt;
2024-12-11 20:16:45 +08:00
2024-12-11 14:24:06 +08:00
// Start is called before the first frame update
void Start()
{
}
2024-12-11 20:16:45 +08:00
//<2F><><EFBFBD><EFBFBD><ECBAAF>
public TaskItem(int id, string name)
{
taskId = id;
taskName = name;
status = TaskStatus.NotAccepted;
triggers = new List<int>();
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
public void SetStatus(TaskStatus newStatus)
{
status = newStatus;
}
2024-12-11 14:24:06 +08:00
private void OnClickButton()
{
}
2024-12-12 11:04:48 +08:00
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void SetInfo(int id,JSONReader js)
{
2024-12-11 20:16:45 +08:00
taskId = id;
jr = js;
UpdateTxt();
}
2024-12-12 11:04:48 +08:00
//<2F><><EFBFBD><EFBFBD>Text
void UpdateTxt()
{
2024-12-11 20:16:45 +08:00
Task_ info = jr.GetTaskByID(taskId);
2024-12-12 11:04:48 +08:00
//Debug.Log(info);
tasktxt.text = info.Note;
}
2024-12-12 11:04:48 +08:00
// <20><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void AddTrigger(int triggerType, string value)
{
triggers.Add(triggerType);
}
2024-12-12 14:50:53 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>õĺ<C3B5><C4BA><EFBFBD>
public void OnTaskCompleted()
{
TaskPanel.instance.RemoveTask(taskId);
}
// Update is called once per frame
void Update()
{
}
}