//Helper function for CreateTileSet private void AddTile(TileID.Suits suit, byte number, bool aka = false) { GameObject tileObj = Instantiate(TileBase); Tile tile = tileObj.GetComponent <Tile>(); tile.Set(suit, number, aka); tileObj.SetActive(true); allTiles.Add(tile); }
//*********************************************************************** //******************************* Shuffling ***************************** //*********************************************************************** //Shuffles the tile at the specified index into a random location over a range private void ShuffleTile(int index, int low, int high) { Tile placeholder = new Tile(); placeholder.SetOwner(_accessKey); placeholder.Set(TileID.Suits.Kaze, 0); Tile shuffling = Tiles[index]; //Use placeholder to not mess up the range Tiles[index] = placeholder; System.Random rnd = new System.Random(); int to = rnd.Next(low, high); Tiles.Insert(to, shuffling, _accessKey); Tiles.Remove(placeholder, _accessKey); }
//Performs an in-place swap of two tiles private void Swap2(int i, int j) { if (i == j) { return; } Tile placeholder = new Tile(); placeholder.SetOwner(_accessKey); placeholder.Set(TileID.Suits.Kaze, 0); Tile wasi = Tiles[i]; Tile wasj = Tiles[j]; Tiles[j] = placeholder; Tiles[i] = wasj; Tiles[j] = wasi; }