public override Selector ActivateBehavior(Dwarf d)
 {
     DwarfConsole.WriteLine("Move crafted", ConsoleColor.Red);
     d.SetActionBuilding(CraftBuilding);
     d.SetActionWorldObject(Obj);
     return new MoveCraftToDepot(CraftBuilding);
 }
 public override Selector ActivateBehavior(Dwarf d)
 {
     d.SetActionBuilding(GeneratorBuilding);
     d.SetActionLevel(1);
     d.SetActionMapElementType(Map.MapElementType.Coal);
     return new GetCoal();
 }
Пример #3
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionBuilding(Tower);
            d.SetActionTower(Tower);

            return new MoveToTower();
        }
Пример #4
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionMapElementType(Type);
            d.SetActionBuilding(Building);
            d.SetActionLevel(Level);

            return new GetBuildingMaterial(Building, this);
        }
 private TaskState Pickup(Dwarf d, float dt)
 {
     WorldObject m = d.GetActionbuilding().WithdrawWorldObject(d.GetActionMapElementType(), d.GetActionLevel());
     if (m == null)
         return TaskState.Fail;
     d.CarryWorldObject(m);
     d.SetActionBuilding(d.GetPrevActionBuilding());
     return TaskState.Success;
 }
        private TaskState FindPath(Dwarf d, float dt)
        {
            if (State == TaskState.NotActive)
            {
                List<Building> craftingBuildings = WorldMap.Instance.GetCraftingBuildings(d.GetActionMapElementType());

                if (d.GetActionMapElementType() == MapElementType.Arrow)
                {

                }

                foreach (Building b in craftingBuildings)
                {
                    if (_cot.AssignedWorkshop != null && b != _cot.AssignedWorkshop)
                        continue;

                    if (b.IsCraftingItem() == false ||
                        //b.IsTakenByDwarf(d, d.GetActionMapElementType()) == true ||
                        (b.IsCraftingItem() == true && b.HasADwarfWorkingOnItem() == false && b.TypeThatIsBeingCrafted() == d.GetActionMapElementType()))
                    {
                        AsyncPathfinding.RequestPathfinding(d, new Point((int)d.Position.X, (int)d.Position.Y), b.GetActivationPoint(), b);
                        _numerOfPaths++;

                    }
                    else
                        continue;
                }

                // If no crafting building that can be used
                if (_numerOfPaths == 0)
                {
                    return TaskState.Fail;
                }

            }

            _paths.AddRange(AsyncPathfinding.GetFinishedPathsWithData(d));

            if (_numerOfPaths != _paths.Count)
                return TaskState.Running;

            PathfindingResult shortestPath = Path.ShortestPath(_paths);

            Building bb = (Building)shortestPath.Data;

            // If the crafting building was taken by another dwarf while we where calculating paths.
            if (bb.HasADwarfWorkingOnItem() == true)
                return TaskState.SmallFail;

            d.SetActionBuilding(bb);
            d.SetMovePath(shortestPath.Path);
            d.GetActionbuilding().TakeForCrafting(d, d.GetActionMapElementType());
            _cot.AssignedWorkshop = d.GetActionbuilding();

            return TaskState.Success;
        }
        private TaskState FindDepot(Dwarf d, float dt)
        {
            if (State == TaskState.NotActive)
            {
                List<BuildingRequest> depoesCandidates = new List<BuildingRequest>();

                List<Building> depos = WorldMap.Instance.GetDepos(d.GetActionMapElementType(), d.GetActionLevel());
                foreach (Building b in depos)
                {
                    depoesCandidates.Add(new BuildingRequest() { Building = b, TypeToGet = d.GetActionMapElementType(), Level = d.GetActionLevel() });
                }

                // If no depot exist that has the required materials, the behavier fails
                if (depoesCandidates.Count == 0)
                {
                    if (_pwo == null)
                        return TaskState.Fail;

                    if (_pwo.HasRequestedConstructionOfNeededItem == true)
                        return TaskState.Fail;

                    TaskManager.AddTask(new CraftingOfResourceTask(d.GetActionMapElementType(), d.GetActionLevel()));
                    _pwo.HasRequestedConstructionOfNeededItem = true;

                    return TaskState.Fail;
                }

                foreach (BuildingRequest b in depoesCandidates)
                {
                    AsyncPathfinding.RequestPathfinding(d, new Point((int)d.Position.X, (int)d.Position.Y), b.Building.GetActivationPoint(), b);
                    _numerOfPaths++;
                }
            }

            _paths.AddRange(AsyncPathfinding.GetFinishedPathsWithData(d));

            if (_paths.Count > _numerOfPaths)
            {

            }

            if (_numerOfPaths != _paths.Count)
                return TaskState.Running;

            PathfindingResult shortestPath = Path.ShortestPath(_paths);

            d.SetActionBuilding(((BuildingRequest)shortestPath.Data).Building);
            d.SetActionMapElementType(((BuildingRequest)shortestPath.Data).TypeToGet);
            d.SetActionLevel(((BuildingRequest)shortestPath.Data).Level);
            d.SetMovePath(shortestPath.Path);

            return TaskState.Success;
        }
