95 lines
1.5 KiB
C#
95 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
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<int> triggers; // 存储任务触发条件
|
|
|
|
public JSONReader jr;
|
|
|
|
public Text tasktxt;
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
//构造函数
|
|
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()
|
|
{
|
|
|
|
}
|
|
|
|
//初始化任务的属性
|
|
public void SetInfo(int id,JSONReader js)
|
|
{
|
|
taskId = id;
|
|
jr = js;
|
|
|
|
UpdateTxt();
|
|
}
|
|
|
|
//更新Text
|
|
void UpdateTxt()
|
|
{
|
|
|
|
Task_ info = jr.GetTaskByID(taskId);
|
|
//Debug.Log(info);
|
|
tasktxt.text = info.Note;
|
|
|
|
}
|
|
|
|
// 添加触发条件
|
|
public void AddTrigger(int triggerType, string value)
|
|
{
|
|
triggers.Add(triggerType);
|
|
}
|
|
|
|
|
|
// 任务完成时调用的函数
|
|
public void OnTaskCompleted()
|
|
{
|
|
TaskPanel.instance.RemoveTask(taskId);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|