You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using LitJson;
|
|
using System.IO;
|
|
using UnityEngine.UI;
|
|
using EduCoderTool;
|
|
public class TaskManager : Singleton<TaskManager>
|
|
{
|
|
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<TextAsset>("task");
|
|
//string str = File.ReadAllText(Application.dataPath + "/StreamingAssets/task.json");
|
|
task=JsonMapper.ToObject<Task[]>(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);
|
|
}
|
|
}
|