using System.Collections; using System.Collections.Generic; using UnityEngine; using LitJson; using System.IO; using UnityEngine.UI; using EduCoderTool; public class TaskManager : Singleton { public GameObject TaskPanel; public Text Name; public class Task { public string name; } public int curTaskIndex; public Task[] task; protected override void Awake() { base.Awake(); curTaskIndex = 0; } private void Start() { TextAsset str = Resources.Load("task"); //string str = File.ReadAllText(Application.dataPath + "/StreamingAssets/task.json"); task=JsonMapper.ToObject(str.text); Name.text = task[curTaskIndex].name; } public void StartTask() { TaskPanel.SetActive(true); curTaskIndex = 0; Name.text = task[curTaskIndex].name; //detail.text = task[curTask].detail; } public void FinishTask(int number) { if (number != curTaskIndex) return; if (number == task.Length - 1) { Name.text = "任务已完成,请自由尝试 (30s后消失)"; Invoke("die", 30); EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true); return; } curTaskIndex++; updateTask(curTaskIndex); } void updateTask(int number) { Name.text = task[number].name; //detail.text = task[number].detail; } private void Update() { //updateTask(curTaskIndex); } void die() { TaskPanel.SetActive(false); } }