hasNeighbor() public method

public hasNeighbor ( NeighborLocation loc ) : System.Boolean
loc NeighborLocation
return System.Boolean
Esempio n. 1
0
File: Game.cs Progetto: arun21/Catan
        private void checkNeighbors(Tile currentTile, int widthCounter)
        {
            widthCounter++;
            for (int i = 0; i < 6; ++i)
            {
                int a = 0;
                a++;
                Debug.Assert(LandTileHeap.Count != 0);

                if (!currentTile.hasNeighbor((NeighborLocation)i))
                {
                    currentTile.addNeighbor(LandTileHeap.TakeAway(rand.Next() % LandTileHeap.Count), (NeighborLocation)i);
                    currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value.addNeighbor(currentTile, (NeighborLocation)((i + 3) % 6));
                    Tile tempTile = currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value;

                    for (int j = 0; j < i; ++j)
                    {
                        tempTile.addNeighbor(currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)j).Value, (NeighborLocation)(((j + 3) % 6) - 1));
                    }


                    if (widthCounter < 3)
                    {
                        checkNeighbors(tempTile, widthCounter);
                    }
                }
            }
        }
Esempio n. 2
0
        private void checkNeighbors(Tile currentTile, int widthCounter)
        {
            widthCounter++;
            for (int i = 0; i < 6; ++i)
            {
                int a = 0;
                a++;
                Debug.Assert(LandTileHeap.Count != 0);

                if (!currentTile.hasNeighbor((NeighborLocation)i))
                {
                    currentTile.addNeighbor(LandTileHeap.TakeAway(rand.Next() % LandTileHeap.Count), (NeighborLocation)i);
                    currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value.addNeighbor(currentTile, (NeighborLocation)((i + 3) % 6));
                    Tile tempTile = currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value;

                    for (int j = 0; j < i; ++j)
                        tempTile.addNeighbor(currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)j).Value, (NeighborLocation)(((j + 3) % 6) - 1));

                    if (widthCounter < 3)
                        checkNeighbors(tempTile, widthCounter);
                }
            }
        }