void buildTower() { //set the tower of the tile to the selected tower blueprint towerBlueprint = TowerBlueprintSelector.towerBlueprintToBuild; //Debug.Log("tower blueprint = " + towerBlueprint); if (towerBlueprint == null) { //show no tower selected message maybe? Debug.Log("No tower has been selected in the build menu yet"); return; } //tower = towerBlueprint.towerPrefab; //instatiate tower prefab tower = Instantiate(towerBlueprint.towerPrefab, new Vector3(transform.position.x, transform.position.y + offset, transform.position.z), Quaternion.identity); //subtract the cost from our currency PlayerStats.currentCurrency -= towerBlueprint.cost; //add the tower blueprint to the tower tower.GetComponent <Tower>().TB = towerBlueprint; Debug.Log("Player bought " + towerBlueprint.name + " for " + towerBlueprint.cost + " gold! Player has " + PlayerStats.currentCurrency + " gold remaining."); //make sure players can't go in negative gold cause of having a tower to build selected already if (PlayerStats.currentCurrency < towerBlueprint.cost) { //display play has run out of money for this tower //deselect towerblueprint tbSelector.deselectTowerBluerpint(); } }
void Update() { if (Input.GetButtonDown("Fire2"))// right Click { tbSelector.deselectTowerBluerpint(); } }