Пример #1
0
 public BuildBuilding(Building building, BuildBuildingTask bb)
 {
     Nodes.Add(new CheckBuildingHasEnoughBuildingMaterials(bb));
     Nodes.Add(new FindPathToBuilding());
     Nodes.Add(new MovePath());
     Nodes.Add(new CheckBuildingHasEnoughBuildingMaterials(bb));
     Nodes.Add(new ConstructBuilding());
 }
Пример #2
0
        public static Color GetBuildingColor(Building building)
        {
            if (building.ConstructionPoints < building.NeededConstructionPoints)
            {
                return new Color(new Vector4(1, 1, 1, 0.5f));
            }

            return Color.White;
        }
Пример #3
0
 public MoveCraftToDepot(Building craftBuilding)
 {
     Nodes.Add(new FindPathToBuilding());
     Nodes.Add(new MovePath());
     Nodes.Add(new PickupCraftingItemFromCraftBuilding());
     Nodes.Add(new FindPathToNearestDepot());
     Nodes.Add(new MovePath());
     Nodes.Add(new DepositWorldObjectInBuilding());
 }
Пример #4
0
 public GetBuildingMaterial(Building building, GetBuildingMaterialTask bb)
 {
     Nodes.Add(new FindPathToDepotWithMaterialForBuildingConstruction(bb));
     Nodes.Add(new MovePath());
     Nodes.Add(new PickupWorldObjectFromDepot());
     Nodes.Add(new FindPathToBuilding());
     Nodes.Add(new MovePath());
     Nodes.Add(new DepositWorldObjectInBuilding());
 }
        public MoveCraftedResourceToDepotTask(Building craftBuilding, WorldObject obj)
        {
            CraftBuilding = craftBuilding;
            Obj = obj;
            TaskType = Tasks.TaskType.MoveCraftedResource;

            GlobalJobType = GlobalJobType.Hauling;

            RegisterTask();
        }
        private bool DoesBuildingHaveFreeCraftingSlot(Building b)
        {
            bool does = true;
            bool haveRequested = TaskManager.IsAlradyHavingCraftingSlotDepoted(b);

            if (b.GetCraftSlot() != null)
            {
                if (b.GetCraftSlot().IsCrafted() == false)
                    throw new Exception("Can't move away unfinished item");
                does = false;
                if (haveRequested == false)
                    TaskManager.AddTask(new MoveCraftedResourceToDepotTask(b, b.GetCraftSlot()));
            }

            return does;
        }
Пример #7
0
        public GetBuildingMaterialTask(MapElementType obj, int level, Building building)
        {
            Building = building;
            Type = obj;
            Level = level;
            if (Type == MapElementType.Stone)
            {

            }
            if (Type == MapElementType.Plank)
            {
                DwarfDebugInfo.GetBuildingMaterialTasksCreatedPlank++;
            }
            TaskType = TaskType.GetBuildingMaterial;

            RegisterTask();
        }
Пример #8
0
        public void SelectBuilding(Building b)
        {
            _selectedBuilding = b;

            _selectionParts.Clear();

            _selectionParts.Add(new SelectionPart() { Point = new Point(b.Position.X, b.Position.Y), Type = SelectionPartType.TopLeft});
            _selectionParts.Add(new SelectionPart() { Point = new Point(b.Position.X + b.Dimentions.X - 1, b.Position.Y), Type = SelectionPartType.TopRight});
            _selectionParts.Add(new SelectionPart() { Point = new Point(b.Position.X, b.Position.Y + b.Dimentions.Y -1), Type = SelectionPartType.BottomLeft});
            _selectionParts.Add(new SelectionPart() { Point = new Point(b.Position.X + b.Dimentions.X - 1, b.Position.Y + b.Dimentions.Y -1), Type = SelectionPartType.BottomRight});

            if (b.IsBuildingConstructed() == false)
            {
                GuiSystem.AddGuiComponent(new UnderConstruction(new Vector2(MouseInput.X, MouseInput.Y - 300)));
            }
            else if (b.GetType().IsSubclassOf(typeof(Tower)))
            {
                GuiSystem.AddGuiComponent(new TowerWindow(new Vector2(MouseInput.X, MouseInput.Y - 300),  (Tower)b));
            }
            else
            {
                b.ShowBuildingWindow(new Vector2(MouseInput.X, MouseInput.Y));
            }
        }
Пример #9
0
 public void PlaceElectricBike()
 {
     _buildingToPlace = new ElectricBike(new Vector3Int(0, 0, 0), 0);
 }
