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.
177 lines
4.8 KiB
177 lines
4.8 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Cinemachine;
|
|
using DG.Tweening;
|
|
using XWFramework.Tools;
|
|
namespace Level2
|
|
{
|
|
[DefaultExecutionOrder(-7)]
|
|
public class GameManager : MonoSingleton<GameManager>
|
|
{
|
|
public GameObject btn;
|
|
[NonSerialized]
|
|
public UI ui;
|
|
[NonSerialized]
|
|
public DataManager dataManager;
|
|
[NonSerialized]
|
|
public AudioAndAnimaManager aaManager;
|
|
|
|
public CinemachineVirtualCamera cm;
|
|
public Transform cmPlace;
|
|
public Transform cmBirthPlace;
|
|
|
|
[Header("toggle")]
|
|
public Dictionary<int, Action> questionCallBack = new Dictionary<int, Action>();
|
|
[NonSerialized]
|
|
public int questionIndex = 0;
|
|
|
|
[Header("select")]
|
|
public Dictionary<int, Action> selectCallBack = new Dictionary<int, Action>();
|
|
[NonSerialized]
|
|
public int selectIndex = 0;
|
|
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
ui = GetComponentInChildren<UI>();
|
|
dataManager = GetComponentInChildren<DataManager>();
|
|
aaManager = GetComponentInChildren<AudioAndAnimaManager>();
|
|
InitQuestionCallBack();
|
|
InitSelectCallBack();
|
|
}
|
|
|
|
void InitQuestionCallBack()
|
|
{
|
|
questionCallBack.Add(0, OpenYishi);
|
|
questionCallBack.Add(1, OpenHuxi);
|
|
questionCallBack.Add(2, GameEnd);
|
|
}
|
|
|
|
void InitSelectCallBack()
|
|
{
|
|
selectCallBack.Add(0, PlayPDAudio);
|
|
selectCallBack.Add(1, PlayTYAni);
|
|
}
|
|
|
|
#region 流程
|
|
private void Start()
|
|
{
|
|
btn.SetActive(true);
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
aaManager.Level2Start();
|
|
StartCoroutine(WaitExecute(() => {
|
|
ui.ShowTip(dataManager.dialogues[0]);
|
|
}, 1f));
|
|
ui.Show(UIType.Info);
|
|
|
|
StartCoroutine(WaitExecute(() => {
|
|
ui.Show(UIType.Toggle);
|
|
ui.Close(UIType.Tool);
|
|
}, 2.5f));
|
|
}
|
|
|
|
void OpenYishi()
|
|
{
|
|
ui.Show(UIType.Select);
|
|
}
|
|
|
|
void PlayPDAudio() {
|
|
aaManager.Yishi();
|
|
}
|
|
|
|
public void HuhuanEnd() {
|
|
ui.Show(UIType.Toggle);
|
|
ui.Close(UIType.Tool);
|
|
ui.uiDicts[UIType.Info].GetComponent<InfoPanel>().ChangeYishi();
|
|
}
|
|
|
|
void OpenHuxi() {
|
|
ui.Show(UIType.Select);
|
|
}
|
|
|
|
void PlayTYAni() {
|
|
aaManager.Guancha();
|
|
JTTX();
|
|
}
|
|
|
|
public void JTTX()
|
|
{
|
|
StartCoroutine(WaitExecute(2.5f, () => {
|
|
cm.transform.DOMove(cmPlace.position, 0.5f);
|
|
cm.transform.DORotate(cmPlace.localEulerAngles, 0.5f);
|
|
StartCoroutine(WaitExecute(() => {
|
|
cm.transform.DOMove(cmBirthPlace.position, 0.5f);
|
|
cm.transform.DORotate(cmBirthPlace.localEulerAngles, 0.5f);
|
|
}, 7f));
|
|
StartCoroutine(WaitExecute(()=> {
|
|
ui.uiDicts[UIType.Info].GetComponent<InfoPanel>().ChangeHuxi(); aaManager.PlayResult();
|
|
}, 8f));
|
|
StartCoroutine(WaitExecute(() => {
|
|
ui.Show(UIType.Toggle);
|
|
}, 9.5f));
|
|
}));
|
|
}
|
|
|
|
void GameEnd() {
|
|
aaManager.PlayTakeAED();
|
|
aaManager.Idle();
|
|
aaManager.Call();
|
|
aaManager.TakeAed();
|
|
StartCoroutine(WaitExecute(()=> {
|
|
ui.ShowTip(dataManager.dialogues[2]);
|
|
},1f));
|
|
StartCoroutine(WaitExecute(() => {
|
|
aaManager.PlayEnd();
|
|
}, 6f));
|
|
StartCoroutine(WaitExecute(()=>{
|
|
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
|
|
},8f));
|
|
}
|
|
#endregion
|
|
|
|
#region TogglePanel
|
|
public Question GetQuestion()
|
|
{
|
|
return dataManager.questionData[questionIndex];
|
|
}
|
|
|
|
public void QuestionCallBack()
|
|
{
|
|
questionCallBack[questionIndex]();
|
|
}
|
|
#endregion
|
|
|
|
#region SelectPanel
|
|
public Select GetSelectData()
|
|
{
|
|
return dataManager.selectData[selectIndex];
|
|
}
|
|
|
|
public void SelectCallBack()
|
|
{
|
|
selectCallBack[selectIndex]();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
IEnumerator WaitExecute(Action action, float t)
|
|
{
|
|
yield return new WaitForSeconds(t);
|
|
action();
|
|
}
|
|
IEnumerator WaitExecute(float time, Action action)
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
action.Invoke();
|
|
}
|
|
}
|
|
}
|