addNeighbor() public method

public addNeighbor ( Tile t, NeighborLocation loc ) : void
t Tile
loc NeighborLocation
return void
示例#1
0
文件: Game.cs 项目: 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);
                    }
                }
            }
        }
示例#2
0
文件: Game.cs 项目: wargamer/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);
                }
            }
        }