Пример #10
0
        private void Input()
        {
            if (MouseInput.IsHandled)
                return;

            if (KeyboardInput.IsKeyClicked(Keys.P))
            {
                PlaceSawmill();
            }
            if (KeyboardInput.IsKeyClicked(Keys.O))
            {
                _buildingToPlace = new Depot(new Vector3Int(0, 0, 0), 0);
            }
            if (KeyboardInput.IsKeyClicked(Keys.I))
            {
                PlaceCarpenter();
            }
            if (KeyboardInput.IsKeyClicked(Keys.U))
                PlaceMason();
            if (KeyboardInput.IsKeyClicked(Keys.T))
                _buildingToPlace = new Arrowsmith(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.R))
                _buildingToPlace = new Trader(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.Y))
                _buildingToPlace = new Kitchen(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.K))
                _buildingToPlace = new Brewery(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.L))
                _buildingToPlace = new ToolSmith(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.J))
                _buildingToPlace = new Furnace(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.H))
                _buildingToPlace = new ArcherTower(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.G))
                _buildingToPlace = new StoneWall(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.E))
                _buildingToPlace = new ElectricBike(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.F))
                _buildingToPlace = new Battery(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.Q))
                _buildingToPlace = new CoalPowerGenerator(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.Z))
                _buildingToPlace = new Bulletsmith(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.Tab))
                _buildingToPlace = new PistolTower(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.LeftShift))
                _buildingToPlace = new TeslacoilTower(new Vector3Int(0, 0, 0), 0);
            if (KeyboardInput.IsKeyClicked(Keys.LeftControl))
                _buildingToPlace = new BalistaTower(new Vector3Int(0, 0, 0), 0);

            if (MouseInput.IsLeftMouseClicked() && _buildingToPlace != null)
            {
                PlaceBuilding();
            }
            if (MouseInput.IsRightMouseClicked())
            {
                CancelBuilding();
            }
        }
Пример #11
0
 public void CursorChange()
 {
     _selectedBuilding = null;
     _selectionParts.Clear();
 }
Пример #12
0
 private void PlaceBuilding()
 {
     _buildingToPlace.Position = new Vector3Int(_highlightedCell.X, _highlightedCell.Y, _highlightedCell.Z - 1);
     WorldMap.Instance.AddBuilding(_buildingToPlace);
     _buildingToPlace = null;
 }
Пример #13
0
 public void SetActionBuilding(Building b)
 {
     _prevActionBuilding = _actionBuilding;
     _actionBuilding = b;
 }
Пример #14
0
 public void PlaceBed()
 {
     _buildingToPlace = new Bed(new Vector3Int(0, 0, 0), 0);
 }
Пример #15
0
 public void PlaceToolsmith()
 {
     _buildingToPlace = new ToolSmith(new Vector3Int(0, 0, 0), 0);
 }
Пример #16
0
 public HarvestCropTask(CropBase crop, Building associatedBuilding)
 {
     Crop = crop;
     associatedBuilding.TasksAssociatedWithBuilding.Add(this);
     TaskType = TaskType.HarvestCrop;
 }
Пример #17
0
        private void RemoveUsedResources(Building b, WorldObject obj)
        {
            if (obj.ElementType == MapElementType.Meal)
            {
                int removedCount = 0;
                Meal meal = (Meal)b.GetCraftSlot();
                meal.NutritionalValue = 0;

                List<MapElementType> toBeRemoved = new List<MapElementType>();
                foreach (KeyValuePair<MapElementType, List<WorldObject>> keyValue in b.DepositedWorldObjects)
                {
                    foreach (WorldObject depobj in keyValue.Value)
                    {
                        if (depobj.GetType().IsSubclassOf(typeof(Food)) && depobj.ElementType != MapElementType.Meal)
                        {
                            if (removedCount == 2)
                                break;

                            Food food = (Food)depobj;
                            // Adds the double of the foods nutritional value to the meal
                            meal.NutritionalValue = meal.NutritionalValue + food.NutritionalValue * TimeRules.MealMultiplier;
                            // Adds the buffs of the food to the meal, and multiply effect by 2
                            foreach (StatBuff buff in food.StatBuffs)
                            {
                                meal.StatBuffs.Add(new StatBuff() { Type = buff.Type, Value = buff.Value  });
                            }

                            toBeRemoved.Add(depobj.ElementType);
                            removedCount++;
                        }
                    }
                }

                foreach (MapElementType type in toBeRemoved)
                {
                    b.RemoveDepositedWorldObject(type, 1);
                }

                //throw new Exception("Two food items should be available to make a meal");
            }
            else
            {
                foreach (KeyValuePair<MapElementType, int> resource in obj.NeededForCrafting)
                {
                    for (int i = 0; i < resource.Value; i++)
                    {
                        b.RemoveDepositedWorldObject(resource.Key, obj.Level);
                    }
                }
            }
        }
Пример #18
0
 public void DestroyBuildingNow(Building b)
 {
     b.RemoveFromMap();
     _buildings.Remove(b);
 }
