Exemple #1
0
        public override void Execute()
        {
            if (BackgroundGame.MapSpace.Test(destination))
            {
                List <Point2D> currentPositions = new List <Point2D>(caller.Length);

                foreach (uint id in caller)
                {
                    InteractiveObject iobj = BackgroundGame.IntObjs.Find((o) => o.id == id);
                    if (iobj != null)
                    {
                        currentPositions.Add(iobj.Position.ToPoint2D());
                    }
                    else
                    {
                        throw new Exception("Could not find InteractiveObject with ID = " + id + "\nThe IObj probably doesn't exist no more.");
                    }
                }

                flowfield = BackgroundGame.MapSpace.FindPath(currentPositions, destination.ToPoint2D());

                foreach (uint id in caller)
                {
                    InteractiveObject iobj = BackgroundGame.IntObjs.Find((o) => o.id == id);
                    if (iobj != null)
                    {
                        iobj.Order(this);
                    }
                    else
                    {
                        throw new Exception("Could not find InteractiveObject with ID = " + id + "\nThe IObj probably doesn't exist no more.");
                    }
                }
            }
        }
Exemple #2
0
        public void Move(Order_Move order)
        {
            FVector2 cur2D     = BackgroundGame.MapSpace.WorldToSpace(parent.Position);
            int      id        = cur2D.X.ToInt() + cur2D.Y.ToInt() * BackgroundGame.MapSpace.Width;
            byte     direction = order.flowfield == null ? (byte)0 : ((id >= 0 && id < order.flowfield.Length) ? order.flowfield.Get(id) : (byte)0);

            if (direction != 0 && direction != 1)
            {
                active        = true;
                reached       = false;
                start         = parent.Position;
                dest          = order.destination;
                flowfield     = order.flowfield;
                parent.Moving = true;
                unreachable   = false;
            }
            else
            {
                active        = false;
                reached       = false;
                unreachable   = true;
                start         = parent.Position;
                dest          = parent.Position;
                parent.Moving = false;
            }
        }
Exemple #3
0
 public AddToPathJob(WorldArea area, Tile tile, FlowFieldPath path, Pathfinder pathfinder)
 {
     _path       = path;
     _area       = area;
     _tile       = tile;
     _pathfinder = pathfinder;
 }