Esempio n. 1
0
        /// <summary>Get cost of moving to this node from the supplied other node</summary>
        /// <typeparam name="T">Content type of other node, must derive from IMapNode</typeparam>
        /// <param name="from">Other node to move from</param>
        /// <returns>Total cost of movement, or +Infinity on invalid move</returns>
        public double CalcMoveCost <T>(PFState <T> from)
            where T : class, IMapNode, new()
        {
            if (!from.Visited)
            {
                return(double.PositiveInfinity);
            }
            MapDirection dir  = DirectionFrom(from);
            double       mult = dir.IsOrthogonal() ? 1 : 1.5;

            return(from.TotalCost + MoveCost * mult);
        }