private NodeIndex AlwaysRightBehaviour() { 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); } //Tries to move to the back newNodeIndex = NodeDirectionUtilities.GetBackDirectionOfNode(aiBehaviour.nodeTable.GetCurrentNodeIndex(), aiBehaviour.GetFacingDirection()); if (aiBehaviour.nodeTable.CheckNodesConnection(aiBehaviour.nodeTable.GetCurrentNodeIndex(), newNodeIndex)) { return(newNodeIndex); } Debug.LogError("Direction calculation is wrong. Didnt find any"); return(newNodeIndex); }
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); }