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.

89 lines
2.0 KiB

1 year ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class TaskBase : MonoBehaviour
{
public static TaskBase Instacne {
get {
if (_instance == null)
{
_instance = new TaskBase();
}
return _instance;
}
}
private static TaskBase _instance;
public GameObject shouTip;
public Transform[] points;//手的点位
public Text tipText;
protected GameObject shou;
protected bool gameEnd = false;
protected int curIndex = -1;
[TextArea]
public string[] taskInfo;
protected virtual void Awake()
{
_instance = this;
}
protected virtual void Start()
{
StartTask(0);
}
protected virtual void Update()
{
if (gameEnd) return;
shou.transform.position = points[curIndex].position + Vector3.down * 10;
}
protected void StartTask(int index)
{
curIndex = index;
TaskTip(taskInfo[curIndex], points[curIndex].position);
}
public virtual void TaskTip(string str, Vector3 pos)
{
tipText.text = "";
tipText.DOText(str, 1);
if (shou)
{
shou.SetActive(true);
}
else
{
shou = Instantiate(shouTip, FindObjectOfType<Canvas>().transform);
}
shou.transform.position = pos + Vector3.down * 10;
}
public virtual void FinishTask(int index)
{
if (index != curIndex) return;
curIndex++;
if (index == points.Length - 1)
{
shou.SetActive(false);
tipText.text = "";
tipText.DOText("恭喜通关", 1);
gameEnd = true;
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
return;
}
shou.SetActive(false);
StartTask(curIndex);
}
public virtual void TaskFinish()
{
shou.SetActive(false);
tipText.text = "";
tipText.DOText("恭喜通关", 1);
}
}