private void AddJewel(int x, int yTarget, int yStart) { grid[x, yTarget] = new Jewel() { Position = GetCellPosition(x, yStart), Parent = this, TargetPosition = GetCellPosition(x, yTarget) }; }
public void ShiftRowRight(int selectedRow) { // Store the right most Jewel for backup Jewel first = grid[Width - 1, selectedRow]; // replace all the Jewel with their left neighbour for (int x = Width - 1; x > 0; x--) { grid[x, selectedRow] = grid[x - 1, selectedRow]; grid[x, selectedRow].TargetPosition = GetCellPosition(x, selectedRow); } // Replace the left most jewel with the backup grid[0, selectedRow] = first; grid[0, selectedRow].Position = GetCellPosition(-1, selectedRow); grid[0, selectedRow].TargetPosition = GetCellPosition(0, selectedRow); }
public void ShiftRowLeft(int selectedRow) { // Store the left most Jewel for backup Jewel first = grid[0, selectedRow]; // Replace all the Jewels with their right neighbour for (int x = 0; x < Width - 1; x++) { grid[x, selectedRow] = grid[x + 1, selectedRow]; grid[x, selectedRow].TargetPosition = GetCellPosition(x, selectedRow); } // Re-insert the backup Jewel in the Right most spot grid[Width - 1, selectedRow] = first; grid[Width - 1, selectedRow].Position = GetCellPosition(Width, selectedRow); grid[Width - 1, selectedRow].TargetPosition = GetCellPosition(Width - 1, selectedRow); }
private bool IsValidCombination(Jewel a, Jewel b, Jewel c) { return(IsConditionValid(a.ShapeType, b.ShapeType, c.ShapeType) && IsConditionValid(a.ColorType, b.ColorType, c.ColorType) && IsConditionValid(a.NumberType, b.NumberType, c.NumberType)); }