Ejemplo n.º 1
0
    private NodeIndex CheckNeighbourNonVisitedNodes()
    {
        NodeIndex newNodeIndex;

        //Tries to move to the right
        newNodeIndex = NodeDirectionUtilities.GetRightDirectionOfNode(aiBehaviour.nodeTable.GetCurrentNodeIndex(), aiBehaviour.GetFacingDirection());
        if (aiBehaviour.nodeTable.CheckNodesConnection(aiBehaviour.nodeTable.GetCurrentNodeIndex(), newNodeIndex))
        {
            return(newNodeIndex);
        }

        //Tries to move to the front
        newNodeIndex = NodeDirectionUtilities.GetFrontDirectionOfNode(aiBehaviour.nodeTable.GetCurrentNodeIndex(), aiBehaviour.GetFacingDirection());
        if (aiBehaviour.nodeTable.CheckNodesConnection(aiBehaviour.nodeTable.GetCurrentNodeIndex(), newNodeIndex))
        {
            return(newNodeIndex);
        }

        //Tries to move to the left
        newNodeIndex = NodeDirectionUtilities.GetLeftDirectionOfNode(aiBehaviour.nodeTable.GetCurrentNodeIndex(), aiBehaviour.GetFacingDirection());
        if (aiBehaviour.nodeTable.CheckNodesConnection(aiBehaviour.nodeTable.GetCurrentNodeIndex(), newNodeIndex))
        {
            return(newNodeIndex);
        }

        //Returns null if there is no elegible neighbour
        return(null);
    }