Exemplo n.º 1
0
        private MovementPath getPath(Map Map, List <int> pathCell)
        {
            pathCell.Reverse();
            MovementPath Path    = new MovementPath();
            int          current = 0;
            int          child   = 0;
            int          PMUsed  = 0;

            if (pathCell.Count > 1)
            {
                Path.AddCell(pathCell[0], Pathfinder.GetDirection(Map, pathCell[0], pathCell[1]));
            }
            for (int i = 0; i <= pathCell.Count - 2; i++)
            {
                PMUsed++;
                if ((PMUsed > nombreDePM))
                {
                    Path.MovementLength = nombreDePM;
                    return(Path);
                }
                current = pathCell[i];
                child   = pathCell[i + 1];
                Path.AddCell(child, Pathfinder.GetDirection(Map, current, child));
            }

            Path.MovementLength = PMUsed;

            return(Path);
        }
Exemplo n.º 2
0
        public static int IsValidLine(Fight Fight, Fighter Fighter, MovementPath Path, int BeginCell, int Direction, int EndCell)
        {
            var Length     = -1;
            var ActualCell = BeginCell;

            if (!Pathfinder.InLine(Fight.Map, BeginCell, EndCell))
            {
                return(Length);
            }

            Length = (int)GoalDistanceEstimate(Fight.Map, BeginCell, EndCell);

            Path.AddCell(ActualCell, Direction);

            for (int i = 0; i < Length; i++)
            {
                ActualCell = Pathfinder.NextCell(Fight.Map, ActualCell, Direction);

                Path.AddCell(ActualCell, Direction);

                Path.MovementLength++;

                if (Pathfinder.IsStopCell(Fighter.Fight, Fighter.Team, ActualCell, Fighter))
                {
                    return(-2);
                }
            }

            return(Length);
        }
Exemplo n.º 3
0
        public static MovementPath IsValidPath(Fight Fight, Fighter Fighter, int CurrentCell, string EncodedPath)
        {
            var DecodedPath = Pathfinder.DecodePath(Fight.Map, CurrentCell, EncodedPath);
            var FinalPath   = new MovementPath();

            var Index       = 0;
            int TransitCell = 0;

            do
            {
                TransitCell = DecodedPath.TransitCells[Index];

                var Length = Pathfinder.IsValidLine(Fight, Fighter, FinalPath, TransitCell, DecodedPath.GetDirection(TransitCell), DecodedPath.TransitCells[Index + 1]);
                if (Length == -1)
                {
                    return(null);
                }
                else if (Length == -2)
                {
                    break;
                }


                Index++;
            }while (TransitCell != DecodedPath.LastStep);

            return(FinalPath);
        }
Exemplo n.º 4
0
        public static MovementPath DecodePath(Map Map, int CurrentCell, string Path)
        {
            MovementPath MovementPath = new MovementPath();

            MovementPath.AddCell(CurrentCell, GetDirection(Map, CurrentCell, CellHelper.CellCharCodeToId(Path.Substring(1, 2))));

            for (int i = 0; i < Path.Length; i += 3)
            {
                int curCell = CellHelper.CellCharCodeToId(Path.Substring(i + 1, 2));
                int curDir  = CellHelper.HASH.IndexOf(Path[i]);

                MovementPath.AddCell(curCell, curDir);
            }

            return(MovementPath);
        }
Exemplo n.º 5
0
 public static String EncodePath(Map map, int CurrentCell, MovementPath DecodePath)
 {
     return(DecodePath.ToString());
 }