/// <summary> /// Teleport player to referenced teleporter position in MVMain.Room.spawnFrom /// </summary> /// <param name="transitionMode">transition movement</param> private void SpawnPlayer(TeleporterData.TeleporterType transitionMode) { WorldTile spawnTile = teleporter.FirstOrDefault(x => x.name == MVMain.Room.spawnFrom); if (spawnTile == null) { return; } Vector3 oldPlayerPos = playerPlayer.GetPosition(); Vector3 newPlayerPos = Vector3.zero; switch (transitionMode) { case TeleporterData.TeleporterType.Vertical: newPlayerPos = new Vector3(oldPlayerPos.x, spawnTile.worldLocation.y, spawnTile.worldLocation.z); break; case TeleporterData.TeleporterType.Horizontal: newPlayerPos = new Vector3(spawnTile.worldLocation.x, oldPlayerPos.y, spawnTile.worldLocation.z); break; case TeleporterData.TeleporterType.Direct: newPlayerPos = spawnTile.worldLocation; break; } playerPosDelta = newPlayerPos - oldPlayerPos; playerPlayer.SetPosition(newPlayerPos); UpdatePlayerChunk(); }
/// <summary> /// Load room referenced by MVMain.Room.activeroomData /// </summary> /// <param name="transitionMode">transition movement</param> public void LoadRoom(TeleporterData.TeleporterType transitionMode) { if (!testMode) { room = Instantiate <GameObject>(MVMain.Room.activeRoomData.Room, Vector3.zero, Quaternion.identity); room.name = MVMain.Room.activeRoomData.name; } else { room = testRoom; } grid = room.GetComponentInChildren <Grid>(); MVMain.Room.activeRoomData.GetRoomTiles(out tiles, out teleporter); if (!testMode) { SpawnPlayer(transitionMode); } SetCamera(); MVMain.World.RevealChunk(MVMain.Room.activeRoomName, playerLocalChunkPos); MVMain.Music.Play(MVMain.Room.activeRoomData.BGM_Name); }