public virtual void Place() { var occupiedArea = Utilities.GetGridReference(transform.position); BuildGridManager.OccupyTiles(occupiedArea.X, occupiedArea.Z, View.Size, TileOccupant.PlayerBuilding); EventSystem.Publish(new PlayerBuildingPlacedEvent(this)); }
public void Place() { int x = Mathf.FloorToInt(transform.position.x); int z = Mathf.FloorToInt(transform.position.z); BuildGridManager.OccupyTiles(x, z, Size, TileOccupant.CityBuilding); EventSystem.Publish(new CityBuildingPlacedEvent(this)); }
void CreateExpansionEntry(BuildGridReference gridRef) { TileOccupant tileOccupantAtGridRef = BuildGridManager.GetOccupantAtLocation(gridRef); // add if anything but a city building, as could destroy a power plant, freeing up space. Will check can place at point of spawn. if (tileOccupantAtGridRef != TileOccupant.CityBuilding) { expansionAreas.Add(gridRef); } }
void SpawnNewRandomCityBuilding() { // TODO: need to find a fit for the tile specified (e.g. if 2x2 and only 1x1 area to build in, go for small building) CityBuildingModel randomModel = CityBuildingStore.GetRandomCityBuilding(); // TODO: definitely inefficient List <BuildGridReference> gridRefs = new List <BuildGridReference>(expansionAreas); for (int i = 0; i < 20; i++) { BuildGridReference spawnReference = Curveball.Utilities.SelectRandomlyFromList(gridRefs); if (BuildGridManager.CanBuildAt(spawnReference, randomModel.Size)) { CreateBuilding(randomModel, spawnReference); return; } } // was unable to spawn a building: set spawn timer to 0f to try again next frame spawnTimer = 0f; }