public void ChangeTower(GameObject tower, string type) { NodeV2 node = tower.transform.parent.transform.gameObject.GetComponent <NodeV2>(); node.RemoveTower(); Vector3 pos = node.GetTowerObject().transform.position; GameObject newTower = null; switch (type) { case "fire": newTower = Instantiate(fire_tower, pos, Quaternion.identity) as GameObject; break; case "ice": newTower = Instantiate(ice_tower, pos, Quaternion.identity) as GameObject; break; case "nature": newTower = Instantiate(nature_tower, pos, Quaternion.identity) as GameObject; break; case "base": newTower = Instantiate(base_tower, pos, Quaternion.identity) as GameObject; break; } if (!newTower.Equals(null)) { newTower.transform.parent = node.transform; } node.SetTowerObject(newTower); }
public void SellTower(GameObject selectedTower, NodeV2 parentNode) { //Set the Node that the tower was previously placed on to false parentNode.towerPlaced = false; parentNode.SetIsTowerPlacable(true); string towerType = selectedTower.GetComponent <TowerController>().GetTowerType(); int amountReturned = CostTemplate.cost_dictionary[towerType]; GameController.SellTowerGetMoney(amountReturned); parentNode.RemoveTower(); }