// 切换世界 public void SwitchWorld(Loop.WorldName targetWorld) { Debug.Log("-- Func : Observer.SwitchWorld --"); _currentPlayer.DisableInput(); StartCoroutine(WaitAndSwitchWorld(targetWorld, Loop.WorldConstants.TIME_BEFORE_SWITCH)); }
// 角色转移到特定名字的世界 public void MoveToWorld(Loop.WorldName name) { Loop.World sourceWorld = Loop.WorldManager.GetPrevWorld(); Debug.Log("Source WorldPos : " + sourceWorld.WorldPos); Loop.World targetWorld = Loop.WorldManager.GetWorld(name); Debug.Log("Target WorldPos: " + targetWorld.WorldPos); transform.Translate(targetWorld.WorldPos - sourceWorld.WorldPos, Space.World); }
// 等待特定秒数以后开始切换 private IEnumerator WaitAndSwitchWorld(Loop.WorldName targetWorld, float seconds) { Debug.Log("Switch world after " + seconds + " seconds..."); yield return(new WaitForSeconds(seconds)); Loop.WorldManager.SwitchToWorld(targetWorld); _currentPlayer.SwitchToWorld(targetWorld); Loop.CameraManager.SwitchWorldCamera(targetWorld); StartCoroutine(WaitToInput(Loop.WorldConstants.TIME_AFTER_SWITCH)); }