public void PlaceBuildingOnCurrent() { if (buildingPlacement.currentBuilding != BuildingType.off) { if (_currentTile != null) { //Handle building removal mode if (buildingPlacement.currentBuilding == BuildingType.remove) { //Store the building and it's removal sound from this tile in temp iBuildingPlacer _tempBuilding = _currentTile.getPlacedBuilding(); SoundType _tempSound = SoundType.None; if (_tempBuilding != null) { _tempSound = _tempBuilding.getRemovalSound(); } //Try to remove building from the current tile building receiver if (_currentTile.RemoveBuilding()) { //Building was cleared from receiver //Play building remove sound, if we have one if (SoundType.None != _tempSound) { Sounds.instance.Play(_tempSound); } } else { //no building to clear } } else { //Handle placement of all other buildings GameObject tempBuilding = GameObject.Instantiate(GetBuildingPrefab_forType(buildingPlacement.currentBuilding)); //Try to place building on the current tile if (tempBuilding.gameObject.GetComponent <iBuildingPlacer>().PlaceBuilding(_currentTile)) { //building was successfully placed onto the receiver //Parent new building to root tempBuilding.transform.parent = GO_Root.transform; //add to internal list allBuildings.Add(tempBuilding); //Initiate the new building (with it's index, etc) tempBuilding.gameObject.GetComponent <iBuildingPlacer>().Init(allBuildings.Count - 1); //Play building place sound Sounds.instance.Play( tempBuilding.gameObject.GetComponent <iBuildingPlacer>().getPlacementSound()); } else { //fail to build, destroy temp Destroy(tempBuilding); } } } } }