using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using Sirenix.OdinInspector; using UnityEngine.SceneManagement; using UnityEngine.InputSystem; /// /// 直译转移,控制玩家在关卡间的切换 /// public class Transfer : EntryTrigger { /// /// 对应进度和场景名称 /// [DictionaryDrawerSettings][ShowInInspector][ReadOnly] public static Dictionary proToScene; private MyPlayer player; private Blcak blcakHori; private Blcak blcakVert; public Blcak.Type transType; void Start(){ proToScene = new Dictionary(); //将场景连成线 proToScene.Add(MyPlayer.Progress.刚开,"Fo"); 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"); //找到必要的游戏物体和组件 player = FindObjectOfType(); } public override void OnCall(){ StartCoroutine(Trans()); } private IEnumerator Trans(){ yield return new WaitForEndOfFrame(); //找到转场块 blcakHori = GameObject.Find("转场块(水平").GetComponent(); blcakVert = GameObject.Find("转场块(竖直").GetComponent(); //关闭操作地图 player.GetComponent().SwitchCurrentActionMap("NullMap"); //令玩家一直向右移动 if(!player.isDead) player.inputDir = 1; //呼出黑块 if(transType == Blcak.Type.水平) blcakHori.OnCall(transType); if(transType == Blcak.Type.竖直) blcakVert.OnCall(transType); //等待黑幕转到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]); } }