public void PositionPlayerAtLocationEntrance() { DFPosition mapPixel = GameManager.Instance.PlayerGPS.CurrentMapPixel; ContentReader.MapSummary mapSummary; if (DaggerfallUnity.Instance.ContentReader.HasLocation(mapPixel.X, mapPixel.Y, out mapSummary)) { StreamingWorld world = GameManager.Instance.StreamingWorld; StreamingWorld.RepositionMethods reposition = StreamingWorld.RepositionMethods.None; reposition = StreamingWorld.RepositionMethods.RandomStartMarker; world.TeleportToCoordinates(mapPixel.X, mapPixel.Y, reposition); } }
private void UpdateMode(TransportModes transportMode) { // Update the transport mode and stop any riding sounds playing. mode = transportMode; if (ridingAudioSource.isPlaying) { ridingAudioSource.Stop(); } if (mode == TransportModes.Horse || mode == TransportModes.Cart) { // Tell player motor we're riding. playerMotor.IsRiding = true; // Setup appropriate riding sounds. SoundClips sound = (mode == TransportModes.Horse) ? horseRidingSound2 : cartRidingSound; ridingAudioSource.clip = dfAudioSource.GetAudioClip((int)sound); // Setup appropriate riding textures. string textureName = (mode == TransportModes.Horse) ? horseTextureName : cartTextureName; for (int i = 0; i < 4; i++) { ridingTexures[i] = ImageReader.GetImageData(textureName, 0, i, true, true); } ridingTexture = ridingTexures[0]; // Initialise neighing timer. neighTime = Time.time + Random.Range(1, 5); } else { // Tell player motor we're not riding. playerMotor.IsRiding = false; } if (mode == TransportModes.Ship) { GameManager.Instance.PlayerMotor.CancelMovement = true; SerializablePlayer serializablePlayer = GetComponent <SerializablePlayer>(); DaggerfallUI.Instance.FadeBehaviour.SmashHUDToBlack(); StreamingWorld world = GameManager.Instance.StreamingWorld; DFPosition shipCoords = DaggerfallBankManager.GetShipCoords(); // Is there recorded position before boarding and is player on the ship? if (IsOnShip()) { // Check for terrain sampler changes. (so don't fall through floor) StreamingWorld.RepositionMethods reposition = StreamingWorld.RepositionMethods.None; if (boardShipPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() || boardShipPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version) { reposition = StreamingWorld.RepositionMethods.RandomStartMarker; if (DaggerfallUI.Instance.DaggerfallHUD != null) { DaggerfallUI.Instance.DaggerfallHUD.PopupText.AddText("Terrain sampler changed. Repositioning player."); } } // Restore player position from before boarding ship, caching ship scene first. SaveLoadManager.CacheScene(world.SceneName); // TODO: Should this should move into teleport to support other teleports? Issue only if inside. (e.g. recall) DFPosition mapPixel = MapsFile.WorldCoordToMapPixel(boardShipPosition.worldPosX, boardShipPosition.worldPosZ); world.TeleportToCoordinates(mapPixel.X, mapPixel.Y, reposition); serializablePlayer.RestorePosition(boardShipPosition); boardShipPosition = null; // Restore cached scene (ship is special case, cache will not be cleared) SaveLoadManager.RestoreCachedScene(world.SceneName); } else { // Record current player position before boarding ship, and cache scene. (ship is special case, cache will not be cleared) boardShipPosition = serializablePlayer.GetPlayerPositionData(); SaveLoadManager.CacheScene(world.SceneName); // Teleport to the players ship, restoring cached scene. world.TeleportToCoordinates(shipCoords.X, shipCoords.Y, StreamingWorld.RepositionMethods.RandomStartMarker); SaveLoadManager.RestoreCachedScene(world.SceneName); } DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack(); mode = TransportModes.Foot; } }
private void UpdateMode(TransportModes transportMode) { // Update the transport mode and stop any riding sounds playing. mode = transportMode; if (ridingAudioSource.isPlaying) { ridingAudioSource.Stop(); } if (mode == TransportModes.Horse || mode == TransportModes.Cart) { // Tell player motor we're riding. TODO: Change to event system so other classes can listen for transport changes. playerMotor.IsRiding = true; // Setup appropriate riding sounds. SoundClips sound = (mode == TransportModes.Horse) ? horseRidingSound2 : cartRidingSound; ridingAudioSource.clip = dfAudioSource.GetAudioClip((int)sound); // Setup appropriate riding textures. string textureName = (mode == TransportModes.Horse) ? horseTextureName : cartTextureName; for (int i = 0; i < 4; i++) { ridingTexures[i] = ImageReader.GetImageData(textureName, 0, i, true, true); } ridingTexure = ridingTexures[0]; // Initialise neighing timer. neighTime = Time.time + Random.Range(1, 5); } else { // Tell player motor we're not riding. playerMotor.IsRiding = false; } if (mode == TransportModes.Ship) { GameManager.Instance.PlayerMotor.CancelMovement = true; SerializablePlayer serializablePlayer = GetComponent <SerializablePlayer>(); DaggerfallUI.Instance.SmashHUDToBlack(); // Is player on board ship? if (boardShipPosition != null) { // Check for terrain sampler changes. (so don't fall through floor) StreamingWorld.RepositionMethods reposition = StreamingWorld.RepositionMethods.None; if (boardShipPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() || boardShipPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version) { reposition = StreamingWorld.RepositionMethods.RandomStartMarker; if (DaggerfallUI.Instance.DaggerfallHUD != null) { DaggerfallUI.Instance.DaggerfallHUD.PopupText.AddText("Terrain sampler changed. Repositioning player."); } } // Restore player position from before boarding ship. DFPosition mapPixel = MapsFile.WorldCoordToMapPixel(boardShipPosition.worldPosX, boardShipPosition.worldPosZ); GameManager.Instance.StreamingWorld.TeleportToCoordinates(mapPixel.X, mapPixel.Y, reposition); serializablePlayer.RestorePosition(boardShipPosition); boardShipPosition = null; } else { // Record current player position before boarding ship. boardShipPosition = serializablePlayer.GetPlayerPositionData(); // Teleport to ship GameManager.Instance.StreamingWorld.TeleportToCoordinates(2, 2, StreamingWorld.RepositionMethods.RandomStartMarker); } DaggerfallUI.Instance.FadeHUDFromBlack(); mode = TransportModes.Foot; } }