Exemple #1
0
 private void AddJewel(int x, int yTarget, int yStart)
 {
     grid[x, yTarget] = new Jewel()
     {
         Position       = GetCellPosition(x, yStart),
         Parent         = this,
         TargetPosition = GetCellPosition(x, yTarget)
     };
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 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));
 }