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.

148 lines
4.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using DG.Tweening;
public class Canvas : MonoBehaviour
{
int questionAnswer=-1;
public GameObject mask;
public Text bigTip;
public GameObject toolBag;
public GameObject toolbag2;
public ErrorTip errorTip;
public GameObject step1_1;
public GameObject step1_2;
public GameObject step2_1;
public GameObject moveTip;
public GameObject person1;
public GameObject person2;
public GameObject GameEndTip;
public GameObject tip2;
private void Start()
{
EventManager.Instance.register("StartTip", StartTip);
EventManager.Instance.register("Question", Step1_1);
EventManager.Instance.register("PanDuanSafe", SafeUIChange);
EventManager.Instance.register("OptionOne", OptionOne);
EventManager.Instance.register("TransEnd", TransEnd);
EventManager.Instance.register("EndGame",EndGame);
}
void StartTip(params object[] args) {
DialogueController.Instance.StartDialogue(0,null,bigTip);
}
#region 第一步操作
void Step1_1(params object[] args) {
bigTip.transform.parent.gameObject.SetActive(false);
toolBag.SetActive(true);
step1_1.SetActive(true);
GameEndTip.SetActive(true);
GameEndTip.GetComponentInChildren<DialoguePlay>().PlayText("请点击左侧工具箱进行答题");
}
public void Question(int value)
{
questionAnswer = -1;
questionAnswer = value;
}
public void SunbmitOne() {
if (questionAnswer==0) {
Invoke("wait", 0.5f);
}
else
{
errorTip.InitThis("当前操作有误,请重试");
}
}
void TransEnd(params object[] data) {
toolbag2.SetActive(true);
}
public void SunbmitTwo()
{
if (questionAnswer == 2)
{
toolbag2.SetActive(false);
EventManager.Instance.emit("DisperseCrowd");
Level1Manager.Instance.allOperates[2].Finished();
}
else
{
errorTip.InitThis("当前选择不正确,请重试");
}
}
void wait() {
toolBag.SetActive(false);
person1.SetActive(false);
step1_2.SetActive(true);
}
#endregion
public void FinishOperate() {
if (GameObject.FindGameObjectsWithTag("ZAW").Length == 0)
{
step1_2.SetActive(false);
errorTip.InitThis("恭喜通关",60);
Level1Manager.Instance.allOperates[2].Finished();
GameEndTip.SetActive(true);
GameEndTip.GetComponentInChildren<Text>().text = "已经成功保留充足急救空间,请前往下一关卡";
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
}
else {
errorTip.InitThis("当前环境还处于危险状态,请继续重试");
}
}
void SafeUIChange(params object[] data) {
if ((bool)data[0])
{
if ((bool)data[1])
{
errorTip.InitThis("恭喜通关",60);
tip2.SetActive(false);
step1_2.SetActive(false);
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
}
else {
step1_2.GetComponent<Step1_2>().SafeFinish();
Level1Manager.Instance.allOperates[1].Finished();
Level1Manager.Instance.AddOperate(Level1Const.operate3Info);
}
}
else {
errorTip.InitThis("当前环境判断错误,请重新判断");
}
}
void OptionOne(params object[] data)
{
if ((int)data[0] == 0)
{
mask.SetActive(true);
mask.GetComponent<Image>().DOColor(new Color(0, 0, 0, 1), 1);
errorTip.InitThis("正在转移");
Invoke("CloseMask", 3);
step1_2.SetActive(false);
}
else if ((int)data[0] == 1)
{
errorTip.InitThis("当前选择错误,请重新选择");
}
}
void CloseMask() {
mask.GetComponent<Image>().DOColor(new Color(0, 0, 0, 0), 1);
mask.SetActive(false);
}
void EndGame(params object[] data) {
errorTip.InitThis("恭喜通关",60);
GameEndTip.SetActive(true);
GameEndTip.GetComponentInChildren<DialoguePlay>().PlayText("已经成功保留充足急救空间,请前往下一关卡");
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
}
}