Tz2/Assets/Zion/Scripts/ChangeScence.cs

87 lines
2.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityStandardAssets.Characters.FirstPerson;
using DG.Tweening;
using static InterfaceManager;
public class ChangeScence : MonoBehaviour
{
public static ChangeScence Instanc;
public bool IsHideGui = false;
/// <summary>
/// 仓库按钮
/// </summary>
public Button warehousebt;
/// <summary>
/// 称重按钮
/// </summary>
public Button weighbt;
/// <summary>
/// 大厅按钮
/// </summary>
public Button hallbt;
public Button diannaofang;
public List<Transform> Point = new List<Transform>();
private void Awake()
{
Instanc = this;
}
void Start()
{
diannaofang.onClick.AddListener(() =>
{
StartCoroutine(WaitFade(Point[3],diannaofang.name));
});
hallbt.onClick.AddListener(() =>
{
StartCoroutine(WaitFade(Point[0],hallbt.name));
});
weighbt.onClick.AddListener(() =>
{
StartCoroutine(WaitFade(Point[1],weighbt.name));
});
warehousebt.onClick.AddListener(() =>
{
StartCoroutine(WaitFade(Point[2],warehousebt.name));
if (GameManager.Instance.combinedClass.Subjectname.Contains("不可用办理实物退库"))
{
IsHideGui = true;
}
});
}
void Update()
{
}
/// <summary>
/// 延迟显示黑屏
/// </summary>
/// <returns></returns>
public IEnumerator WaitFade(Transform transform,string btnName)
{
Transform player = GameObject.FindWithTag("Player").transform;
Image bg = player.GetComponentInChildren<Image>();
player.GetComponent<FirstPersonController>().enabled = false;
bg.DOFade(1, 1.9f);
yield return new WaitForSeconds(2f);
bg.DOFade(0, 1.9f);
player.SetLocalPositionAndRotation(transform.position, Quaternion.Euler(0, -90, 0));
yield return new WaitForSeconds(0.1f);
player.GetComponent<FirstPersonController>().enabled = true;
player.GetComponent<FirstPersonController>().InitController();
if (IsHideGui)
{
LoadTriggerNextGuide("关闭");;
}
else
{
LoadTriggerNextGuide(btnName);
}
}
}