private void RentRoom() { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; int mapId = GameManager.Instance.PlayerGPS.CurrentLocation.MapTableData.MapId; string sceneName = DaggerfallInterior.GetSceneName(mapId, buildingData.buildingKey); if (rentedRoom == null) { // Get rest markers and select a random marker index for allocated bed // We store marker by index as building positions are not stable, they can move from terrain mods or floating Y Vector3[] restMarkers = playerEnterExit.Interior.FindMarkers(DaggerfallInterior.InteriorMarkerTypes.Rest); int markerIndex = Random.Range(0, restMarkers.Length); // Create room rental and add it to player rooms RoomRental_v1 room = new RoomRental_v1() { name = buildingData.displayName, mapID = mapId, buildingKey = buildingData.buildingKey, allocatedBedIndex = markerIndex, expiryTime = DaggerfallUnity.Instance.WorldTime.Now.ToSeconds() + (ulong)(DaggerfallDateTime.SecondsPerDay * daysToRent) }; playerEntity.RentedRooms.Add(room); SaveLoadManager.StateManager.AddPermanentScene(sceneName); Debug.LogFormat("Rented room for {1} days. {0}", sceneName, daysToRent); } else { rentedRoom.expiryTime += (ulong)(DaggerfallDateTime.SecondsPerDay * daysToRent); Debug.LogFormat("Rented room for additional {1} days. {0}", sceneName, daysToRent); } }
void TryPlacement() { PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; // The "send" variant is only used when player within a town/exterior location // The placement will remain pending until player matches conditions if (isSendAction) { if (!GameManager.Instance.PlayerGPS.IsPlayerInLocationRect) { return; } } // Place in world near player depending on local area if (playerEnterExit.IsPlayerInsideBuilding) { PlaceFoeBuildingInterior(pendingFoeGameObjects, playerEnterExit.Interior); } else if (playerEnterExit.IsPlayerInsideDungeon) { PlaceFoeDungeonInterior(pendingFoeGameObjects, playerEnterExit.Dungeon); } else if (!playerEnterExit.IsPlayerInside && GameManager.Instance.PlayerGPS.IsPlayerInLocationRect) { PlaceFoeExteriorLocation(pendingFoeGameObjects, GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject); } else { PlaceFoeWilderness(pendingFoeGameObjects); } }
/// <summary> /// Transition player up or down a ladder. /// </summary> public void ClimbLadder() { // Player must be inside a building PlayerMotor playerMotor = GameManager.Instance.PlayerMotor; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; if (!playerEnterExit.IsPlayerInsideBuilding) { return; } // Get bottom marker Vector3 bottomMarker; bool foundBottom = playerEnterExit.Interior.FindClosestMarker(out bottomMarker, DaggerfallInterior.InteriorMarkerTypes.LadderBottom, playerMotor.transform.position); // Get top marker Vector3 topMarker; bool foundTop = playerEnterExit.Interior.FindClosestMarker(out topMarker, DaggerfallInterior.InteriorMarkerTypes.LadderTop, playerMotor.transform.position); // Teleport to top marker if (foundTop && playerMotor.transform.position.y < topMarker.y) { playerMotor.transform.position = topMarker; playerMotor.FixStanding(); } else if (foundBottom && playerMotor.transform.position.y > bottomMarker.y) { playerMotor.transform.position = bottomMarker; playerMotor.FixStanding(); } }
/// <summary> /// Check if player at specific town exterior. /// This includes the exterior RMB area of dungeons in world. /// </summary> bool CheckInsideTown(Place place) { // Get component handling player world status and transitions PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; if (!playerEnterExit) { return(false); } // Player must be outside if (playerEnterExit.IsPlayerInside) { return(false); } // Compare mapId of site and current location DFLocation location = GameManager.Instance.PlayerGPS.CurrentLocation; if (location.Loaded && GameManager.Instance.PlayerGPS.IsPlayerInLocationRect) { if (location.MapTableData.MapId == place.SiteDetails.mapId) { return(true); } } return(false); }
/// <summary> /// Check if player inside a specific target site building. /// </summary> bool CheckInsideBuilding(Place place) { // Get component handling player world status and transitions PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; if (!playerEnterExit) { return(false); } // Check if player inside the building matching this site if (playerEnterExit.IsPlayerInside && playerEnterExit.IsPlayerInsideBuilding) { // Must have at least one exterior door for building check StaticDoor[] exteriorDoors = playerEnterExit.ExteriorDoors; if (exteriorDoors == null || exteriorDoors.Length < 1) { throw new Exception("CheckInsideBuilding() could not get at least 1 exterior door from playerEnterExit.ExteriorDoors."); } // Check if building IDs match both site and any exterior door of this building if (exteriorDoors[0].buildingKey == place.SiteDetails.buildingKey) { return(true); } } return(false); }
void Awake() { // Get player objects player = FindPlayer(); playerEnterExit = FindPlayerEnterExit(player); playerHealth = FindPlayerHealth(player); }
protected virtual void Start() { // Store references dfUnity = DaggerfallUnity.Instance; dfAudioSource = GetComponent <DaggerfallAudioSource>(); playerEnterExit = GetComponent <PlayerEnterExit>(); transportManager = GetComponent <TransportManager>(); entityBehaviour = GetComponent <DaggerfallEntityBehaviour>(); GameObject audioSourceObject = new GameObject("Footsteps Source"); audioSourceObject.transform.SetParent(transform); audioSourceObject.transform.localPosition = Vector3.zero; customAudioSource = audioSourceObject.AddComponent <AudioSource>(); customAudioSource.playOnAwake = false; customAudioSource.loop = false; customAudioSource.dopplerLevel = 0f; customAudioSource.spatialBlend = 1; // Set start position lastPosition = GetHorizontalPosition(); // Set starting footsteps currentFootstepSoundList = FootstepSoundDungeon; }
void Awake() { playerEnterExit = GetComponent <PlayerEnterExit>(); if (!playerEnterExit) { throw new Exception("PlayerEnterExit not found."); } playerCamera = GetComponentInChildren <Camera>(); if (!playerCamera) { throw new Exception("Player Camera not found."); } playerMouseLook = playerCamera.GetComponent <PlayerMouseLook>(); if (!playerMouseLook) { throw new Exception("PlayerMouseLook not found."); } playerMotor = GetComponent <PlayerMotor>(); if (!playerMotor) { throw new Exception("PlayerMotor not found."); } playerEntityBehaviour = GetComponent <DaggerfallEntityBehaviour>(); if (!playerEntityBehaviour) { throw new Exception("PlayerEntityBehaviour not found."); } SaveLoadManager.RegisterSerializableGameObject(this); }
private void RentRoom() { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; int mapId = GameManager.Instance.PlayerGPS.CurrentLocation.MapTableData.MapId; string sceneName = DaggerfallInterior.GetSceneName(mapId, buildingData.buildingKey); if (rentedRoom == null) { // Get rest marker Vector3 restMarker; playerEnterExit.Interior.FindMarker(out restMarker, DaggerfallInterior.InteriorMarkerTypes.Rest, true); // Create room rental and add it to player rooms RoomRental_v1 room = new RoomRental_v1() { name = buildingData.displayName, mapID = mapId, buildingKey = buildingData.buildingKey, allocatedBed = restMarker, expiryTime = DaggerfallUnity.Instance.WorldTime.Now.ToSeconds() + (ulong)(DaggerfallDateTime.SecondsPerDay * daysToRent) }; playerEntity.RentedRooms.Add(room); SaveLoadManager.StateManager.AddPermanentScene(sceneName); Debug.LogFormat("Rented room for {1} days. {0}", sceneName, daysToRent); } else { rentedRoom.expiryTime += (ulong)(DaggerfallDateTime.SecondsPerDay * daysToRent); Debug.LogFormat("Rented room for additional {1} days. {0}", sceneName, daysToRent); } }
protected void SetupShopGoldInfoText() { PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; int currentBuildingID = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey; LimitedGoldShops.ShopData sd; int goldSupply = 0; uint investedAmount = 0; if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { goldSupply = sd.CurrentGoldSupply; investedAmount = sd.AmountInvested; } if (!(playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.Temple) && !(playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.GuildHall)) { localTextLabelOne = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(263, 34), string.Empty, NativePanel); localTextLabelOne.TextScale = 0.85f; localTextLabelOne.Text = "Invested: " + investedAmount.ToString(); localTextLabelTwo = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(263, 41), string.Empty, NativePanel); localTextLabelTwo.TextScale = 0.85f; localTextLabelTwo.Text = "Shop Gold: " + goldSupply.ToString(); } UpdateShopGoldDisplay(); }
public static string Execute(params string[] args) { PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;//GameObject.FindObjectOfType<PlayerEnterExit>(); if (playerEnterExit == null || !playerEnterExit.IsPlayerInside) { Console.Log(HelpCommand.Execute(TransitionToExterior.name)); return(error); } else { try { if (playerEnterExit.IsPlayerInsideDungeon) { playerEnterExit.TransitionDungeonExterior(); } else { playerEnterExit.TransitionExterior(); } return("Transitioning to exterior"); } catch { return("Error on transitioning"); } } }
private void PlayerEnterExit_OnRespawnerComplete() { // Must have a caster and it must be the player if (caster == null || caster != GameManager.Instance.PlayerEntityBehaviour) { return; } // Get peered SerializablePlayer and PlayerEnterExit SerializablePlayer serializablePlayer = caster.GetComponent <SerializablePlayer>(); PlayerEnterExit playerEnterExit = caster.GetComponent <PlayerEnterExit>(); if (!serializablePlayer || !playerEnterExit) { Debug.LogError("Teleport effect OnRespawnerComplete() could not find both SerializablePlayer and PlayerEnterExit components."); return; } // Restore final position and unwire event serializablePlayer.RestorePosition(anchorPosition); PlayerEnterExit.OnRespawnerComplete -= PlayerEnterExit_OnRespawnerComplete; // Restore scene cache on arrival if (!playerEnterExit.IsPlayerInside) { SaveLoadManager.RestoreCachedScene(GameManager.Instance.StreamingWorld.SceneName); // Player is outside } else if (playerEnterExit.IsPlayerInsideBuilding) { SaveLoadManager.RestoreCachedScene(playerEnterExit.Interior.name); // Player inside a building } }
/// <summary> /// Check if player is allowed to rest at this location. /// </summary> bool CanRest() { remainingHoursRented = -1; allocatedBed = Vector3.zero; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (playerGPS.IsPlayerInTown(true, true)) { CloseWindow(); DaggerfallUI.MessageBox(cityCampingIllegal); // Register crime and start spawning guards playerEntity.CrimeCommitted = PlayerEntity.Crimes.Vagrancy; playerEntity.SpawnCityGuards(true); return(false); } else if (playerGPS.IsPlayerInTown() && playerEnterExit.IsPlayerInsideBuilding) { // Check owned locations string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey); if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName)) { // Can rest if it's an player owned ship/house. int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey; if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey)) { return(true); } // Find room rental record and get remaining time.. int mapId = playerGPS.CurrentLocation.MapTableData.MapId; RoomRental_v1 room = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey); remainingHoursRented = PlayerEntity.GetRemainingHours(room); // Get allocated bed marker - default to 0 if out of range // We relink marker position by index as building positions are not stable, they can move from terrain mods or floating Y Vector3[] restMarkers = playerEnterExit.Interior.FindMarkers(DaggerfallInterior.InteriorMarkerTypes.Rest); int bedIndex = (room.allocatedBedIndex >= 0 && room.allocatedBedIndex < restMarkers.Length) ? room.allocatedBedIndex : 0; allocatedBed = restMarkers[bedIndex]; if (remainingHoursRented > 0) { return(true); } } // Check for guild hall rest privileges (exclude taverns since they are all marked as fighters guilds in data) if (playerEnterExit.BuildingDiscoveryData.buildingType != DFLocation.BuildingTypes.Tavern && GameManager.Instance.GuildManager.GetGuild(playerEnterExit.BuildingDiscoveryData.factionID).CanRest()) { playerEnterExit.Interior.FindMarker(out allocatedBed, DaggerfallInterior.InteriorMarkerTypes.Rest); return(true); } CloseWindow(); DaggerfallUI.MessageBox(HardStrings.haveNotRentedRoom); return(false); } return(true); }
void Awake() { // Get player objects player = FindPlayer(); playerEnterExit = FindPlayerEnterExit(player); // Assign default player equipment & spells allocation methods AssignStartingEquipment = DaggerfallUnity.Instance.ItemHelper.AssignStartingGear; AssignStartingSpells = SetStartingSpells; }
/// <summary> /// Check if player is allowed to rest at this location. /// </summary> bool CanRest() { remainingHoursRented = -1; allocatedBed = Vector3.zero; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; bool inTown = playerGPS.IsPlayerInTown(true); if (inTown && !playerEnterExit.IsPlayerInside) { CloseWindow(); DaggerfallUI.MessageBox(cityCampingIllegal); // Register crime and start spawning guards playerEntity.CrimeCommitted = PlayerEntity.Crimes.Vagrancy; playerEntity.SpawnCityGuards(true); return(false); } else if ((inTown || !playerGPS.HasCurrentLocation) && playerEnterExit.IsPlayerInsideBuilding) { // Check for guild hall rest privileges if (GameManager.Instance.GuildManager.GetGuild(playerEnterExit.BuildingDiscoveryData.factionID).CanRest()) { playerEnterExit.Interior.FindMarker(out allocatedBed, DaggerfallInterior.InteriorMarkerTypes.Rest); return(true); } // Check owned locations string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey); if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName)) { // Can rest if it's an player owned ship/house. int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey; if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey)) { return(true); } // Find room rental record and get remaining time.. int mapId = playerGPS.CurrentLocation.MapTableData.MapId; RoomRental_v1 room = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey); remainingHoursRented = PlayerEntity.GetRemainingHours(room); allocatedBed = room.allocatedBed; if (remainingHoursRented > 0) { return(true); } } CloseWindow(); DaggerfallUI.MessageBox(HardStrings.haveNotRentedRoom); return(false); } return(true); }
PlayerEnterExit FindPlayerEnterExit(GameObject player) { PlayerEnterExit playerEnterExit = player.GetComponent <PlayerEnterExit>(); if (!playerEnterExit) { throw new Exception("Could not find PlayerEnterExit."); } return(playerEnterExit); }
// Cache required references in Start() or Resume() (only one or the other is called) void CacheReferences() { // Get peered SerializablePlayer and PlayerEnterExit serializablePlayer = caster.GetComponent <SerializablePlayer>(); playerEnterExit = caster.GetComponent <PlayerEnterExit>(); if (!serializablePlayer || !playerEnterExit) { Debug.LogError("Teleport effect could not find both SerializablePlayer and PlayerEnterExit components."); return; } }
void Start() { if (playerEnterExit == null) { playerEnterExit = GameManager.Instance.PlayerEnterExit; } if (mainCamera == null) { mainCamera = GameManager.Instance.MainCamera; } }
private void Start() { ModSettings settings = mod.GetSettings(); volume = settings.GetValue <float>("Settings", "Volume"); minDist = settings.GetValue <float>("Settings", "MinVolumeDistance"); maxDist = settings.GetValue <float>("Settings", "MaxVolumeDistance"); playerEnterExit = GameManager.Instance.PlayerEnterExit; SaveLoadManager.OnLoad += (saveData) => { currentLocationName = null; }; StartGameBehaviour.OnNewGame += () => { currentLocationName = null; }; }
private static void OnTransitionToInterior_VariantShopTavernNPCsprites(PlayerEnterExit.TransitionEventArgs args) { PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; DFLocation.BuildingData buildingData = playerEnterExit.Interior.BuildingData; if (buildingData.BuildingType == DFLocation.BuildingTypes.Tavern || RMBLayout.IsShop(buildingData.BuildingType)) { Billboard[] dfBillboards = playerEnterExit.Interior.GetComponentsInChildren <Billboard>(); foreach (Billboard billboard in dfBillboards) { int record = -1; if (billboard.Summary.Archive == 182 && billboard.Summary.Record == 0) { record = GetRecord_182_0(buildingData.Quality); // (buildingData.Quality - 1) / 4; #if UNITY_EDITOR Debug.LogFormat("Shop quality {0} using record {1} to replace 182_0", buildingData.Quality, record); #endif } else if (billboard.Summary.Archive == 182 && billboard.Summary.Record == 1) { if (buildingData.Quality < 12) { // Using big test flats version record = 4; } else if (buildingData.Quality > 14) { record = 5; } #if UNITY_EDITOR Debug.LogFormat("Tavern quality {0} using record {1} to replace 182_1", buildingData.Quality, record); #endif } else if (billboard.Summary.Archive == 182 && billboard.Summary.Record == 2) { if (buildingData.Quality > 12) { record = 6; } #if UNITY_EDITOR Debug.LogFormat("Tavern quality {0} using record {1} to replace 182_2", buildingData.Quality, record); #endif } if (record > -1) { billboard.SetMaterial(197, record); GameObjectHelper.AlignBillboardToGround(billboard.gameObject, billboard.Summary.Size); } } } }
private bool GetRefrences() { try { if (!_cloudGen) { _cloudGen = this.GetComponent <CloudGenerator>(); } if (!_cloudGen) { _cloudGen = this.gameObject.AddComponent <CloudGenerator>(); } if (!dfallSky) { dfallSky = GameManager.Instance.SkyRig.gameObject; } if (!playerEE) { playerEE = GameManager.Instance.PlayerEnterExit; } if (!exteriorParent) { exteriorParent = GameManager.Instance.ExteriorParent; } if (!weatherMan) { weatherMan = GameManager.Instance.WeatherManager; } if (!postProcessingBehaviour) { postProcessingBehaviour = Camera.main.GetComponent <PostProcessingBehaviour>(); } } catch { DaggerfallUnity.LogMessage("Error in SkyManager.GetRefrences()", true); return(false); } if (dfallSky && playerEE && exteriorParent && weatherMan && _cloudGen && StarMaskMat && _skyObjMat && StarsMat && SkyMat) { return(true); } else { return(false); } }
void Start() { if (playerEnterExit == null) { playerEnterExit = GameManager.Instance.PlayerEnterExit; } if (mainCamera == null) { mainCamera = GameManager.Instance.MainCamera; } //if (mainCamera != null) //{ // globalFog = mainCamera.GetComponent<GlobalFog>(); //} }
void Start() { if (playerEnterExit == null) { playerEnterExit = GameManager.Instance.PlayerEnterExit; } if (mainCamera == null) { mainCamera = GameManager.Instance.MainCamera; } retroModeEnabled = DaggerfallUnity.Settings.RetroRenderingMode > 0; if (retroModeEnabled) { mainCamera.clearFlags = CameraClearFlags.Depth; } }
public static void UpdateInvestAmount(int investOffer = 0) // This is responsible for updating investment data in the save-data for a building etc. { uint investedOffer = Convert.ToUInt32(investOffer); ulong creationTime = 0; int buildingQuality = 0; bool investedIn = false; uint amountInvested = 0; int shopAttitude = 0; int buildingKey = 0; int currentGoldSupply = 0; int currentBuildingID = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; ShopData sd; if (ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { buildingKey = currentBuildingID; creationTime = sd.CreationTime; investedIn = sd.InvestedIn; amountInvested = sd.AmountInvested; shopAttitude = sd.ShopAttitude; buildingQuality = sd.BuildingQuality; currentGoldSupply = sd.CurrentGoldSupply; } //Debug.LogFormat("Offered Investment Amount = {0}", investedOffer); investedIn = true; amountInvested = sd.AmountInvested + investedOffer; ShopBuildingData.Remove(buildingKey); ShopData currentBuildKey = new ShopData { CreationTime = creationTime, InvestedIn = investedIn, AmountInvested = amountInvested, ShopAttitude = shopAttitude, BuildingQuality = buildingQuality, CurrentGoldSupply = currentGoldSupply }; ShopBuildingData.Add(buildingKey, currentBuildKey); //Debug.LogFormat("Total Investment Amount After This Addition = {0}", amountInvested); }
/// <summary> /// Check if player is allowed to rest at this location. /// </summary> bool CanRest() { remainingHoursRented = -1; allocatedBed = Vector3.zero; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; bool inTown = playerGPS.IsPlayerInTown(true); if (inTown && !playerEnterExit.IsPlayerInside) { CloseWindow(); DaggerfallUI.MessageBox(cityCampingIllegal); return(false); } else if ((inTown || !playerGPS.HasCurrentLocation) && playerEnterExit.IsPlayerInsideBuilding) { string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey); if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName)) { // Can rest if it's an player owned ship/house. int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey; if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey)) { return(true); } // Find room rental record and get remaining time.. int mapId = playerGPS.CurrentLocation.MapTableData.MapId; RoomRental_v1 room = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey); remainingHoursRented = PlayerEntity.GetRemainingHours(room); allocatedBed = room.allocatedBed; if (remainingHoursRented > 0) { return(true); } } CloseWindow(); DaggerfallUI.MessageBox(HardStrings.haveNotRentedRoom); return(false); } return(true); }
/// <summary> /// Update NPC presence for shops and guilds after resting/idling. /// </summary> public void UpdateNpcPresence() { PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; DFLocation.BuildingTypes buildingType = playerEnterExit.BuildingType; if ((RMBLayout.IsShop(buildingType) && !playerEnterExit.IsPlayerInsideOpenShop) || (!RMBLayout.IsShop(buildingType) && buildingType <= DFLocation.BuildingTypes.Palace && buildingType != DFLocation.BuildingTypes.HouseForSale)) { Transform npcTransforms = transform.Find(peopleFlats); if (PlayerActivate.IsBuildingOpen(buildingType)) { foreach (Transform npcTransform in npcTransforms) { npcTransform.gameObject.SetActive(true); } Debug.Log("Updated npcs to be present."); } } }
private void ConfirmRenting_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { CloseWindow(); if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; if (playerEntity.GetGoldAmount() >= tradePrice) { playerEntity.DeductGoldAmount(tradePrice); int mapId = GameManager.Instance.PlayerGPS.CurrentLocation.MapTableData.MapId; string sceneName = DaggerfallInterior.GetSceneName(mapId, buildingData.buildingKey); if (rentedRoom == null) { // Get rest marker Vector3 restMarker; playerEnterExit.Interior.FindMarker(out restMarker, DaggerfallInterior.InteriorMarkerTypes.Rest, true); // Create room rental and add it to player rooms RoomRental_v1 room = new RoomRental_v1() { name = buildingData.displayName, mapID = mapId, buildingKey = buildingData.buildingKey, allocatedBed = restMarker, expiryTime = DaggerfallUnity.Instance.WorldTime.Now.ToSeconds() + (ulong)(DaggerfallDateTime.SecondsPerDay * daysToRent) }; playerEntity.RentedRooms.Add(room); SaveLoadManager.StateManager.AddPermanentScene(sceneName); Debug.LogFormat("Rented room for {1} days. {0}", sceneName, daysToRent); } else { rentedRoom.expiryTime += (ulong)(DaggerfallDateTime.SecondsPerDay * daysToRent); Debug.LogFormat("Rented room for additional {1} days. {0}", sceneName, daysToRent); } } else { DaggerfallUI.MessageBox(notEnoughGoldId); } } }
private void YesButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { DaggerfallUI.Instance.FadeBehaviour.SmashHUDToBlack(); // Teleport to destination. PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; if (playerEnterExit.IsPlayerInside) { playerEnterExit.TransitionExterior(); } GameManager.Instance.StreamingWorld.TeleportToCoordinates((int)destinationPos.X, (int)destinationPos.Y, StreamingWorld.RepositionMethods.RandomStartMarker); // Close windows. DaggerfallUI.Instance.UserInterfaceManager.PopWindow(); travelWindow.CloseTravelWindows(); CloseWindow(); DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack(); }
public static string Execute(params string[] args) { int x = 0; int y = 0; DaggerfallWorkshop.StreamingWorld streamingWorld = GameManager.Instance.StreamingWorld; //GameObject.FindObjectOfType<DaggerfallWorkshop.StreamingWorld>(); PlayerEnterExit playerEE = GameManager.Instance.PlayerEnterExit; //GameObject.FindObjectOfType<PlayerEnterExit>(); if (args == null || args.Length < 2) { return(HelpCommand.Execute(TeleportToMapPixel.name)); } else if (streamingWorld == null) { return("Could not locate Streaming world object"); } else if (playerEE == null || playerEE.IsPlayerInside) { return("PlayerEnterExit could not be found or player inside"); } else if (int.TryParse(args[0], out x) && int.TryParse(args[1], out y)) { if (x <= 0 || y <= 0) { return("Invalid Coordinates"); } else if (x >= MapsFile.MaxMapPixelX || y >= MapsFile.MaxMapPixelY) { return("Invalid coordiantes"); } else { streamingWorld.TeleportToCoordinates(x, y); } return(string.Format("Teleporting player to: {0} {1}", x, y)); } return("Invalid coordiantes"); }
// Cache required references bool CacheReferences() { // Get peered SerializablePlayer and PlayerEnterExit if (!serializablePlayer) { serializablePlayer = caster.GetComponent <SerializablePlayer>(); } if (!playerEnterExit) { playerEnterExit = caster.GetComponent <PlayerEnterExit>(); } if (!serializablePlayer || !playerEnterExit) { Debug.LogError("Teleport effect could not find both SerializablePlayer and PlayerEnterExit components."); return(false); } return(true); }
void Awake() { playerEnterExit = GetComponent<PlayerEnterExit>(); if (!playerEnterExit) throw new Exception("PlayerEnterExit not found."); playerCamera = GetComponentInChildren<Camera>(); if (!playerCamera) throw new Exception("Player Camera not found."); playerMouseLook = playerCamera.GetComponent<PlayerMouseLook>(); if (!playerMouseLook) throw new Exception("PlayerMouseLook not found."); playerMotor = GetComponent<PlayerMotor>(); if (!playerMotor) throw new Exception("PlayerMotor not found."); playerEntityBehaviour = GetComponent<DaggerfallEntityBehaviour>(); if (!playerEntityBehaviour) throw new Exception("PlayerEntityBehaviour not found."); SaveLoadManager.RegisterSerializableGameObject(this); }