Exemple #1
0
    private void WithdrawFrom(AdjacencyMask direction)
    {
        PathNode neighbor = TraverseConnection(direction);

        if (neighbor != null)
        {
            neighbor.SetConnection(Reverse(direction), null);
        }
    }
Exemple #2
0
    private PathNode TraverseConnection(AdjacencyMask direction)
    {
        PathNode node;

        if (!connectionDictionary.TryGetValue(direction, out node))
        {
            return(null);
        }
        return(node);
    }
Exemple #3
0
    public void SetConnection(AdjacencyMask direction, PathNode connection)
    {
        if (connection != null)
        {
            adjacencies |= direction;
        }
        else
        {
            adjacencies &= ~direction;
        }

        connectionDictionary[direction] = connection;
        UpdateVisual();
    }
Exemple #4
0
    private AdjacencyMask Reverse(AdjacencyMask dir)
    {
        switch (dir)
        {
        case AdjacencyMask.north:
            dir = AdjacencyMask.south;
            break;

        case AdjacencyMask.south:
            dir = AdjacencyMask.north;
            break;

        case AdjacencyMask.east:
            dir = AdjacencyMask.west;
            break;

        case AdjacencyMask.west:
            dir = AdjacencyMask.east;
            break;
        }

        return(dir);
    }
Exemple #5
0
 private void UpdateVisual(AdjacencyMask direction)
 {
     meshDictionary[direction].SetActive((adjacencies & direction) != 0);
 }