public bool PlaceBuilding(iBuildingReceiver tile) { if (tile == null) { return(false); } if (tile.canReceiveBuilding()) { this.transform.position = tile.getPlacementLocation(); tile.ReceiveBuilding(this as iBuildingPlacer); placedRowCol = tile.getRowCol(); //store the hover interface for the tile so that we can passthru hovers on the building tileHover = tile.getGameObject().GetComponent <iHoverable>(); myReceiverTile = tile; return(true); } else { return(false); } }
//Called on hover stop of tiles public void ClearCurrentTile_buildMode(iBuildingReceiver tile) { //If we have stopped hovering the tile that was ref'ed as the current build mode tile, set to null if (_currentTile_buildMode == tile) { _currentTile_buildMode = null; } }
public void PurchaseAndPlaceBuilding(iBuildingReceiver tile) { if (buildInGame.currentBuilding != BuildingType.off) { //Check cost and make sure the player can afford int buildCost = BuildingCosts.GetCost(buildInGame.currentBuilding); if (Resources.instance.CanAfford(buildCost)) { //Handle purchase and placement of buildings GameObject tempBuilding = GameObject.Instantiate(GetBuildingPrefab_forType(buildInGame.currentBuilding)); //Try to place building on the current tile if (tempBuilding.gameObject.GetComponent <iBuildingPlacer>().PlaceBuilding(tile)) { //building was successfully placed onto the receiver //Subtract the cost of the building Resources.instance.subMoney(buildCost); //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()); //Destroy the transparent building temp game object ClearTransparentBuilding(); } else { //fail to build, destroy temp Destroy(tempBuilding); } } //See if we need to drop out of build mode, if they can no longer afford the placements //Check cost and make sure the player can afford if (!Resources.instance.CanAfford(buildCost)) { StopBuildingPurchase(); } } }
public iBuildingReceiver getTileAtLoc(Vector2 rowCol) { iBuildingReceiver _tempTile = null; //Loop all tiles and find the one with the matching location for (int j = 0; j < boardTiles.Count; j++) { if (((iBuildingReceiver)boardTiles[j]).getRowCol() == rowCol) { //Found the matching rowCol, assign and drop out _tempTile = (iBuildingReceiver)boardTiles[j]; j = boardTiles.Count + 1; } } return(_tempTile); }
//===== Transparent building handling public void PlaceTransparentBuilding(iBuildingReceiver tile) { //Spawn transparent building if it's not already if (transparentBuilding == null) { //There is no temp building for remove mode if (buildInGame.currentBuilding != BuildingType.remove) { transparentBuilding = Instantiate(GetTransparentBuildingPrefab_forType(buildInGame.currentBuilding)); } } //Place the transparent building on the requesting receiver (board tile) if (transparentBuilding != null) { transparentBuilding.GetComponent <iBuildingPlacer>().ChangeLoc(tile.getPlacementLocation()); } }
public void PlaceTempBuilding(iBuildingReceiver tile) { if (tempBuilding == null) { //There is no temp building for remove mode if (buildingPlacement.currentBuilding != BuildingType.remove) { tempBuilding = Instantiate(GetBuildingPrefab_forType(buildingPlacement.currentBuilding)); } } if (tempBuilding != null) { tempBuilding.GetComponent <iBuildingPlacer>().ChangeLoc(tile.getPlacementLocation()); } //Store this tile as the current tile (has a click down but no click up yet) _currentTile = tile; }
public bool PlaceBuilding(iBuildingReceiver tile) { if(tile == null) { return false; } if(tile.canReceiveBuilding()) { this.transform.position = tile.getPlacementLocation(); tile.ReceiveBuilding(this as iBuildingPlacer); placedRowCol = tile.getRowCol(); //store the hover interface for the tile so that we can passthru hovers on the building tileHover = tile.getGameObject().GetComponent<iHoverable>(); myReceiverTile = tile; return true; } else { return false; } }
//Called on hover start of tiles public void SetCurrentTile_buildMode(iBuildingReceiver tile) { _currentTile_buildMode = tile; }
public void SetCurrentHoverTileForBuilding(iBuildingReceiver tile) { //Store this tile as the current tile (has a click down but no click up yet) _currentTile = tile; }