private void PlaceDefenderAt(Vector2 gridPos) { var coinsDisplay = FindObjectOfType <CoinsDisplay>(); int defenderCost = defenderType.GetCoinCost(); if (coinsDisplay.HaveEnoughCoins(defenderCost)) { SpawnDefender(gridPos); coinsDisplay.SpendCoins(defenderCost); } }
private void LabelButtonWithCost() { Text costText = GetComponentInChildren <Text>(); if (!costText) { Debug.LogError(name + "has no cost text"); } else { costText.text = defenderPrefab.GetCoinCost().ToString(); } }
private void AttemptToPlaceDefenderAt(Vector2 gridPos) { if (defender != null && FindObjectOfType <CoinDisplay>() != null) { var CoinDisplay = FindObjectOfType <CoinDisplay>(); int defenderCost = defender.GetCoinCost(); //if we have enough coin if (CoinDisplay.HaveEnoughCoin(defenderCost)) { SpawnDefender(gridPos); CoinDisplay.SpendCoin(defenderCost); } } }
private void AttemptToPlaceDefender() { var coinDisplay = FindObjectOfType <CoinDisplay>(); int defenderCost = defender.GetCoinCost(); if (coinDisplay.HaveEnoughCoins(defenderCost)) { SpawnDefender(GetSquareClicked()); coinDisplay.SpendCoins(defenderCost); } else { return; } }