2021-12-21 00:45:50 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using DG.Tweening;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine.SceneManagement;
|
2021-12-22 11:17:21 +08:00
|
|
|
using UnityEngine.InputSystem;
|
2021-12-21 00:45:50 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 直译转移,控制玩家在关卡间的切换
|
|
|
|
/// </summary>
|
|
|
|
public class Transfer : EntryTrigger
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 对应进度和场景名称
|
|
|
|
/// </summary>
|
2021-12-22 11:17:21 +08:00
|
|
|
[DictionaryDrawerSettings][ShowInInspector][ReadOnly]
|
2021-12-21 00:45:50 +08:00
|
|
|
public static Dictionary<MyPlayer.Progress, string> proToScene;
|
|
|
|
|
2021-12-22 11:17:21 +08:00
|
|
|
private MyPlayer player;
|
2021-12-23 01:19:03 +08:00
|
|
|
private Blcak blcakHori;
|
|
|
|
private Blcak blcakVert;
|
2021-12-22 11:17:21 +08:00
|
|
|
public Blcak.Type transType;
|
|
|
|
|
2021-12-21 00:45:50 +08:00
|
|
|
void Start(){
|
|
|
|
proToScene = new Dictionary<MyPlayer.Progress, string>();
|
|
|
|
//将场景连成线
|
2021-12-22 11:17:21 +08:00
|
|
|
proToScene.Add(MyPlayer.Progress.刚开,"Fo");
|
2021-12-21 00:45:50 +08:00
|
|
|
proToScene.Add(MyPlayer.Progress.通Fo,"DiZangStageTest");
|
|
|
|
proToScene.Add(MyPlayer.Progress.通佛,"cun");
|
|
|
|
proToScene.Add(MyPlayer.Progress.过佛,"Yi");
|
|
|
|
proToScene.Add(MyPlayer.Progress.通Yi,"TeLuoYiStageTest");
|
|
|
|
proToScene.Add(MyPlayer.Progress.通伊,"cun");
|
|
|
|
proToScene.Add(MyPlayer.Progress.过伊,"Ji");
|
|
|
|
proToScene.Add(MyPlayer.Progress.通Ji,"YiSaStageTest");
|
|
|
|
proToScene.Add(MyPlayer.Progress.通基,"cun");
|
|
|
|
proToScene.Add(MyPlayer.Progress.过基,"cun");
|
2021-12-22 11:17:21 +08:00
|
|
|
//找到必要的游戏物体和组件
|
|
|
|
player = FindObjectOfType<MyPlayer>();
|
2021-12-21 00:45:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnCall(){
|
2021-12-23 01:19:03 +08:00
|
|
|
StartCoroutine(Trans());
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerator Trans(){
|
|
|
|
yield return new WaitForEndOfFrame();
|
|
|
|
//找到转场块
|
|
|
|
blcakHori = GameObject.Find("转场块(水平").GetComponent<Blcak>();
|
|
|
|
blcakVert = GameObject.Find("转场块(竖直").GetComponent<Blcak>();
|
2021-12-22 11:17:21 +08:00
|
|
|
//关闭操作地图
|
|
|
|
player.GetComponent<PlayerInput>().SwitchCurrentActionMap("NullMap");
|
|
|
|
//令玩家一直向右移动
|
2021-12-23 01:19:03 +08:00
|
|
|
if(!player.isDead) player.inputDir = 1;
|
2021-12-22 11:17:21 +08:00
|
|
|
//呼出黑块
|
|
|
|
if(transType == Blcak.Type.水平) blcakHori.OnCall(transType);
|
|
|
|
if(transType == Blcak.Type.竖直) blcakVert.OnCall(transType);
|
2021-12-23 01:19:03 +08:00
|
|
|
//等待黑幕转到all状态,转移到下一个场景
|
|
|
|
yield return new WaitUntil(
|
|
|
|
() => {
|
|
|
|
if(transType == Blcak.Type.水平){
|
|
|
|
return (blcakHori.state == Blcak.State.全);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return (blcakVert.state == Blcak.State.全);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
SceneManager.LoadScene(proToScene[MyPlayer.progress]);
|
2021-12-21 00:45:50 +08:00
|
|
|
}
|
|
|
|
}
|