Exemplo n.º 1
0
    public static int FindPath(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            ClientWorld     world;
            LuaObject.checkType <ClientWorld>(l, 2, out world);
            int start;
            LuaObject.checkType(l, 3, out start);
            int goal;
            LuaObject.checkType(l, 4, out goal);
            List <int> path;
            LuaObject.checkType <List <int> >(l, 5, out path);
            bool checkWaypointStatus;
            LuaObject.checkType(l, 6, out checkWaypointStatus);
            bool b = worldPathfinder.FindPath(world, start, goal, path, checkWaypointStatus);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 2
0
    public static int InitiatePathfind(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            worldPathfinder.InitiatePathfind();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 3
0
    public static int get_GoalNode(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, worldPathfinder.GoalNode);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 4
0
    public static int constructor(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder o = new WorldPathfinder();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, o);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 5
0
    public static int AllocatePathNode(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            WorldPathNode   o = worldPathfinder.AllocatePathNode();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, o);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 6
0
    public static int HasStartNode(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            bool            b = worldPathfinder.HasStartNode();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 7
0
    public static int GetSolutionNext(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            WorldPathNode   solutionNext    = worldPathfinder.GetSolutionNext();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, solutionNext);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 8
0
    public static int SearchStep(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder             worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            WorldPathfinder.SearchState e = worldPathfinder.SearchStep();
            LuaObject.pushValue(l, true);
            LuaObject.pushEnum(l, (int)e);
            result = 2;
        }
        catch (Exception e2)
        {
            result = LuaObject.error(l, e2);
        }
        return(result);
    }
Exemplo n.º 9
0
    public static int AddSuccessor(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            WorldPathNode   state;
            LuaObject.checkType <WorldPathNode>(l, 2, out state);
            worldPathfinder.AddSuccessor(state);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 10
0
    public static int CanMoveToWaypoint(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            int             id;
            LuaObject.checkType(l, 2, out id);
            bool b = worldPathfinder.CanMoveToWaypoint(id);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 11
0
    public static int SetStartAndGoalStates(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            WorldPathNode   start;
            LuaObject.checkType <WorldPathNode>(l, 2, out start);
            WorldPathNode goal;
            LuaObject.checkType <WorldPathNode>(l, 3, out goal);
            worldPathfinder.SetStartAndGoalStates(start, goal);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 12
0
        public void Init(int mapId)
        {
            MapId = mapId;

            var tmp = MapsManager.FromId(MapId);

            tmp.Cells.ForEachWithIndex((cellData, index) =>
            {
                var cell  = GetCell(index);
                cell.Text = cell.Id.ToString();
                if (cellData.Los)
                {
                    cell.State = CellState.NonWalkable;
                }
                if (cellData.Mov)
                {
                    cell.State = CellState.Walkable;
                }
            });
            Invalidate();

            WPath = new WorldPathfinder(MapsManager.FromId(MapId), this);
        }
Exemplo n.º 13
0
        public void CanPathFromWorldList()
        {
            var start = "A";
            var end   = "D";

            var world    = ExampleWorld.Sample();
            var traveler = new Traveler();

            var got = WorldPathfinder.FindWorldPathToZone(world, start, end);

            var want = new List <Zone>
            {
                world.GetZoneByName("A"),
                world.GetZoneByName("C"),
                world.GetZoneByName("D")
            };

            Assert.Equal(want.Count, got.Count);
            for (var i = 0; i < want.Count; i++)
            {
                Assert.Equal(want[i].Name, got[i].Name);
            }
        }
Exemplo n.º 14
0
    public static int GetWaypoint(IntPtr l)
    {
        int result;

        try
        {
            WorldPathfinder worldPathfinder = (WorldPathfinder)LuaObject.checkSelf(l);
            int             id;
            LuaObject.checkType(l, 2, out id);
            ConfigDataWaypointInfo o;
            Vector2 o2;
            bool    waypoint = worldPathfinder.GetWaypoint(id, out o, out o2);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, waypoint);
            LuaObject.pushValue(l, o);
            LuaObject.pushValue(l, o2);
            result = 4;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }