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); }
protected static void GenerateShop_OnTransitionInterior(PlayerEnterExit.TransitionEventArgs args) { ulong creationTime = 0; int buildingQuality = 0; bool investedIn = false; uint amountInvested = 0; int shopAttitude = 0; int buildingKey = 0; int currentGoldSupply = 0; creationTime = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToSeconds(); buildingQuality = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.quality; buildingKey = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey; if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) { //Debug.Log("You Just Entered An Open Shop, Good Job!..."); ShopData sd; currentGoldSupply = GoldSupplyAmountGenerator(buildingQuality); shopAttitude = UnityEngine.Random.Range(0, 2); // Mostly have it as an int instead of a bool, just incase I want to add more "attitude types" to this later on. //Debug.Log("Building Attitude Rolled: " + shopAttitude.ToString()); FlexCurrentGoldSupply = currentGoldSupply; // On transition, sets the shops gold supply to this "global variable" for later uses. if (!ShopBuildingData.ContainsKey(buildingKey)) { ShopData currentBuildKey = new ShopData { CreationTime = creationTime, InvestedIn = investedIn, AmountInvested = amountInvested, ShopAttitude = shopAttitude, BuildingQuality = buildingQuality, CurrentGoldSupply = currentGoldSupply }; //Debug.Log("Adding building " + buildingKey.ToString() + " - quality: " + buildingQuality.ToString()); ShopBuildingData.Add(buildingKey, currentBuildKey); } else { if (ShopBuildingData.TryGetValue(buildingKey, out sd)) { ulong timeLastVisited = creationTime - sd.CreationTime; investedIn = sd.InvestedIn; if (timeLastVisited >= 1296000) { // 15 * 86400 = Number of seconds in 15 days. if (investedIn) { investedIn = sd.InvestedIn; amountInvested = sd.AmountInvested; shopAttitude = sd.ShopAttitude; buildingQuality = sd.BuildingQuality; currentGoldSupply = InvestedGoldSupplyAmountGenerator(buildingQuality, amountInvested, shopAttitude); ShopBuildingData.Remove(buildingKey); //Debug.Log("Removing Expired Invested Shop Gold & Time: " + buildingKey.ToString()); ShopData currentBuildKey = new ShopData { CreationTime = creationTime, InvestedIn = investedIn, AmountInvested = amountInvested, ShopAttitude = shopAttitude, BuildingQuality = buildingQuality, CurrentGoldSupply = currentGoldSupply }; //Debug.Log("Refreshing building " + buildingKey.ToString() + " - quality: " + buildingQuality.ToString()); ShopBuildingData.Add(buildingKey, currentBuildKey); } else { ShopBuildingData.Remove(buildingKey); //Debug.Log("Removed Expired Building Key " + buildingKey.ToString() + " Generating New Properties"); ShopData currentBuildKey = new ShopData { CreationTime = creationTime, InvestedIn = investedIn, AmountInvested = amountInvested, ShopAttitude = shopAttitude, BuildingQuality = buildingQuality, CurrentGoldSupply = currentGoldSupply }; //Debug.Log("Adding building " + buildingKey.ToString() + " - quality: " + buildingQuality.ToString()); ShopBuildingData.Add(buildingKey, currentBuildKey); } } //Debug.Log("Building " + buildingKey.ToString() + " is present - quality = " + sd.BuildingQuality.ToString()); } } } else { return; } //Debug.Log("You Just Entered Something Other Than An Open Shop..."); }
public static void TradeUpdateShopGold(DaggerfallTradeWindow.WindowModes mode, int value) { 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; try { 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; } //Debug.LogFormat("Sale Value = {0}", value); if (mode == DaggerfallTradeWindow.WindowModes.Buy && (playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.Temple || playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.GuildHall)) { //Debug.Log("You are buying inside a Temple or a Guild-Hall."); } else if (mode == DaggerfallTradeWindow.WindowModes.Buy) { currentGoldSupply = sd.CurrentGoldSupply + value; ShopBuildingData.Remove(buildingKey); ShopData currentBuildKey = new ShopData { CreationTime = creationTime, InvestedIn = investedIn, AmountInvested = amountInvested, ShopAttitude = shopAttitude, BuildingQuality = buildingQuality, CurrentGoldSupply = currentGoldSupply }; ShopBuildingData.Add(buildingKey, currentBuildKey); } else { currentGoldSupply = sd.CurrentGoldSupply - value; 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("Shop Gold Supply After Sale = {0}", currentGoldSupply); FlexCurrentGoldSupply = currentGoldSupply; } catch { //Debug.Log("You are buying inside a Temple or a Guild-Hall, as your first entered building since launching the game!"); } }