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.

130 lines
3.6 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
/// <summary>
/// 拆装进度
/// </summary>
public enum Progress
{
,,,CPU,,,,,,
}
public class GameManager : MonoSingleton<GameManager>
{
public static InteractiveUI actionUI;//当前操作的ui
public static Progress progress;
public List<ProgressInstance> instanceLists;
public static Dictionary<Progress, ProgressInstance> instanceMapping;
public Transform cameraPos;
public bool firstEnter = true;
protected override void Awake()
{
base.Awake();
instanceMapping = new Dictionary<Progress, ProgressInstance>();
foreach (var instacne in instanceLists)
{
if (!instanceMapping.ContainsKey(instacne.progress))
{
instanceMapping.Add(instacne.progress,instacne);
}
}
instanceLists = null;
foreach (var instance in instanceMapping.Values)
{
instance.gameObject.SetActive(false);
}
}
/// <summary>
/// 更改状态
/// </summary>
/// <param name="progress"></param>
public static void ChangeProgress(Progress pro)
{
if (instanceMapping.ContainsKey(progress))
{
progress = pro;
Debug.Log(progress);
instanceMapping[progress].gameObject.SetActive(true);
instanceMapping[progress].OpenLine();
}
}
/// <summary>
/// 交互结束回调
/// </summary>
public void InteractEnd()
{
//操作栏ui关掉 提示特效关掉
UI.Instance.operation.SetActive(false);
instanceMapping[progress].CloseLine();
EffectManager.Instance.DisableTipEffect();
TimeLineManager.Instance.pds[(int)progress].Play();
}
/// <summary>
/// 下一阶段
/// </summary>
public void NextProcess()
{
UI.Instance.UpdateJDT();
UI.Instance.CloseOperation();
GameStageManager.Instance.currentStage = GameStage.;
if (progress == Progress.)
{
Camera.main.transform.DOMove(cameraPos.position, 2);
Camera.main.transform.DOLocalRotate(cameraPos.localEulerAngles, 2);
UI.Instance.nextPanel.SetActive(true);
UI.Instance.nextPanel.GetComponentInChildren<Button>().onClick.AddListener(() =>
{
SceneManager.LoadSceneAsync(1);
});
return;
}
ChangeProgress((Progress)((int)progress + 1));
UI.Instance.operation.SetActive(true);
EffectManager.Instance.EnableTipEffect(instanceMapping[progress].transform);
Camera.main.transform.DOMove(cameraPos.position, 2);
Camera.main.transform.DOLocalRotate(cameraPos.localEulerAngles, 2);
}
public void MoveComputer()
{
TimeLineManager.Instance.openComputer.Play();
if (firstEnter)
{
firstEnter = false;
Invoke("EnterHelp",2);
}
else
{
Debug.Log("change");
GameStageManager.Instance.currentStage = GameStage.;
}
}
/// <summary>
/// 玩家选中电脑进入帮助阶段
/// </summary>
void EnterHelp()
{
GameStageManager.Instance.currentStage = GameStage.;
ChangeProgress(Progress.);
EffectManager.Instance.EnableTipEffect(instanceMapping[progress].transform);
}
}