Пример #8
0
        private TaskState FindDepot(Dwarf d, float dt)
        {
            if (State == TaskState.NotActive)
            {
                List<BuildingRequest> depoesCandidates = new List<BuildingRequest>();

                List<Building> depos = WorldMap.Instance.GetDeposWithTool();
                foreach (Building b in depos)
                {
                    depoesCandidates.Add(new BuildingRequest() { Building = b, TypeToGet = MapElementType.None, Level = 1 });
                }

                // If no depot exist that has the required food, the behavier fails
                if (depoesCandidates.Count == 0)
                {
                    return TaskState.PersonalFail;
                }

                foreach (BuildingRequest b in depoesCandidates)
                {
                    AsyncPathfinding.RequestPathfinding(d, new Point((int)d.Position.X, (int)d.Position.Y), b.Building.GetActivationPoint(), b);
                    _numerOfPaths++;
                }
            }

            _paths.AddRange(AsyncPathfinding.GetFinishedPathsWithData(d));

            if (_paths.Count > _numerOfPaths)
            {

            }

            if (_numerOfPaths != _paths.Count)
                return TaskState.Running;

            PathfindingResult shortestPath = Path.ShortestPath(_paths);
            BuildingRequest br = (BuildingRequest)shortestPath.Data;

            d.SetActionBuilding(br.Building);
            d.SetMovePath(shortestPath.Path);

            return TaskState.Success;
        }
Пример #9
0
        private TaskState Find(Dwarf d, float dt)
        {
            List<Building> depots = WorldMap.Instance.GetBuildings(BuildingType.Depot);

            if (State == TaskState.NotActive)
            {
                if (depots.Count == 0)
                    return TaskState.Fail;

                foreach (Building b in depots)
                {
                    AsyncPathfinding.RequestPathfinding(d, new Point((int)d.Position.X, (int)d.Position.Y), b.GetActivationPoint(), null);
                    _numerOfPaths++;
                }
            }

            _paths.AddRange(AsyncPathfinding.GetFinishedPaths(d));

            if (_numerOfPaths != _paths.Count)
                return TaskState.Running;

            Path shortestPath = Path.ShortestPath(_paths);
            Building depot = null;

            foreach (Building b in depots)
            {
                Point p = b.GetActivationPoint();
                // TODO: This is bad. Use the object parameter on RequestPathfinding to solve
                if (p.X == shortestPath.GetEndPoint().X && p.Y == shortestPath.GetEndPoint().Y)
                {
                    depot = b;
                }
            }

            if (depot == null)
                throw new Exception("Depot not found.. It should be there");

            d.SetActionBuilding(depot);
            d.SetMovePath(shortestPath);

            return TaskState.Success;
        }
Пример #10
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionBuilding(WorldMap.Instance.GetTradingStation());

            return new MoveToTrader();
        }
Пример #11
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionBuilding(Building);

            return new BikeGeneration();
        }
Пример #12
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionBuilding(Building);

            return new BuildBuilding(Building, this);
        }
 private TaskState Set(Dwarf d, float dt)
 {
     d.SetActionBuilding(d.GetActionTower());
     return TaskState.Success;
 }
Пример #14
0
 public override Selector ActivateBehavior(Dwarf d)
 {
     d.SetActionBuilding(Building);
     return new MoveToFortress();
 }