private static void ChangeGemInBlastRadius(FieldCell fieldCell) { if (fieldCell.Gem != null && (fieldCell.Gem.Type == GemType.Bomb || fieldCell.Gem.Type == GemType.HorizontalLine || fieldCell.Gem.Type == GemType.VerticalLine)) { fieldCell.Gem.WasMoved = true; } else { GemsController.DeleteGem(fieldCell); } }
public static FieldCell GenerateNewFieldCell(int column, int row, Random random, EventHandler onClick) { var cell = new FieldCell { Id = (column + 1) + 8 * row, Column = column, Row = row, Position = new Vector2(DefaultCell.Width * column, DefaultCell.Height * 2 + DefaultCell.Height * row), Texture = TextureController.GetTexture(BackgroundType.Ground.SpritePath()) }; cell.Click += onClick; var type = (GemType)random.Next(1, 6); cell.Gem = GemsController.GetNewGem(cell.Position, type); return(cell); }
private static void SetCoincidenceResults(List <List <FieldCell> > list, DirectionType type) { foreach (var element in list) { if (element.Count > 2 && element.Count < 4) { GemsController.DeleteGems(element); } else if (element.Count > 3 && element.Count < 5) { var gemType = type == DirectionType.Horizontal ? GemType.HorizontalLine : GemType.VerticalLine; AddNewBonus(element, gemType); } else if (element.Count > 4) { AddNewBonus(element, GemType.Bomb); } } }
private static void AddNewBonus(List <FieldCell> element, GemType gemType) { FieldCell bonus = null; if (GameState.Move != null && GameState.Move.FirstCell != null && element.Contains(GameState.Move.FirstCell)) { bonus = GameState.Move.FirstCell; } if (GameState.Move != null && GameState.Move.SecondCell != null && element.Contains(GameState.Move.SecondCell)) { bonus = GameState.Move.SecondCell; } bonus = bonus ?? element.Last(); bonus.Gem = GemsController.GetNewGem(bonus.Position, gemType); element.Remove(bonus); GemsController.DeleteGems(element); }