Beispiel #1
0
        private TaskState FindPath(Dwarf d, float dt)
        {
            if (State == TaskState.NotActive)
            {
                RequestPathfinding(d.GetActionMapElement(), d);
            }

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

            if (_paths.Count != _numberOfPathRequests)
                return TaskState.Running;
            else
            {
                Path shortest = Path.ShortestPath(_paths);

                if (shortest == null)
                    return TaskState.Fail;
                else
                {
                    d.SetMovePath(shortest);
                    return TaskState.Success;
                }

            }
        }
Beispiel #2
0
        private TaskState Damage(Dwarf d, float dt)
        {
            MapElement e = d.GetActionMapElement();

            if (e.DoDamage(DamageRules.DamageMapElement(e, d)))
                return TaskState.Success;
            else
                return TaskState.Running;
        }
        private TaskState Pickup(Dwarf d, float dt)
        {
            WorldObject me = d.GetActionWorldObject();

            //if ((int)d.Position.X != me.Position.X || (int)d.Position.Y != me.Position.Y)
            //    throw new Exception("Dwarf not in place");
            Console.WriteLine("Pickup: " + d.Id + " - " + d.GetActionWorldObject().Position.X + ", " + d.GetActionWorldObject().Position.Y);
            d.GetActionMapElement().RemoveFromMap();
            d.CarryWorldObject(d.GetActionWorldObject());
            return TaskState.Success;
        }