public void Sell() { GameManager.gm.towers.Remove(this); GameManager.gm.AddScrap(ScrapValues.GetTowerSellPrice(type)); towerPlatform.hasTower = false; Destroy(gameObject); }
//Sets the existing tower buttons to disable when pressed. //Sets the upgrade button to upgrade the tower when pressed. //Sets the sell button to sell the tower when pressed. void SetExistingTowerMenuButtons(Tower tower) { foreach (Button button in existingTowerMenuButtons) { button.onClick.RemoveAllListeners(); } existingTowerMenuButtons[0].onClick.AddListener(() => tower.Upgrade()); existingTowerMenuButtons[1].onClick.AddListener(() => tower.Sell()); existingTowerMenuButtons[0].transform.Find("Text").GetComponent <Text>().text = "Upgrade\n<size=12>" + ScrapValues.GetTowerUpgradePrice(tower.type) + " Scrap</size>"; existingTowerMenuButtons[1].transform.Find("Text").GetComponent <Text>().text = "Sell\n<size=12>" + ScrapValues.GetTowerSellPrice(tower.type) + " Scrap</size>"; foreach (Button button in existingTowerMenuButtons) { button.onClick.AddListener(DisableRadialMenu); } }