コード例 #1
0
 private void PlaceBuilding(Building building, BuildingTile tile)
 {
     building.Tile          = tile;
     building.Tile.Building = building;
     building.transform.SetParent(building.Tile.transform, false);
     building.transform.localPosition = (new Vector3(0, 0, -0.1f));
 }
コード例 #2
0
 public void BuyBuilding(Building building, BuildingTile tile)
 {
     if (tile.Building == null && Core.Data.Saved.Gold >= building.GoldCost)
     {
         Core.Data.Saved.Gold.Set(Core.Data.Saved.Gold - building.GoldCost);
         PlaceBuilding(building, tile);
         SaveBuildings();
     }
 }
コード例 #3
0
        public Building GetAdjacentBuilding(Vector2 worldPosition)
        {
            Vector2      gridPos = GetClosestGridPositionIgnoringGridLimits(worldPosition);
            BuildingTile cell    = GetCell(gridPos - new Vector2(1f, 0f));

            if (cell == null)
            {
                return(null);
            }
            return(cell.Building);
        }