コード例 #1
0
        public void init(int maxRad, int people = 6)
        {
            players = people;
            int width = 2 * maxRad + 1;

            tiles = new SystemTile[width][];
            for (int i = 0; i <= 2 * maxRad; i++)
            {
                SystemTile[] row = new SystemTile[width];
                for (int j = 0; j <= 2 * maxRad; j++)
                {
                    row[j] = TilesetGenerator.GetBlankTile();
                }
                tiles[i] = row;
            }
            MaxRadius = maxRad;
        }
コード例 #2
0
        public void GenerateStandard(Shuffle shuffle, int rad, int players = 6)
        {
            List <SystemTile> tileset = new List <SystemTile>();
            int placeableTileCount    = 3 * rad * (rad + 1) - players;

            while (tileset.Count < placeableTileCount)
            {
                tileset.AddRange(TilesetGenerator.GetAllTiles());
            }

            shuffle.ShuffleList <SystemTile>(tileset);
            tileset = tileset.GetRange(0, placeableTileCount);
            connectWormholes(tileset);

            HSLocations = new List <Tuple <int, int> >();
            if (players == 6)
            {
                HSLocations.Add(new Tuple <int, int>(0, rad));
                HSLocations.Add(new Tuple <int, int>(0, 2 * rad));
                HSLocations.Add(new Tuple <int, int>(rad, 0));
                HSLocations.Add(new Tuple <int, int>(rad, 2 * rad));
                HSLocations.Add(new Tuple <int, int>(2 * rad, 0));
                HSLocations.Add(new Tuple <int, int>(2 * rad, rad));
            }

            for (int i = 1; i <= players; i++)
            {
                Tuple <int, int> tuple = HSLocations[i - 1];
                tiles[tuple.Item1][tuple.Item2].playerNum = i;
            }

            int width = 2 * rad + 1;
            int index = 0;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < width; y++)
                {
                    if (x + y >= rad && x + y <= 3 * rad && !(x == rad && y == rad))
                    {
                        if (tiles[x][y].playerNum == 0)
                        {
                            tiles[x][y] = tileset[index];
                            index++;
                        }
                    }
                    else if (x == rad && y == rad)
                    {
                        tiles[x][y] = TilesetGenerator.GetMecatol();
                    }
                    else
                    {
                        tiles[x][y].playerNum = -1;
                    }
                }
            }

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < width; y++)
                {
                    if (tiles[x][y].playerNum >= 0)
                    {
                        if (x < 2 * rad && tiles[x + 1][y].playerNum >= 0)
                        {
                            tiles[x][y].adjacent.Add(tiles[x + 1][y]);
                            tiles[x + 1][y].adjacent.Add(tiles[x][y]);
                        }
                        if (y < 2 * rad && tiles[x][y + 1].playerNum >= 0)
                        {
                            tiles[x][y].adjacent.Add(tiles[x][y + 1]);
                            tiles[x][y + 1].adjacent.Add(tiles[x][y]);
                        }
                        if (x < 2 * rad && y > 0 && tiles[x + 1][y - 1].playerNum >= 0)
                        {
                            tiles[x][y].adjacent.Add(tiles[x + 1][y - 1]);
                            tiles[x + 1][y - 1].adjacent.Add(tiles[x][y]);
                        }
                    }
                }
            }
        }