Beispiel #1
0
        private static Building GetSmallBuilding(SpriteFrame spriteFrame, Vector2 pos, Rectangle rect, Actions type, Costs costs)
        {
            if (type == Actions.House)
            {
                return(new House(spriteFrame, pos, rect, type, costs));
            }
            if (type == Actions.Woodcutter)
            {
                return(new Woodcutter(spriteFrame, pos, rect, type, costs));
            }

            return(null);
        }
Beispiel #2
0
        public static Actions BuildStuff(Actions mouseAction, Vector2 mousePositionInWorld)
        {
            foreach (Tile tile in tileMap)
            {
                if (tile != null && tile.Rect.Contains(mousePositionInWorld))
                {
                    if (mouseAction == Actions.Townhall)
                    {
                        // Only allowed to build it once
                        foreach (Building building in mechanics.Buildings)
                        {
                            if (building.Type == Actions.Townhall)
                            {
                                mouseAction = Actions.Nothing;
                                return(mouseAction);
                            }
                        }
                        BuildingOperations.BuildTownHall(tile, new Costs(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
                        mouseAction = Actions.Nothing;
                    }
                    if (mouseAction == Actions.House)
                    {
                        BuildingOperations.BuildSmallBuilding(tile, mouseAction, Costs.HouseCosts());
                    }
                    if (mouseAction == Actions.Farm)
                    {
                        BuildingOperations.BuildLargeBuilding(tile, mouseAction, Costs.FarmCosts());
                    }
                    if (mouseAction == Actions.Woodcutter)
                    {
                        BuildingOperations.BuildSmallBuilding(tile, mouseAction, Costs.WoodcutterCosts());
                    }
                    if (mouseAction == Actions.Quarry)
                    {
                        BuildingOperations.BuildQuarry(tile, mouseAction, Costs.WoodcutterCosts());
                    }
                    if (mouseAction == Actions.Scientist)
                    {
                        BuildingOperations.BuildLargeBuilding(tile, mouseAction, Costs.ScientistCosts());
                    }
                    if (mouseAction == Actions.Brewery)
                    {
                        BuildingOperations.BuildLargeBuilding(tile, mouseAction, Costs.BreweryCosts());
                    }
                    if (mouseAction == Actions.Tavern)
                    {
                        BuildingOperations.BuildLargeBuilding(tile, mouseAction, Costs.TavernCosts());
                    }
                    if (mouseAction == Actions.Storage)
                    {
                        BuildingOperations.BuildLargeBuilding(tile, mouseAction, Costs.StorageCosts());
                    }
                    if (mouseAction == Actions.Road)
                    {
                        BuildingOperations.BuildRoad(tile, false);
                    }
                }
            }

            // Sort buildings for rendering later
            IOrderedEnumerable <Building> sortedBuildings = mechanics.Buildings.OrderBy(building => building.Position.Y);

            mechanics.Buildings = new List <Building>();
            foreach (Building building in sortedBuildings)
            {
                mechanics.Buildings.Add(building);
            }

            mechanics.MaxPop = mechanics.GetMaxPop();
            return(mouseAction);
        }
Beispiel #3
0
        private static Building GetLargeBuilding(SpriteFrame spriteFrame, Vector2 pos, Rectangle rect, Actions type, Costs costs)
        {
            if (type == Actions.Farm)
            {
                return(new Farm(spriteFrame, pos, rect, type, costs));
            }
            if (type == Actions.Scientist)
            {
                return(new Scientist(spriteFrame, pos, rect, type, costs));
            }
            if (type == Actions.Quarry)
            {
                return(new Quarry(spriteFrame, pos, rect, type, costs));
            }
            if (type == Actions.Tavern)
            {
                return(new Tavern(spriteFrame, pos, rect, type, costs));
            }
            if (type == Actions.Brewery)
            {
                return(new Brewery(spriteFrame, pos, rect, type, costs));
            }
            if (type == Actions.Storage)
            {
                return(new Storage(spriteFrame, pos, rect, type, costs));
            }

            return(null);
        }