public override Selector ActivateBehavior(Dwarf d)
 {
     d.SetActionBuilding(GeneratorBuilding);
     d.SetActionLevel(1);
     d.SetActionMapElementType(Map.MapElementType.Coal);
     return new GetCoal();
 }
Ejemplo n.º 2
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionWorldObject(Crop);
            d.SetActionMapElement(WorldMap.Instance.GetMapElement(Crop.Position.X, Crop.Position.Y, Crop.Position.Z));
            d.SetActionMapElementType(Crop.ElementType);

            return new HarvestCrop();
        }
Ejemplo n.º 3
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionWorldObject(WorldObject);
            d.SetActionMapElementType(WorldObject.ElementType);
            d.SetActionLevel(WorldObject.Level);

            return new PlaceWorldObject(this);
        }
Ejemplo n.º 4
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionMapElementType(Type);
            d.SetActionBuilding(Building);
            d.SetActionLevel(Level);

            return new GetBuildingMaterial(Building, this);
        }
Ejemplo n.º 5
0
        public override Selector ActivateBehavior(Dwarf d)
        {
            d.SetActionMapElementType(Type);
            d.SetActionLevel(Level);

            return new CraftResource(this);
            //d.SetActionBuilding(Building);

            //return new BuildBuilding(Building);
        }
        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;
        }