示例#1
0
        /**
         * Gets a direction index towards another NodeData. Assumes other node is near this |deltaX + deltaY = 1|
         */
        public int GetDirectionTowards(NodeVO other)
        {
            if (other == null)
            {
                return(NodeVO.DIRECTION_INVALID_IDX);
            }

            if (other.pos.x == pos.x)
            {
                if (other.pos.y > pos.y)
                {
                    return(NodeVO.DIRECTION_UP_IDX);
                }
                else
                {
                    return(NodeVO.DIRECTION_DOWN_IDX);
                }
            }
            else
            {
                if (other.pos.x > pos.x)
                {
                    return(NodeVO.DIRECTION_RIGHT_IDX);
                }
                else
                {
                    return(NodeVO.DIRECTION_LEFT_IDX);
                }
            }
        }
示例#2
0
        /**
         * Gets the number of nodes between this and starting node. Use with caution, as it loops through all chain.
         */
        public uint GetDistance()
        {
            uint   distance = 0;
            NodeVO node     = previousNode;

            while (node != null)
            {
                distance++;
                node = node.previousNode;
            }

            return(distance);
        }