/// <summary>True when there's a recorded position before boarding and player is on the ship</summary> public bool IsOnShip() { StreamingWorld world = GameManager.Instance.StreamingWorld; DFPosition shipCoords = DaggerfallBankManager.GetShipCoords(); return(boardShipPosition != null && shipCoords != null && world.MapPixelX == shipCoords.X && world.MapPixelY == shipCoords.Y); }
public void ReceiveHouse(PlayerEntity playerEntity) { if (rank < 9) { DaggerfallUI.MessageBox(NoHouseId); } else if ((flags & HouseFlagMask) > 0) { DaggerfallUI.MessageBox(HardStrings.serviceReceiveHouseAlready); } else { // Give a house if one availiable if (DaggerfallBankManager.OwnsHouse) { DaggerfallUI.MessageBox((int)TransactionResult.ALREADY_OWN_HOUSE); } else { BuildingDirectory buildingDirectory = GameManager.Instance.StreamingWorld.GetCurrentBuildingDirectory(); if (buildingDirectory) { List <BuildingSummary> housesForSale = buildingDirectory.GetHousesForSale(); if (housesForSale.Count > 0) { BuildingSummary house = housesForSale[UnityEngine.Random.Range(0, housesForSale.Count)]; DaggerfallBankManager.AllocateHouseToPlayer(house, GameManager.Instance.PlayerGPS.CurrentRegionIndex); flags = flags | HouseFlagMask; DaggerfallUI.MessageBox(HouseId); return; } } DaggerfallUI.MessageBox((int)TransactionResult.NO_HOUSES_FOR_SALE); } } }
void SellShipButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (DaggerfallBankManager.OwnsShip) { GeneratePopup(TransactionResult.SELL_SHIP_OFFER, DaggerfallBankManager.GetShipSellPrice(DaggerfallBankManager.OwnedShip)); } }
private static void OverdueLoan(int regionIndex) { // Try to repay the loan off player's account int transferAmount = (int)Math.Min(DaggerfallBankManager.GetLoanedTotal(regionIndex), DaggerfallBankManager.GetAccountTotal(regionIndex)); DaggerfallBankManager.MakeTransaction(TransactionType.Repaying_loan_from_account, transferAmount, regionIndex); if (!DaggerfallBankManager.HasLoan(regionIndex)) { return; } // Only apply reputation drop once if (DaggerfallBankManager.HasDefaulted(regionIndex)) { return; } // Set hasDefaulted flag (Note: Does not seem to ever be set in classic) DaggerfallBankManager.SetDefaulted(regionIndex, true); PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; // Should that be weighted by the amount? playerEntity.LowerRepForCrime(regionIndex, PlayerEntity.Crimes.LoanDefault); }
/// <summary> /// Gets discovered building data for current location. /// </summary> /// <param name="buildingKey">Building key in current location.</param> /// <param name="discoveredBuildingOut">Building discovery data out.</param> /// <returns>True if building discovered, false if building not discovered.</returns> public bool GetDiscoveredBuilding(int buildingKey, out DiscoveredBuilding discoveredBuildingOut) { discoveredBuildingOut = new DiscoveredBuilding(); // Must have discovered building if (!HasDiscoveredBuilding(buildingKey)) { return(false); } // Get the location discovery for this mapID int mapPixelID = MapsFile.GetMapPixelIDFromLongitudeLatitude((int)CurrentLocation.MapTableData.Longitude, CurrentLocation.MapTableData.Latitude); DiscoveredLocation dl = discoveredLocations[mapPixelID]; if (dl.discoveredBuildings == null) { return(false); } // Get discovery data for building discoveredBuildingOut = dl.discoveredBuildings[buildingKey]; // Check if name should be overridden (owned house / quest site) PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; if (DaggerfallBankManager.IsHouseOwned(buildingKey)) { discoveredBuildingOut.displayName = HardStrings.playerResidence.Replace("%s", playerEntity.Name); } return(true); }
void UpdateLabels() { inventoryAmount.Text = playerEntity.GetGoldAmount().ToString(); accountAmount.Text = DaggerfallBankManager.GetAccountTotal(regionIndex).ToString(); loanAmountDue.Text = DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString(); loanDueBy.Text = DaggerfallBankManager.GetLoanDueDateString(regionIndex); }
void Update() { // Do nothing if not ready if (!ReadyCheck()) { return; } // Update local world information whenever player map pixel changes DFPosition pos = CurrentMapPixel; if (pos.X != lastMapPixelX || pos.Y != lastMapPixelY) { RaiseOnMapPixelChangedEvent(pos); UpdateWorldInfo(pos.X, pos.Y); // Clear non-permanent scenes from cache, unless going to/from owned ship DFPosition shipCoords = DaggerfallBankManager.GetShipCoords(); if (shipCoords == null || (!(pos.X == shipCoords.X && pos.Y == shipCoords.Y) && !(lastMapPixelX == shipCoords.X && lastMapPixelY == shipCoords.Y))) { SaveLoadManager.ClearSceneCache(false); } lastMapPixelX = pos.X; lastMapPixelY = pos.Y; isPlayerInLocationRect = false; } // Raise other events RaiseEvents(); // Check if player is inside actual location rect PlayerLocationRectCheck(); }
public static DaggerfallMessageBox CreateBankingStatusBox(IUserInterfaceWindow previous = null) { const string textDatabase = "DaggerfallUI"; DaggerfallMessageBox bankingBox = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, previous); bankingBox.SetHighlightColor(DaggerfallUI.DaggerfallUnityStatDrainedTextColor); List <TextFile.Token> messages = new List <TextFile.Token>(); bool found = false; messages.AddRange(GetLoansLine( TextManager.Instance.GetText(textDatabase, "region"), TextManager.Instance.GetText(textDatabase, "account"), TextManager.Instance.GetText(textDatabase, "loan"), TextManager.Instance.GetText(textDatabase, "dueDate"))); messages.Add(TextFile.NewLineToken); for (int regionIndex = 0; regionIndex < DaggerfallBankManager.BankAccounts.Length; regionIndex++) { if (DaggerfallBankManager.GetAccountTotal(regionIndex) > 0 || DaggerfallBankManager.HasLoan(regionIndex)) { TextFile.Formatting formatting = DaggerfallBankManager.HasDefaulted(regionIndex) ? TextFile.Formatting.TextHighlight : TextFile.Formatting.Text; messages.AddRange(GetLoansLine(ShortenName(MapsFile.RegionNames[regionIndex], 12), DaggerfallBankManager.GetAccountTotal(regionIndex).ToString(), DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString(), DaggerfallBankManager.GetLoanDueDateString(regionIndex), formatting)); found = true; } } if (!found) { TextFile.Token noneToken = TextFile.CreateTextToken(TextManager.Instance.GetText(textDatabase, "noAccount")); messages.Add(noneToken); messages.Add(TextFile.NewLineToken); } bankingBox.SetTextTokens(messages.ToArray()); bankingBox.ClickAnywhereToClose = true; return(bankingBox); }
/// <summary> /// Add interior people flats. /// </summary> private void AddPeople(PlayerGPS.DiscoveredBuilding buildingData) { GameObject node = new GameObject("People Flats"); node.transform.parent = this.transform; bool isMemberOfBuildingGuild = GameManager.Instance.GuildManager.GetGuild(buildingData.factionID).IsMember(); // Add block flats foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords) { // Calculate position Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Import 3D character instead of billboard if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform) != null) { continue; } // Spawn billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform); // Set position DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); go.transform.position = billboardPosition; go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0); // Add RMB data to billboard dfBillboard.SetRMBPeopleData(obj); // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj, entryDoor.buildingKey); // Disable people if shop or building is closed DFLocation.BuildingTypes buildingType = buildingData.buildingType; if ((RMBLayout.IsShop(buildingType) && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) || (buildingType <= DFLocation.BuildingTypes.Palace && !RMBLayout.IsShop(buildingType) && !PlayerActivate.IsBuildingOpen(buildingType))) { go.SetActive(false); } // Disable people if player owns this house else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey)) { go.SetActive(false); } // Disable people if this is TG/DB house and player is not a member else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID != 0 && !isMemberOfBuildingGuild) { go.SetActive(false); } // Disable people if they are TG spymaster, but not in a legit TG house (TODO: spot any other instances for TG/DB) else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID == 0 && npc.Data.factionID == (int)GuildNpcServices.TG_Spymaster) { go.SetActive(false); } } }
void SellShipButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick); if (DaggerfallBankManager.OwnsShip) { GeneratePopup(TransactionResult.SELL_SHIP_OFFER, DaggerfallBankManager.GetShipSellPrice(DaggerfallBankManager.OwnedShip)); } }
//handles button clicks from Sell ship message box void SellShip_messageBox_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { DaggerfallBankManager.MakeTransaction(TransactionType.Sell_ship, 0, regionIndex); } sender.CloseWindow(); }
//handles button clicks from Deposit LOC message box void DepositLOC_messageBox_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { DaggerfallBankManager.MakeTransaction(TransactionType.Depositing_LOC, 0, regionIndex); } sender.CloseWindow(); }
/// <summary> /// Add interior people flats. /// </summary> private void AddPeople(PlayerGPS.DiscoveredBuilding buildingData) { GameObject node = new GameObject(peopleFlats); node.transform.parent = this.transform; IGuild guild = GameManager.Instance.GuildManager.GetGuild(buildingData.factionID); bool isMemberOfBuildingGuild = guild.IsMember(); // Add block flats foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords) { // Calculate position Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Make person gameobject GameObject go = MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform); if (!go) { // Spawn billboard gameobject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform); // Set position DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); go.transform.position = billboardPosition; go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0); // Add RMB data to billboard dfBillboard.SetRMBPeopleData(obj); } // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj, entryDoor.buildingKey); // Disable people if shop or building is closed DFLocation.BuildingTypes buildingType = buildingData.buildingType; if ((RMBLayout.IsShop(buildingType) && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) || (buildingType <= DFLocation.BuildingTypes.Palace && !RMBLayout.IsShop(buildingType) && !(PlayerActivate.IsBuildingOpen(buildingType) || buildingType == DFLocation.BuildingTypes.GuildHall && guild.HallAccessAnytime()))) { go.SetActive(false); } // Disable people if player owns this house else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey)) { go.SetActive(false); } // Disable people if this is TG/DB house and player is not a member else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID != 0 && !isMemberOfBuildingGuild) { go.SetActive(false); } } }
void Update() { // Do nothing if not ready if (!ReadyCheck()) { return; } // Update local world information whenever player map pixel changes DFPosition pos = CurrentMapPixel; if (pos.X != lastMapPixelX || pos.Y != lastMapPixelY) { RaiseOnMapPixelChangedEvent(pos); UpdateWorldInfo(pos.X, pos.Y); // Clear non-permanent scenes from cache, unless going to/from owned ship DFPosition shipCoords = DaggerfallBankManager.GetShipCoords(); if (shipCoords == null || (!(pos.X == shipCoords.X && pos.Y == shipCoords.Y) && !(lastMapPixelX == shipCoords.X && lastMapPixelY == shipCoords.Y))) { SaveLoadManager.ClearSceneCache(false); } lastMapPixelX = pos.X; lastMapPixelY = pos.Y; } // Raise other events RaiseEvents(); // Check if player is inside actual location rect PlayerLocationRectCheck(); // Update nearby objects nearbyObjectsUpdateTimer += Time.deltaTime; if (nearbyObjectsUpdateTimer > refreshNearbyObjectsInterval) { UpdateNearbyObjects(); nearbyObjectsUpdateTimer = 0; } // Snap back to physical world boundary to prevent player running off edge of world // Setting to approx. 10000 inches (254 metres) in from edge so end of world not so visible if (WorldX < 10000 || // West WorldZ > 16370000 || // North WorldZ < 10000 || // South WorldX > 32750000) // East { gameObject.transform.position = lastFramePosition; } // Record player's last frame position lastFramePosition = gameObject.transform.position; }
void CheckInterior() { if (CurrentBuildingKey == 0) { Debug.LogWarning("CurrentBuildingKey == 0"); return; } else { if (!DaggerfallBankManager.IsHouseOwned(CurrentBuildingKey)) { if (playerHomeObjects.ContainsKey(CurrentBuildingKey)) { playerHomeObjects.Remove(CurrentBuildingKey); } if (DaggerfallInterior.GetSceneName(playerGPS.CurrentMapID, BuildingDirectory.buildingKey0) == Ship1Interior || DaggerfallInterior.GetSceneName(playerGPS.CurrentMapID, BuildingDirectory.buildingKey0) == Ship2Interior) { CreatePlacedObjects(playerShipObjects, PlayerShip); inPlayerHome = false; inPlayerShip = true; inPlayerShipExterior = false; } else { inPlayerHome = false; inPlayerShip = false; inPlayerShipExterior = false; } } else { PlacedObjectData_v2[] value = null; if (playerHomeObjects.ContainsKey(CurrentBuildingKey)) { playerHomeObjects.TryGetValue(CurrentBuildingKey, out value); CreatePlacedObjects(value, PlayerHome); } else { playerHomeObjects.Add(CurrentBuildingKey, value); } inPlayerHome = true; inPlayerShip = false; inPlayerShipExterior = false; } lastBuildingKey = CurrentBuildingKey; } }
void UpdateLabels() { inventoryAmount.Text = playerEntity.GetGoldAmount().ToString(); if (playerEntity.WagonItems.Contains(ItemGroups.Currency, (int)Currency.Gold_pieces)) { int wagonGold = playerEntity.WagonItems.GetItem(ItemGroups.Currency, (int)Currency.Gold_pieces).stackCount; inventoryAmount.Text += " (+" + wagonGold + ")"; } accountAmount.Text = DaggerfallBankManager.GetAccountTotal(regionIndex).ToString(); loanAmountDue.Text = DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString(); loanDueBy.Text = DaggerfallBankManager.GetLoanDueDateString(regionIndex); }
void loanBorrowButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (DaggerfallBankManager.HasLoan(regionIndex)) { GeneratePopup(TransactionResult.ALREADY_HAVE_LOAN); ToggleTransactionInput(TransactionType.None); } else { ToggleTransactionInput(TransactionType.Borrowing_loan); } }
void UpdateButtons() { depoGoldButton.Enabled = transactionType == TransactionType.None; drawGoldButton.Enabled = transactionType == TransactionType.None; depoLOCButton.Enabled = transactionType == TransactionType.None; drawLOCButton.Enabled = transactionType == TransactionType.None; depoLOCButton.Enabled = transactionType == TransactionType.None; loanBorrowButton.Enabled = transactionType == TransactionType.None; loanRepayButton.Enabled = (transactionType == TransactionType.None && DaggerfallBankManager.HasLoan(regionIndex)); buyHouseButton.Enabled = transactionType == TransactionType.None; sellHouseButton.Enabled = transactionType == TransactionType.None; buyShipButton.Enabled = transactionType == TransactionType.None; sellShipButton.Enabled = transactionType == TransactionType.None; }
private void AddFurnitureAction(DFBlock.RmbBlock3dObjectRecord obj, GameObject go, PlayerGPS.DiscoveredBuilding buildingData) { // Create unique LoadID for save system, using 9 lsb and the sign bit from each coord pos int ulong loadID = ((ulong)buildingData.buildingKey) << 30 | (uint)(obj.XPos << 1 & posMask) << 20 | (uint)(obj.YPos << 1 & posMask) << 10 | (uint)(obj.ZPos << 1 & posMask); DFLocation.BuildingTypes buildingType = buildingData.buildingType; // Handle shelves: if (shopShelvesObjectGroupIndices.Contains(obj.ModelIdNum - containerObjectGroupOffset)) { if (RMBLayout.IsShop(buildingType)) { // Shop shelves, so add a DaggerfallLoot component DaggerfallLoot loot = go.AddComponent <DaggerfallLoot>(); if (loot) { // Set as shelves, assign load id and create serialization object loot.ContainerType = LootContainerTypes.ShopShelves; loot.ContainerImage = InventoryContainerImages.Shelves; loot.LoadID = loadID; if (SaveLoadManager.Instance != null) { go.AddComponent <SerializableLootContainer>(); } } } else if (buildingType == DFLocation.BuildingTypes.Library || buildingType == DFLocation.BuildingTypes.GuildHall || buildingType == DFLocation.BuildingTypes.Temple) { // Bookshelves, add DaggerfallBookshelf component go.AddComponent <DaggerfallBookshelf>(); } else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey)) { // Player owned house, everything is a house container MakeHouseContainer(obj, go, loadID); } } // Handle generic furniture as (private) house containers: // (e.g. shelves, boxes, wardrobes, drawers etc) else if (obj.ModelIdNum / 100 == houseContainerObjectGroup || houseContainerObjectGroupIndices.Contains(obj.ModelIdNum - containerObjectGroupOffset)) { MakeHouseContainer(obj, go, loadID); } }
void SellHouseButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (DaggerfallBankManager.OwnsHouse) { BuildingDirectory buildingDirectory = GameManager.Instance.StreamingWorld.GetCurrentBuildingDirectory(); if (buildingDirectory) { BuildingSummary house; if (buildingDirectory.GetBuildingSummary(DaggerfallBankManager.OwnedHouseKey, out house)) { GeneratePopup(TransactionResult.SELL_HOUSE_OFFER, DaggerfallBankManager.GetHouseSellPrice(house)); } } } }
private void PopulatePriceList() { if (housesForSale == null) { for (int i = 0; i < 2; i++) { priceListBox.AddItem(HardStrings.bankPurchasePrice.Replace("%s", DaggerfallBankManager.GetShipPrice((ShipType)i).ToString()), i); } } else { // List all the houses for sale in this location foreach (BuildingSummary house in housesForSale) { priceListBox.AddItem(HardStrings.bankPurchasePrice.Replace("%s", DaggerfallBankManager.GetHousePrice(house).ToString())); } } }
void LoanBorrowButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick); if (DaggerfallBankManager.HasDefaulted(regionIndex)) { GeneratePopup(TransactionResult.ALREADY_DEFAULTED); ToggleTransactionInput(TransactionType.None); } else if (DaggerfallBankManager.HasLoan(regionIndex)) { GeneratePopup(TransactionResult.ALREADY_HAVE_LOAN); ToggleTransactionInput(TransactionType.None); } else { ToggleTransactionInput(TransactionType.Borrowing_loan); } }
void RestoreHousesData(HouseData_v1[] housesData) { DaggerfallBankManager.SetupHouses(); if (housesData == null) { return; } for (int i = 0; i < housesData.Length; i++) { if (housesData[i].regionIndex < 0 || housesData[i].regionIndex >= DaggerfallBankManager.Houses.Length) { continue; } DaggerfallBankManager.Houses[housesData[i].regionIndex] = housesData[i]; } }
void RestoreBankData(BankRecordData_v1[] bankData) { DaggerfallBankManager.SetupAccounts(); DaggerfallBankManager.SetupHouses(); // Covers case when loading old save with no house data if (bankData == null) { return; } for (int i = 0; i < bankData.Length; i++) { if (bankData[i].regionIndex < 0 || bankData[i].regionIndex >= DaggerfallBankManager.BankAccounts.Length) { continue; } DaggerfallBankManager.BankAccounts[bankData[i].regionIndex] = bankData[i]; } }
private void Display3dModelSelection(int selectedIdx) { if (goModel) { Object.Destroy(goModel); goModel = null; } // Position camera and set model id uint modelId = 0; if (housesForSale == null) { camera.transform.position = new Vector3(0, 12, DaggerfallBankManager.GetShipCameraDist((ShipType)selectedIdx)); modelId = DaggerfallBankManager.GetShipModelId((ShipType)selectedIdx); } else { camera.transform.position = new Vector3(0, 3, -20); BuildingSummary house = housesForSale[selectedIdx]; modelId = house.ModelID; } // Inject custom GameObject if available else create standard mesh game object for the model goModel = MeshReplacement.ImportCustomGameobject(modelId, goBankPurchase.transform, new Matrix4x4()); if (goModel == null) { goModel = GameObjectHelper.CreateDaggerfallMeshGameObject(modelId, goBankPurchase.transform); } goModel.layer = layer; // Apply current climate ClimateBases climateBase = ClimateSwaps.FromAPIClimateBase(GameManager.Instance.PlayerGPS.ClimateSettings.ClimateType); ClimateSeason season = (DaggerfallUnity.WorldTime.Now.SeasonValue == DaggerfallDateTime.Seasons.Winter) ? ClimateSeason.Winter : ClimateSeason.Summer; DaggerfallMesh dfMesh = goModel.GetComponent <DaggerfallMesh>(); dfMesh.SetClimate(climateBase, season, WindowStyle.Day); }
void HandleTransactionInput() { int amount = 0; if (string.IsNullOrEmpty(transactionInput.Text)) { return; } else if (!System.Int32.TryParse(transactionInput.Text, out amount)) { Debug.LogError("Failed to parse input"); return; } else if (amount < 1) { return; } else { DaggerfallBankManager.MakeTransaction(transactionType, amount, regionIndex); } }
public static void CheckOverdueLoans(uint lastGameMinutes) { uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); for (int regionIndex = 0; regionIndex < DaggerfallBankManager.BankAccounts.Length; regionIndex++) { long paymentDueMinutes = DaggerfallBankManager.GetLoanDueDate(regionIndex); if (paymentDueMinutes != 0) { if (paymentDueMinutes < gameMinutes) { Debug.Log("loan overdue " + paymentDueMinutes + " < " + gameMinutes); OverdueLoan(regionIndex); } else { long lastRemainingMonths = (paymentDueMinutes - lastGameMinutes) / MinutesPerMonth; long remainingMonths = (paymentDueMinutes - gameMinutes) / MinutesPerMonth; if (remainingMonths < lastRemainingMonths) { // Months left before due date int[] sendReminderMonths = { 6, 3, 1 }; if (Array.Exists(sendReminderMonths, month => lastRemainingMonths >= month && remainingMonths < month)) { // Send letters before due date instead? DaggerfallUI.AddHUDText(String.Format(TextManager.Instance.GetLocalizedText("loanReminder"), DaggerfallBankManager.GetLoanedTotal(regionIndex)), loanReminderHUDDelay); DaggerfallUI.AddHUDText(String.Format(TextManager.Instance.GetLocalizedText("loanReminder2"), remainingMonths + 1, MapsFile.RegionNames[regionIndex]), loanReminderHUDDelay); } } } } } }
public override string MaxLoan() { return(DaggerfallBankManager.CalculateMaxLoan().ToString()); }
/// <summary> /// Check if player is allowed to rest at this location. /// </summary> bool CanRest(bool alreadyWarned = false) { remainingHoursRented = -1; allocatedBed = Vector3.zero; PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (playerGPS.IsPlayerInTown(true, true)) { if (!alreadyWarned) { CloseWindow(); DaggerfallUI.MessageBox(cityCampingIllegal); } // Register crime and start spawning guards playerEntity.CrimeCommitted = PlayerEntity.Crimes.Vagrancy; playerEntity.SpawnCityGuards(true); return(alreadyWarned); } 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(TextManager.Instance.GetLocalizedText("haveNotRentedRoom")); return(false); } return(true); }
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; } }