Example #1
0
        public static List <PositionNode> GetNextSteps(this Ship ship, PositionNode current)
        {
            PositionNode shipNode = new PositionNode(ship.pos, ship.rotation, ship.speed);

            List <PositionNode> path = new List <PositionNode>();

            int count = 0;

            while (current != null && !current.Equals(shipNode) && current.parent != null && count < 30)
            {
                path.Add(current);
                current = current.parent;
                count++;
            }

            if (count >= 30)
            {
                Console.Error.WriteLine("Can't find shipNode");
                return(null);
            }

            if (current != null && current.Equals(shipNode))
            {
                path.Reverse();
                return(path);
            }

            return(null);
        }