예제 #1
0
        public LocationPair TryToBuild(Int2 buildingSize)
        {
            if (!IsAvailableToBuild() || !IsAvailableToGrow())
            {
                return(null);
            }

            List <Direction> availableDirs = CanSplitIn();

            if (availableDirs.Count <= 0)
            {
                return(null);
            }

            LocationPair buildingBounds = null;

            foreach (Direction dir in availableDirs)
            {
                Tile toConsider = ground.getDirection(dir);
                buildingBounds = StructureBuilder.BoundsForStructure(toConsider, dir, buildingSize.x, buildingSize.y);

                if (buildingBounds != null)
                {
                    availableDepths[(int)(dir)] = buildingBounds.SpaceInDirection(dir);
                    break;
                }
            }

            return(buildingBounds);
        }