private bool DoesBuildingHaveNecessaryMaterialsForCrafting(Building b, WorldObject obj)
        {
            bool does = true;
            bool haveRequested = TaskManager.IsAlreadyGettingNecessaryBuildingMaterials(b, obj);

            int counter = 0;

            if (obj.ElementType == MapElementType.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 (b.DepositedWorldObjects.ContainsKey(materials.Key) == false)
                    {
                        for (int i = 0; i < materials.Value; i++)
                        {
                            if (haveRequested == false)
                            {
                                TaskManager.AddTask(new GetBuildingMaterialTask(materials.Key, obj.Level, b));
                                counter++;
                            }
                            does = false;
                        }
                    }
                    else
                    {
                        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;
        }
 public MoveCraftedResourceToDepotTask(Building craftBuilding, WorldObject obj)
 {
     DwarfConsole.WriteLine("Move crafted", ConsoleColor.Red);
     CraftBuilding = craftBuilding;
     Obj = obj;
     TaskType = Tasks.TaskType.MoveCraftedResource;
 }
Ejemplo n.º 3
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());
 }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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());
 }
Ejemplo n.º 6
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());
 }
Ejemplo n.º 7
0
        private void Input()
        {
            if (KeyboardInput.IsKeyClicked(Keys.P))
            {
                _buildingToPlace = new Sawmill(new Vector3Int(0, 0, 0), 0);
            }
            if (KeyboardInput.IsKeyClicked(Keys.O))
            {
                _buildingToPlace = new Depot(new Vector3Int(0, 0, 0), 0);
            }
            if (KeyboardInput.IsKeyClicked(Keys.I))
            {
                _buildingToPlace = new CarpenterWorkshop(new Vector3Int(0, 0, 0), 0);
            }
            if (KeyboardInput.IsKeyClicked(Keys.U))
                _buildingToPlace = new MasonWorkshop(new Vector3Int(0, 0, 0), 0);
            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();
            }
        }
Ejemplo n.º 8
0
        public GetBuildingMaterialTask(MapElementType obj, int level, Building building)
        {
            Building = building;
            Type = obj;
            Level = level;
            if (Type == MapElementType.Stone)
            {

            }
            TaskType = TaskType.GetBuildingMaterial;
        }
        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;
        }
Ejemplo n.º 10
0
 public void DestroyBuildingNow(Building b)
 {
     b.RemoveFromMap();
     _buildings.Remove(b);
 }
Ejemplo n.º 11
0
 public BikeGenerationTask(Building b)
 {
     Building = b;
     TaskType = Tasks.TaskType.BikeGeneration;
 }
Ejemplo n.º 12
0
 private void CancelBuilding()
 {
     _buildingToPlace = null;
 }
Ejemplo n.º 13
0
 private void PlaceBuilding()
 {
     _buildingToPlace.Position = new Vector3Int(_highlightedCell.X, _highlightedCell.Y, _highlightedCell.Z - 1);
     WorldMap.Instance.AddBuilding(_buildingToPlace);
     _buildingToPlace = null;
 }
Ejemplo n.º 14
0
 public void SetActionBuilding(Building b)
 {
     _actionBuilding = b;
 }
Ejemplo n.º 15
0
 public MoveToFortressTask(Building b)
 {
     Building = b;
 }
Ejemplo n.º 16
0
 public BuildBuildingTask(Building b)
 {
     Building = b;
     TaskType = TaskType.BuildBuilding;
 }
Ejemplo n.º 17
0
 private void RemoveUsedResources(Building b, WorldObject obj)
 {
     if (obj.ElementType == MapElementType.Meal)
     {
         foreach (KeyValuePair<MapElementType, List<WorldObject>> keyValue in b.DepositedWorldObjects)
         {
             foreach (WorldObject depobj in keyValue.Value)
             {
                 if (depobj.GetType().IsSubclassOf(typeof(Food)))
                 {
                     b.RemoveDepositedWorldObject(depobj.ElementType, depobj.Level);
                     return;
                 }
             }
         }
     }
     else
     {
         foreach (KeyValuePair<MapElementType, int> resource in obj.NeededForCrafting)
         {
             for (int i = 0; i < resource.Value; i++)
             {
                 b.RemoveDepositedWorldObject(resource.Key, obj.Level);
             }
         }
     }
 }
Ejemplo n.º 18
0
 public void AddBuilding(Building building)
 {
     _buildings.Add(building);
     building.PlaceOnMap();
 }
Ejemplo n.º 19
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;
        }
Ejemplo n.º 20
0
 public void SetActionBuilding(Building b)
 {
     _prevActionBuilding = _actionBuilding;
     _actionBuilding = b;
 }
 public GetCoalForPowerGeneratorTask(Building generatorBuilding)
 {
     GeneratorBuilding = generatorBuilding;
     TaskType = Tasks.TaskType.GetCoalForPowerGenerator;
 }
Ejemplo n.º 22
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;
        }