Exemplo n.º 1
0
 public void placeBuilding(GameObject building, RessourceManager ressourceManager, JobManager jobManager, Transform buildingParent)
 {
     if (_building == null)
     {
         GameObject newBuild = Instantiate(building, position_absolute(), Quaternion.Euler(0, this.rotation, 0), buildingParent.transform);
         _building = newBuild.GetComponent <Building>();
         if (fitsRequirement(_building.build_requirement) && ressourceManager.canAfford(_building))
         {
             decoration.gameObject.SetActive(false);
             _building.tile = this;
             ressourceManager.buyBuilding(_building);
             _building.setEfficiency();
             _building.ressourceManager = ressourceManager;
             _building.jobManager       = jobManager;
             _building.launch();
             navigationManager.register(this);
         }
         else
         { // Revert changes
             Destroy(_building.gameObject);
             _building = null;
             decoration.gameObject.SetActive(true);
             navigationManager.unregister(this);
         }
     }
     else
     {
         Destroy(_building.gameObject);
         _building = null;
         decoration.gameObject.SetActive(true);
     }
 }