public void PurchasePowerup(PowerupBase.PowerupType purchasedType) { if (playerPowerups.ContainsKey(purchasedType)) { Debug.LogError("Player already owns this powerup"); return; } int powerUpCost = GameManager.Instance.powerUpCosts.GetCostForPowerup(purchasedType); if (powerUpCost > currencyAmount) { Debug.LogError("Not enough currency!"); return; } // TODO: Add all other types switch (purchasedType) { case PowerupBase.PowerupType.DOUBLE_JUMP: playerPowerups.Add(purchasedType, new DoubleJumpPowerup()); playerPowerups[purchasedType].OnPurchased(); break; case PowerupBase.PowerupType.DASH: playerPowerups.Add(purchasedType, new DashPowerup()); playerPowerups[purchasedType].OnPurchased(); break; } }
public void InitializeItem(PowerupBase.PowerupType type, PowerupShop shop) { parentShop = shop; powerUpInfo = GameManager.Instance.powerUpCosts.GetCostPair(type); if (powerupImage == null) { return; } powerupImage.sprite = powerUpInfo.powerupSprite; if (!PlayerInventory.Instance.unlockedPowerUps.Contains(powerUpInfo.type)) { // TODO: Show locked } else { if (PlayerInventory.Instance.playerPowerups.ContainsKey(powerUpInfo.type)) { // TODO: Show owned } else { // TODO: Show purchasable } } }
public void UnlockPowerup(PowerupBase.PowerupType unlockedType) { if (!unlockedPowerUps.Contains(unlockedType)) { unlockedPowerUps.Add(unlockedType); } }
private void SetItemTexts(PowerupBase.PowerupType type) { selectedItemTitle.text = GameManager.Instance.powerUpCosts.GetTitleText(type); selectedItemDescription.text = GameManager.Instance.powerUpCosts.GetDescriptionText(type); bool owned = PlayerInventory.Instance.playerPowerups.ContainsKey(type); purchaseButtonText.text = owned ? "Owned" : "Cost: " + GameManager.Instance.powerUpCosts.GetCostForPowerup(type); purchaseButton.image.color = owned ? Color.red : new Color(1, 1, 1, 0.5f); }
public PowerUpCostPair GetCostPair(PowerupBase.PowerupType type) { foreach (PowerUpCostPair pair in powerUpCostList) { if (pair.type == type) { return(pair); } } return(new PowerUpCostPair()); }
public string GetDescriptionText(PowerupBase.PowerupType type) { foreach (PowerUpCostPair pair in powerUpCostList) { if (pair.type == type) { return(pair.descriptionText); } } return(null); }
public Sprite GetSpriteForPowerup(PowerupBase.PowerupType type) { foreach (PowerUpCostPair pair in powerUpCostList) { if (pair.type == type) { return(pair.powerupSprite); } } return(null); }
public int GetCostForPowerup(PowerupBase.PowerupType type) { foreach (PowerUpCostPair pair in powerUpCostList) { if (pair.type == type) { return(pair.cost); } } return(int.MaxValue); }
private bool HasPowerup(PowerupBase.PowerupType type) { return(PlayerInventory.Instance.playerPowerups.ContainsKey(type)); }