public TileBehavior(Tile parent) { _parent = parent; }
public Tile GenerateRandomTile() { Tile entity = null; if (_random.NextDouble() < ChanceSpecial1) { entity = new Special1Tile(GetTileScale()); } else { int tileIndex = _random.Next(_noTilesKinds); entity = new Tile(tileIndex, GetTileScale()); } return entity; }
public void PutTileAtPosition(Tile tile, int column, int row) { Point tilePosition = GetTilePosition(column, row); tile.X = tilePosition.X; tile.Y = tilePosition.Y; tile.BoardColumn = column; tile.BoardRow = row; Tiles[column, row] = tile; }
public List<Entity> GenerateRandomBoard(string tilesSpriteSheet, string[] tiles) { _noTilesKinds = tiles.Length; Tiles = new Tile[Columns, Rows]; List<Entity> entities = new List<Entity>(); for (int i = 0; i < Columns; i++) { for(int j = 0; j < Rows; j++) { Tile entity = GenerateRandomTile(); Point tilePosition = GetTilePosition(i, j); entity.X = tilePosition.X; entity.Y = tilePosition.Y; entity.BoardColumn = i; entity.BoardRow = j; Tiles[i,j] = entity; entities.Add(entity.Entity); } } List<Match> initialMatches = new List<Match>(); do { initialMatches = FindMatches(); foreach (Match m in initialMatches) { foreach (Tile tile in m.Tiles) { int tileIndex = _random.Next(tiles.Length); tile.Change(tileIndex); } } } while (initialMatches.Count != 0); return entities; }