Пример #19
0
        public static bool IsAlradyHavingCraftingSlotDepoted(Building b)
        {
            if (_tasks.ContainsKey(TaskType.MoveCraftedResource) == false)
            {
                return false;
            }

            foreach (Task t in _tasks[TaskType.MoveCraftedResource])
            {
                MoveCraftedResourceToDepotTask mct = (MoveCraftedResourceToDepotTask)t;

                if (mct.CraftBuilding == b)
                    return true;
            }

            foreach (Task t in _tasksInProgress[TaskType.MoveCraftedResource])
            {
                MoveCraftedResourceToDepotTask gbt = (MoveCraftedResourceToDepotTask)t;

                if (gbt.CraftBuilding == b)
                {
                    return true;
                }
            }

            return false;
        }
Пример #20
0
 public void PlaceCoalPower()
 {
     _buildingToPlace = new CoalPowerGenerator(new Vector3Int(0, 0, 0), 0);
 }
Пример #21
0
 public void PlaceCarpenter()
 {
     _buildingToPlace = new CarpenterWorkshop(new Vector3Int(0, 0, 0), 0);
 }
Пример #22
0
 public void PlaceBrewery()
 {
     _buildingToPlace = new Brewery(new Vector3Int(0, 0, 0), 0);
 }
Пример #23
0
        public static bool IsAlreadyGettingNecessaryBuildingMaterials(Building b, WorldObject obj)
        {
            if (_tasks.ContainsKey(TaskType.GetBuildingMaterial) == false)
                return false;

            foreach (Task t in _tasks[TaskType.GetBuildingMaterial])
            {
                GetBuildingMaterialTask gbt = (GetBuildingMaterialTask)t;

                if (gbt.Building == b)
                {
                    return true;
                }
            }

            foreach (Task t in _tasksInProgress[TaskType.GetBuildingMaterial])
            {
                GetBuildingMaterialTask gbt = (GetBuildingMaterialTask)t;

                if (gbt.Building == b)
                {
                    return true;
                }
            }

            //if (numberFound == obj.NeededForCrafting.Count)
            //    return true;
            return false;
        }
Пример #24
0
 public void PlaceFurnis()
 {
     _buildingToPlace = new Furnace(new Vector3Int(0, 0, 0), 0);
 }
Пример #25
0
 public void AddBuilding(Building building)
 {
     _buildings.Add(building);
     building.PlaceOnMap();
 }
Пример #26
0
 public void PlaceKitchen()
 {
     _buildingToPlace = new Kitchen(new Vector3Int(0, 0, 0), 0);
 }
Пример #27
0
 public BuildBuildingTask(Building b)
 {
     Building = b;
     TaskType = TaskType.BuildBuilding;
     RegisterTask();
 }
Пример #28
0
 public void PlaceMason()
 {
     _buildingToPlace = new MasonWorkshop(new Vector3Int(0, 0, 0), 0);
 }
Пример #29
0
        private bool DoesBuildingHaveNecessaryMaterialsForCrafting(Building b, WorldObject obj)
        {
            bool does = true;
            bool haveRequested = TaskManager.IsAlreadyGettingNecessaryBuildingMaterials(b, obj);

            int counter = 0;

            if (obj.ElementType == MapElementType.Meal)
            {
                // If the building has some kind of food depsited, we have enough materials to make a meal
                foreach (KeyValuePair<MapElementType, List<WorldObject>> keyValue in b.DepositedWorldObjects)
                {
                    foreach (WorldObject depobj in keyValue.Value)
                    {
                        if (depobj.GetType().IsSubclassOf(typeof(Food)))
                        {
                            return true;
                        }
                    }
                }

                return false;
            }
            else
            {
                foreach (KeyValuePair<MapElementType, int> materials in obj.NeededForCrafting)
                {
                    // If the building does not contains the material needed, request a delivery
                    if (b.DepositedWorldObjects.ContainsKey(materials.Key) == false)
                    {
                        // Multiple instances of the material may be needed
                        for (int i = 0; i < materials.Value; i++)
                        {
                            if (haveRequested == false)
                            {
                                // Request a delivery of the material
                                TaskManager.AddTask(new GetBuildingMaterialTask(materials.Key, obj.Level, b));
                                counter++;
                            }
                            does = false;
                        }
                    }
                    // Else, if the building does contain the material, does it contain enough?
                    else
                    {
                        // Request the missing material instaces, if any
                        for (int i = 0; i < materials.Value - b.GetNumberOfDepositedMaterial(materials.Key, obj.Level); i++)
                        {
                            if (haveRequested == false)
                            {
                                TaskManager.AddTask(new GetBuildingMaterialTask(materials.Key, obj.Level, b));
                                counter++;
                            }
                            does = false;
                        }
                    }
                }
            }

            if (counter == 1)
            {

            }

            return does;
        }
Пример #30
0
 public void PlaceSawmill()
 {
     _buildingToPlace = new Sawmill(new Vector3Int(0, 0, 0), 0);
 }