61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using DG.Tweening;
|
|
|
|
/// <summary>
|
|
/// 圣火点燃开始游戏的流程管理
|
|
/// </summary>
|
|
public class FireController : MonoBehaviour
|
|
{
|
|
private void OnTriggerEnter2D(Collider2D other) {
|
|
if(other.TryGetComponent<Person>(out var person)) {
|
|
//当人进入点燃圣火触发器
|
|
StartCoroutine(LightFireCoroutine());
|
|
}
|
|
}
|
|
public Transform target;
|
|
private IEnumerator LightFireCoroutine(){
|
|
//把马的刚体速度建为0
|
|
FindObjectOfType<Horse>().GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
|
//切断输入
|
|
Player.Instance.ToNullMap();
|
|
//渐渐显示火把
|
|
SpriteRenderer fire = GameObject.Find("火炬(不可改名)").GetComponent<SpriteRenderer>();
|
|
fire.DOFade(1,2);
|
|
yield return new WaitForSeconds(2);
|
|
|
|
//此时人手中火炬显示
|
|
|
|
//点燃引线
|
|
GameObject fireLine = GameObject.Find("Scene").transform.Find("燃烧的引线").gameObject;
|
|
fireLine.SetActive(true);
|
|
fireLine.GetComponent<ParticleSystem>().Play();
|
|
//播放音效
|
|
GetComponent<AudioSource>().Play();
|
|
GameObject.Find("点").SetActive(false);
|
|
|
|
//等待一段时间
|
|
yield return new WaitForSeconds(1.5f);
|
|
|
|
//渐显播放标题动画
|
|
SpriteRenderer title = GameObject.Find("标题").GetComponent<SpriteRenderer>();
|
|
title.DOFade(1,2);
|
|
yield return new WaitForSeconds(2);
|
|
//播放圣火粒子
|
|
transform.Find("圣火粒子").GetComponent<ParticleSystem>().Play();
|
|
//此时圣火已点燃,标题已显示
|
|
//等待一秒后,开始转场
|
|
yield return new WaitForSeconds(2.5f);
|
|
//呼出黑块从右向左的动画
|
|
BlackController.Instance.Trans();
|
|
//直到黑幕全黑
|
|
yield return new WaitUntil(() => {return BlackController.Instance.AllBlack;});
|
|
//开始跳转到下一个场景
|
|
SceneManager.LoadScene("0813中期提交");
|
|
//切换BGM
|
|
MusicController.Instance.To(MusicController.Instance.game);
|
|
}
|
|
}
|