Esempio n. 1
0
 // Simple building and destoying mechanism. TODO
 void OnMouseDown()
 {
     // If there is no building and player has money
     if ((buildingPrefab != null) && (building == null) && (GameObject.FindObjectOfType<Player>().money >= buildingPrefab.price)){
         building = (Building)Instantiate(buildingPrefab);
         building.SetTile(this);
         building.transform.parent = transform;
         building.transform.position = transform.position;
         // Player pays the price of the building
         GameObject.FindObjectOfType<Player>().addMoney(-building.price);
     } else
         // If there is a building destroy it
     if ((buildingPrefab != null) && (building != null)){
         Destroy(building.gameObject);
     }
 }