private void InstantiateTower(PlaceTowers baseTowerPlacement) { var newTower = Instantiate(towerPrefab, baseTowerPlacement.transform.position, Quaternion.identity); newTower.transform.parent = towerParent; newTower.towerBase = baseTowerPlacement; baseTowerPlacement.isPlacable = false; placedTowers.Enqueue(newTower); }
private void MoveExistingTower(PlaceTowers newTowerBasePlacement) { var oldTower = placedTowers.Dequeue(); oldTower.towerBase.isPlacable = true; newTowerBasePlacement.isPlacable = false; oldTower.towerBase = newTowerBasePlacement; oldTower.transform.position = newTowerBasePlacement.transform.position; placedTowers.Enqueue(oldTower); }
public void AddTower(PlaceTowers baseTowerPlacement) { towerCount = placedTowers.Count; if (towerCount > towerLimit - 1) { MoveExistingTower(baseTowerPlacement); } else { InstantiateTower(baseTowerPlacement); } }