public void Update(Match matchMade) { if (TileIndex == matchMade.Tiles[0].Index) { AmountLeft -= matchMade.Tiles.Count; } }
public void UpdateObjectives(Match match) { StringBuilder sb = new StringBuilder("\n"); foreach (Objective objective in _objectives) { objective.Update(match); if (!objective.IsMet()) { sb.AppendFormat("{0} - {1}\n", objective.Name, objective.AmountLeft); } } text.Text = sb.ToString(); }
public List<Match> FindMatches() { int skipTiles = 0; List<Match> matchesFound = new List<Match>(); for (int j = 0; j < Rows; j++) { for (int i = 0; i < Columns - 2; i++) { if (Tiles[i, j].Index == 5) { continue; } if (Tiles[i, j].Matched) { continue; } if ((Tiles[i, j].Index == Tiles[i + 1, j].Index) && (Tiles[i, j].Index == Tiles[i + 2, j].Index) && !Tiles[i +1, j].Matched && !Tiles[i+2, j].Matched) { if (skipTiles != 0) { skipTiles--; continue; } Match newMatch = new Match { Tiles = new List<Tile>() { Tiles[i, j], Tiles[i + 1, j], Tiles[i + 2, j] } }; if (i + 3 < Columns && (Tiles[i, j].Index == Tiles[i + 3, j].Index) && !Tiles[i+3, j].Matched) { newMatch.Tiles.Add(Tiles[i + 3, j]); skipTiles = 1; if (i + 4 < Rows && (Tiles[i, j].Index == Tiles[i + 4, j].Index) && !Tiles[i+4, j].Matched) { newMatch.Tiles.Add(Tiles[i + 4, j]); skipTiles = 2; } } matchesFound.Add(newMatch); } } } for (int i = 0; i < Columns; i++) { for (int j = 0; j < Rows - 2; j++) { if (Tiles[i, j].Index == 5) { continue; } if (Tiles[i, j].Matched) { continue; } if (skipTiles != 0) { skipTiles--; continue; } if ((Tiles[i, j].Index == Tiles[i, j + 1].Index) && (Tiles[i, j].Index == Tiles[i, j + 2].Index) && !Tiles[i, j+1].Matched && !Tiles[i, j+2].Matched) { Match newMatch = new Match { Tiles = new List<Tile>() { Tiles[i, j], Tiles[i, j + 1], Tiles[i, j + 2] } }; if (j + 3 < Rows && (Tiles[i, j].Index == Tiles[i, j + 3].Index) && !Tiles[i, j+3].Matched) { newMatch.Tiles.Add(Tiles[i, j + 3]); skipTiles = 1; if (j + 4 < Rows && (Tiles[i, j].Index == Tiles[i, j + 4].Index) && !Tiles[i, j+4].Matched) { newMatch.Tiles.Add(Tiles[i, j + 4]); skipTiles = 2; } } matchesFound.Add(newMatch); } } } return matchesFound; }