Created
June 28, 2017 19:34
-
-
Save anonymous/85bb165682e1cee9a65fdd4c4b889686 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void BuildTower(GameObject towerPrefab, bool buildtowerbool) | |
{ | |
// Close active building tree | |
CloseBuildingTree(false); | |
Price price = towerPrefab.GetComponent<Price>(); | |
// If anough gold | |
if (uiManager.SpendGold(price.price) == true) | |
{ | |
// Create new tower and place it on same position | |
GameObject newTower = Instantiate<GameObject>(towerPrefab, transform.parent); | |
newTower.transform.position = transform.position; | |
newTower.transform.rotation = transform.rotation; | |
// Destroy old tower | |
Destroy(gameObject); | |
} | |
} | |
/// <summary> | |
/// Disable tower raycast and close building tree on game pause. | |
/// </summary> | |
/// <param name="obj">Object.</param> | |
/// <param name="param">Parameter.</param> | |
private void GamePaused(GameObject obj, string param) | |
{ | |
if (param == bool.TrueString) // Paused | |
{ | |
CloseBuildingTree(); | |
bodyCollider.enabled = false; | |
} | |
else // Unpaused | |
{ | |
bodyCollider.enabled = true; | |
} | |
} | |
/// <summary> | |
/// On user click. | |
/// </summary> | |
/// <param name="obj">Object.</param> | |
/// <param name="param">Parameter.</param> | |
private void UserClick(GameObject obj, string param) | |
{ | |
if (obj == gameObject) // This tower is clicked | |
{ | |
// Show attack range | |
ShowRange(true); | |
if (activeBuildingTree == null) | |
{ | |
// Open building tree if it is not | |
OpenBuildingTree(); | |
} | |
} | |
else // Other click | |
{ | |
// Hide attack range | |
ShowRange(false); | |
// Close active building tree | |
CloseBuildingTree(true); | |
if (!BuildTower(true)) | |
{ | |
Debug.Log("closed 4 real this time"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment