Exemple #1
0
        private IntVector2[] ChooseRandomPositionsFromAvailableTiles(LinkedList <IntVector2> availableTiles,
                                                                     int numTilesToGenerate)
        {
            IntVector2[] tiles       = new IntVector2[numTilesToGenerate];
            int          chosenTiles = 0;
            float        randomNumber;

            for (int i = 0; i < kMaxTries; i++)
            {
                if (chosenTiles == numTilesToGenerate)
                {
                    break;
                }

                foreach (var tile in availableTiles)
                {
                    randomNumber = _randomProvider.GetRandomFloatInRange(0, 1);
                    if (randomNumber <= kTileChooseProbability)
                    {
                        tiles[chosenTiles] = tile;
                        chosenTiles++;
                        availableTiles.Remove(tile);
                        break;
                    }
                }
            }

            return(tiles);
        }