
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;
using Pvr_UnitySDKAPI;
public class WaSiTuChuManager : GameManager
{
public GameObject TheMe;
public GameObject UITip;
public GameObject UI事故地点概况;
public GameObject UI瓦斯突出发生经过;
public GameObject UITitle;
public GameObject 虫洞;
public GameObject 穿越;
public GameObject[] Env;
public GameObject Card;
public PlayableDirector WaSiTuChuTimeLine;
private Transform Player;
public AudioClip StartClip, ShiGuDiDianGaiKuoClip;
private AudioSource AudioTips, AudioBgs;
public GameObject MarkRImage;
public GameObject UIYuanYin;
private Button btnBlack;
public AudioClip insert1Clip;
public AudioClip insert2Clip;
public AudioClip insert3Clip;
private Clips AudioClips;
private bool 跳过事故地点概况 = false;
public GameObject UIWork;
public Sprite[] WorkPrites;
public AudioClip[] WorkAudioClips;
public float[] clipcTime;
bool Insert1 = true, Insert2 = true, Insert3 = true, Insert4 = true;
public GameObject 详情分析;
private void Awake()
{
Init();
StartCoroutine(InitGame());
}
void Update()
{
if (跳过事故地点概况 && (Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.TRIGGER) ||
Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.TRIGGER) ||
Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.TOUCHPAD) ||
Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.TOUCHPAD) || Input.GetKeyUp(KeyCode.Space)))
{
跳过事故地点概况 = false;
StopAllCoroutines();
StartCoroutine(跳过事故概况());
}
}
void OnClick() {
详情分析.GetChild(0).SetActive(false);
详情分析.GetChild(1).SetActive(true);
}
private void Init()
{
详情分析.GetChild(0).GetChild(0).GetComponent<Button>().onClick.AddListener(OnClick);
虫洞.SetActive(false);
穿越.SetActive(false);
AudioBgs = transform.Find("Audio").Find("AudioBgs").GetComponent<AudioSource>();
AudioTips = transform.Find("Audio").Find("TipsAudio").GetComponent<AudioSource>();
AudioClips = AudioTips.transform.parent.GetComponent<Clips>();
Player = GetComponent<RayManager>().HeadStart.parent;
}
IEnumerator InitGame()
{
TheMe.SetActive(true);
yield return new WaitForSeconds(3);
TheMe.SetActive(false);
UITip.SetActive(true);
UITip.GetChild(0).GetComponent<Text>().DOText("2014年10月8日15时45分,贵州省某煤矿发生一起煤与瓦斯突出事故,造成13人死亡,5人受伤,直接经济损失2890.8万元。", 16).SetEase(Ease.Linear);
AudioTips.clip = StartClip;
AudioTips.Play();
yield return new WaitForSeconds(16);
UITip.GetChild(0).GetComponent<Text>().text = "";
UITip.SetActive(false);
UITitle.SetActive(true);
UITitle.GetChild(0).GetComponent<Text>().text = "一、矿井及事故地点概况";
yield return new WaitForSeconds(1);
UITitle.GetChild(0).GetComponent<Text>().text = "";
UITitle.SetActive(false);
跳过事故地点概况 = true;
UI事故地点概况.SetActive(true);
UI事故地点概况.GetChild(0).SetActive(true);
UI事故地点概况.GetChild(0).GetChild(0).SetActive(true);
UI事故地点概况.GetChild(0).GetChild(1).GetChild(1).GetComponent<Text>().text = "地点概括";
yield return new WaitForSeconds(0.5f);
UI事故地点概况.GetChild(0).GetChild(1).SetActive(true);
UI事故地点概况.GetChild(0).GetChild(1).GetChild(1).SetActive(true);
yield return new WaitForSeconds(0.5f);
AudioTips.clip = ShiGuDiDianGaiKuoClip;
AudioTips.Play();
UI事故地点概况.GetChild(0).GetChild(1).GetChild(0).SetActive(true);
UI事故地点概况.GetChild(0).GetChild(1).GetChild(0).GetComponent<Text>()
.DOText("该煤矿为设计生产能力15万吨 / 年的乡镇生产矿井,2014年2月1日,矿井将井下生产承包给某施工队。该矿17号煤层在 + 1350米标高以上,有突出危险性,属煤与瓦斯突出矿井;", 10)
.SetEase(Ease.Linear);
yield return new WaitForSeconds(10);
UI事故地点概况.GetChild(0).GetChild(1).GetChild(0).GetComponent<Text>().text = "";
UI事故地点概况.GetChild(0).GetChild(1).GetChild(0).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(2).SetActive(true);
yield return new WaitForSeconds(1.5f);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(2).SetActive(true);
yield return new WaitForSeconds(1.5f);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(3).SetActive(true);
yield return new WaitForSeconds(1.5f);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(4).SetActive(true);
yield return new WaitForSeconds(1.5f);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(5).SetActive(true);
yield return new WaitForSeconds(1.5f);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(6).SetActive(true);
yield return new WaitForSeconds(1.5f);
UI事故地点概况.GetChild(0).GetChild(1).GetChild(1).GetComponent<Text>().text = "";
UI事故地点概况.GetChild(0).GetChild(2).GetChild(2).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(3).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(4).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(5).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(2).GetChild(6).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(1).GetChild(1).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(1).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(2).SetActive(false);
UI事故地点概况.GetChild(0).GetChild(0).SetActive(false);
UIWork.SetActive(true);
UIWork.GetChild(0).SetActive(true);
yield return new WaitForSeconds(2f);
UIWork.GetChild(1).SetActive(true);
yield return new WaitForSeconds(2f);
UIWork.GetChild(3).SetActive(true);
UIWork.GetChild(3).GetChild(0).GetComponent<Text>().DOText("从2014年4月起,矿井在未采取任何区域防突措施的情况下在西翼布置2172运输巷和回风巷掘进工作面;并于8月1日在2172运输巷开掘2172下山。", 2).SetEase(Ease.Linear);
UIWork.GetChild(2).SetActive(true);
yield return new WaitForSeconds(2f);
for (int i = 0; i < 4; i++)
{
UIWork.GetChild(i).SetActive(false);
}
UIWork.GetChild(4).SetActive(true);
for (int i = 0; i < WorkPrites.Length; i++)
{
yield return StartCoroutine(setImage(WorkPrites[i], WorkAudioClips[i], clipcTime[i]));
}
UIWork.SetActive(false);
UI事故地点概况.GetChild(0).SetActive(false);
UI事故地点概况.SetActive(false);
跳过事故地点概况 = false;
UITitle.SetActive(true);
UITitle.GetChild(0).GetComponent<Text>().text = "事故经过";
yield return new WaitForSeconds(1);
UI瓦斯突出发生经过.SetActive(true);
UI瓦斯突出发生经过.GetChild(0).GetChild(0).SetActive(true);
UI瓦斯突出发生经过.GetChild(0).GetChild(0).SetActive(false);
UI瓦斯突出发生经过.SetActive(false);
UITitle.SetActive(false);
UITip.SetActive(true);
UITip.GetChild(0).GetComponent<Text>().DOText("10月8日,十时左右,2172下山当班第一次放炮,循环进尺1米左右;", 5).SetEase(Ease.Linear);
AudioTips.clip = insert1Clip;
AudioTips.Play();
UITip.GetChild(0).GetComponent<Text>().text = "";
UITip.SetActive(false);
WaSiTuChuTimeLine.Play();
yield return new WaitForSeconds(1.5f);
详情分析.SetActive(true);
详情分析.GetChild(1).SetActive(false);
}
IEnumerator setImage(Sprite s, AudioClip a, float time) {
UIWork.GetChild(4).GetComponent<Image>().sprite = s;
AudioTips.clip = a;
AudioTips.Play();
yield return new WaitForSeconds(time);
}
IEnumerator JuQing(String s, AudioClip a, float time)
{
UITip.SetActive(true);
UITip.GetChild(0).GetComponent<Text>().DOText(s, time).SetEase(Ease.Linear);
AudioTips.clip = a;
AudioTips.Play();
yield return new WaitForSeconds(time);
UITip.GetChild(0).GetComponent<Text>().text = "";
UITip.SetActive(false);
}
async void CardAction()
{
CardManager.Instance.CardStatue(true);
await CardManager.Instance.AddEndAction(8);
Debug.LogError("卡片收集完成");
CardManager.Instance.CardStatue(false);
虫洞.SetActive(true);
AudioTips.clip = AudioClips.出现虫洞;
AudioTips.Play();
AudioBgs.clip = AudioClips.虫洞开启;
AudioBgs.Play();
}
IEnumerator 跳过事故概况()
{
AudioTips.Stop();
UI事故地点概况.GetChild(0).GetChild(1).GetChild(1).GetComponent<Text>().text = "";
UI事故地点概况.SetActive(false);
标题提示("事故经过");
String str = "10月8日,十时左右,2172下山当班第一次放炮,循环进尺1米左右;";
yield return StartCoroutine(JuQing(str, insert3Clip, 5));
WaSiTuChuTimeLine.Play();
}
IEnumerator 标题提示(String str)
{
UITitle.SetActive(true);
UITitle.GetChild(0).GetComponent<Text>().text = str;
yield return new WaitForSeconds(2);
UITitle.GetChild(0).GetComponent<Image>().DOColor(new Color(0, 0, 0, 0), 2);
UITitle.GetChild(0).GetComponent<Text>().DOColor(new Color(0, 0, 0, 0), 2);
yield return new WaitForSeconds(2);
UITitle.GetChild(0).GetComponent<Image>().DOColor(new Color(0, 0, 0, 1), 0);
UITitle.GetChild(0).GetComponent<Text>().DOColor(new Color(1, 1, 1, 1), 0);
UITitle.SetActive(false);
}
public override void RayImage(Transform t)
{
if (t.GetComponent<Image>())
t.GetComponent<Image>().color = Color.yellow;
if (Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.TRIGGER) || Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.TRIGGER) || Controller.UPvr_GetKeyUp(0, Pvr_KeyCode.TOUCHPAD) || Controller.UPvr_GetKeyUp(1, Pvr_KeyCode.TOUCHPAD) || Input.GetKeyUp(KeyCode.Space))
{
if (t.name == "jieshao")
{
详情分析.GetChild(0).SetActive(false);
}
if (t.name == "zhijieyuanyin")
{
StartCoroutine(收集());
详情分析.GetChild(2).SetActive(true);
}
if (t.parent.GetComponent<CardManager>())
{
t.GetComponent<CardBase>().OnClick();
}
if (t.name == "虫洞")
{
t.GetComponent<Collider>().enabled = false;
点击虫洞();
}
}
}
IEnumerator 收集()
{
UIYuanYin.GetChild(1).SetActive(true);
yield return new WaitForSeconds(1);
UIYuanYin.SetActive(false);
CardAction();
}
async void 点击虫洞()
{
AudioTips.Stop();
AudioBgs.clip = AudioClips.穿越虫洞;
AudioBgs.Play();
Player.transform.LookAt(虫洞.transform);
while (Vector3.Distance(Player.transform.position, 虫洞.transform.position) > 0.1f)
{
Player.transform.Translate(Vector3.forward * Time.deltaTime * 1);
await new WaitForUpdate();
}
Debug.LogError("移动结束");
虫洞.SetActive(false);
Env.Foreach(_ => _.SetActive(false));
穿越.SetActive(true);
await Task.Delay(6000);
Debug.LogError("穿越虫洞结束");
Env.Foreach(_ => _.SetActive(true));
穿越.SetActive(false);
AudioBgs.Stop();
WaSiTuChuTimeLine.Play();
}
public override void RayImageUp(Transform t)
{
if (t.GetComponent<Image>())
t.GetComponent<Image>().color = Color.white;
}
}