public void BuyUpgrade <T>(UpgradeTier <T> currentUpgrade) { if (currentUpgrade.Next != null && gameObject.GetComponent <GameManager>().money >= currentUpgrade.Next.Cost) { gameObject.GetComponent <GameManager>().money -= currentUpgrade.Next.Cost; switch (currentUpgrade.Type) { case Upgrades.ClickWeight: currentClickWeight = currentClickWeight.Next; break; case Upgrades.Raise: currentRaise = currentRaise.Next; break; case Upgrades.Inflation: currentInflation = currentInflation.Next; break; } Debug.Log(currentUpgrade.Type + " Upgraded"); } else { Debug.Log("No next upgrade available or not enough money!"); } }
public UpgradeTier(Upgrades type, T data, float cost, UpgradeTier <T> nextTier) { this.type = type; this.data = data; this.cost = cost; this.nextTier = nextTier; }
void CreateInflationUpgrades() { UpgradeTier <float> inflactionTier3 = new UpgradeTier <float>(Upgrades.Inflation, 1.3f, 2000000.0f, null); UpgradeTier <float> inflactionTier2 = new UpgradeTier <float>(Upgrades.Inflation, 1.15f, 23500.0f, inflactionTier3); UpgradeTier <float> inflactionTier1 = new UpgradeTier <float>(Upgrades.Inflation, 1.05f, 2250.0f, inflactionTier2); startingInflation = new UpgradeTier <float>(Upgrades.Inflation, 1.0f, 0.0f, inflactionTier1); }
void CreateRaiseUpgrades() { UpgradeTier <float> raiseTier3 = new UpgradeTier <float>(Upgrades.Raise, 1.3f, 450000.0f, null); UpgradeTier <float> raiseTier2 = new UpgradeTier <float>(Upgrades.Raise, 1.2f, 17500.0f, raiseTier3); UpgradeTier <float> raiseTier1 = new UpgradeTier <float>(Upgrades.Raise, 1.1f, 1000.0f, raiseTier2); startingRaise = new UpgradeTier <float>(Upgrades.Raise, 1.0f, 0.0f, raiseTier1); }
void CreateClickUpgrades() { UpgradeTier <int> clickWeightTier3 = new UpgradeTier <int>(Upgrades.ClickWeight, 10, 150000.0f, null); UpgradeTier <int> clickWeightTier2 = new UpgradeTier <int>(Upgrades.ClickWeight, 5, 12500.0f, clickWeightTier3); UpgradeTier <int> clickWeightTier1 = new UpgradeTier <int>(Upgrades.ClickWeight, 2, 1250.0f, clickWeightTier2); startingClickWeight = new UpgradeTier <int>(Upgrades.ClickWeight, 1, 0.0f, clickWeightTier1); }
public float GetCost() { UpgradeTier tier = GameManager.Instance.UpgradeManager.UpgradeTierFromId(tierId); int purchasedCount = GameManager.Instance.UpgradeManager.PurchasedCount(id); return(Mathf.Pow(10, tier.BasePrice) * (((float)purchasedCount / quantity) + 1) // Increase price after each unit purchased * (100 / quantity)); // Increase price for lower quantity upgrades }
public static GameConfiguration FromJSON(string jsonStr) { JSONNode json = JSON.Parse(jsonStr); return(new GameConfiguration( Target.FromArray(json["targets"].AsArray), Device.FromArray(json["devices"].AsArray), StorageUnit.FromArray(json["storage"].AsArray), UpgradeType.FromArray(json["upgrades"]["types"].AsArray), UpgradeTier.FromArray(json["upgrades"]["tiers"].AsArray) )); }
public UpgradeTier UpgradeTierFromId(int tierId) { for (int i = 0; i < GameManager.Instance.GameConfiguration.UpgradeTiers.Length; i++) { UpgradeTier tier = GameManager.Instance.GameConfiguration.UpgradeTiers[i]; if (tier.Id == tierId) { return(tier); } } return(null); }
public static UpgradeTier[] FromArray(JSONArray jsonArr) { UpgradeTier[] tiers = new UpgradeTier[jsonArr.Count]; for (int i = 0; i < tiers.Length; i++) { JSONNode json = jsonArr[i]; tiers[i] = new UpgradeTier( i, json["name"].Value, Upgrade.FromArray(i, json["upgrades"].AsArray), json["base-price"].AsFloat ); } return(tiers); }
void LoadUpgrades() { currentClickWeight = startingClickWeight; for (int i = 0; i < clickWeightTierNum; i++) { if (currentClickWeight.Next == null) { break; } else { currentClickWeight = currentClickWeight.Next; } } currentRaise = startingRaise; for (int i = 0; i < raiseTierNum; i++) { if (currentRaise.Next == null) { break; } else { currentRaise = currentRaise.Next; } } currentInflation = startingInflation; for (int i = 0; i < inflationTierNum; i++) { if (currentInflation.Next == null) { break; } else { currentInflation = currentInflation.Next; } } }
public void ResetUpgrades() { currentClickWeight = startingClickWeight; currentRaise = startingRaise; currentInflation = startingInflation; }