removeDots(dots , numberOfClosed, dotsScore) {
    if (dots.length === 0) return;

    let colorId = dots[0].colorId;

    let columnLowestRowChanged = {};

    // Remove dots and leave nulls where they were referenced
    dots.forEach((dot) => {
      if (dot!=null) {        
          if (columnLowestRowChanged[dot.column] === undefined || columnLowestRowChanged[dot.column] < dot.row) {
            columnLowestRowChanged[dot.column] = dot.row;
          };
          
          this.colorBuckets[dot.colorId][dot.indexInColorBucket] = null;
          this.grid[dot.row][dot.column].dot = null;
          
           //Alexandr + 28/03/2021
          var result = dotsScore.find(obj => {
              return obj.name === dot.name
           });
          
          if (result!=undefined) {              
            //console.log(dot.bonusFeature);  
            let pluspoints = 0;  
              
            if (dot.bonusFeature==0){  
                pluspoints+=1;
                this.scene.points   +=pluspoints;                 
            }else {
                pluspoints+=1;                
                pluspoints          += dot.bonusFeature;
                this.scene.points   += pluspoints;     
            };
              
            this.scene.createScoreAnimation(dot.x, dot.y, "+"+pluspoints);              
          };
          //Alexandr - 28/03/2021 
          //console.log(result);           
          
          //Alexander + 21/02/2021 - destroying animations    
          if(dot.bonusFeature>0){
             //console.log("bonus " + dot.bonusFeature); 
             dot.anims.stop();  
             dot.anims.remove(this.scene.anims.get('explode'+dot.bonusFeature)); 
             //console.log(dot.currentAnim);    
             this.scene.anims.create(this.scene.cfgbonus1);
             this.scene.anims.create(this.scene.cfgbonus2);
             this.scene.anims.create(this.scene.cfgbonus3);
             dot.bonusFeature = 0; 
             dot.setTexture("dot");
             //console.log(dot);
             this.scene.dotFruitDissapear.play();              
          }else{
              this.scene.dotFruitBonusDissapear.play(); 
          };
          //Alexander - 21/02/2021 
         
          dot.despawn();
      };
    });


    // Move dots downwards.
    Object.keys(columnLowestRowChanged).forEach((column) => {
      let lowestRowChanged = columnLowestRowChanged[column];
      column = Number(column);
      let remainingDots = [];

      for (let row = 0; row <= lowestRowChanged; row++) {
        let dot = this.grid[row][column].dot;
        if (dot) {
          remainingDots.push(dot);
        }
      }

      for (let row = lowestRowChanged; row >= 0; row--) {
        let cell = this.grid[row][column];
        if (remainingDots.length > 0) {
          let dot = remainingDots.pop();
          this.moveDotToRow(dot, dot.row, row);
          dot.setGridPosition(row, column);
          cell.dot = dot;
        }
        else {
          cell.dot = null;
        }
      }
    });

    // Remove nulls from color buckets
    let colorBucket = this.colorBuckets[colorId];
    let numDots     = 0;

    for (let i = 0; i < colorBucket.length; i++) {
      if (colorBucket[i] !== null) {
        colorBucket[numDots] = colorBucket[i];
        colorBucket[numDots].indexInColorBucket = numDots;
        numDots++;
      }
    }

    // Remove the nulls from the end
    this.colorBuckets[colorId] = colorBucket.slice(0, numDots);
    
    //Alexandr + 16/02/2021 - getting a bonus dot
    let bonus = 0;       
      
    if (numberOfClosed % 5 === 0) {
       bonus = 1; 
    }else if (numberOfClosed % 6 === 0) {
       bonus = 2; 
    }else if (numberOfClosed % 8 === 0) {
       bonus = 3; 
    }     
    //Alexandr - 16/02/2021  
      
    //console.log(bonus);  
      
    // REPLACE REMOVED CELLS ======================================================================

    this.grid.forEach((row, r) => {
      let delay = 300 + (r / this.numRows) * 700;
      this.scene.time.delayedCall(delay, () => {
        row.forEach((cell, c) => {
          if (cell.dot === null) {          
            //Alexandr + 16/02/2021          
            cell.dot = this.addNewDot(cell.x, cell.y, bonus); //Alexandr + 16/02/2021
            cell.dot.setGridPosition(r, c);                 
            if (bonus > 0){  
              this.scene.createScoreAnimation(cell.dot.x, cell.dot.y, "Bonus Dot level " +bonus +"!");
              this.scene.BonusPickup.play();    
              bonus = 0;
            };              
            //Alexandr - 16/02/2021   
          }
        });
      }, []);
    });
  }
//Alexandr + 16/02/2021 - getting a number of closed points    
Alexandr + 16/02/2021 - getting a number of closed points
Alexandr + 16 / 02 / 2021 - getting a number of closed points
removeDots(dots , numberOfClosed, dotsScore) {
    if (dots.length === 0) return;
    let colorId = dots[0].colorId;
    let columnLowestRowChanged = {};
    dots.forEach((dot) => {
      if (dot!=null) {        
          if (columnLowestRowChanged[dot.column] === undefined || columnLowestRowChanged[dot.column] < dot.row) {
            columnLowestRowChanged[dot.column] = dot.row;
          };
          this.colorBuckets[dot.colorId][dot.indexInColorBucket] = null;
          this.grid[dot.row][dot.column].dot = null;
          var result = dotsScore.find(obj => {
              return obj.name === dot.name
           });
          if (result!=undefined) {              
            let pluspoints = 0;  
            if (dot.bonusFeature==0){  
                pluspoints+=1;
                this.scene.points   +=pluspoints;                 
            }else {
                pluspoints+=1;                
                pluspoints          += dot.bonusFeature;
                this.scene.points   += pluspoints;     
            };
            this.scene.createScoreAnimation(dot.x, dot.y, "+"+pluspoints);              
          };
          if(dot.bonusFeature>0){
             dot.anims.stop();  
             dot.anims.remove(this.scene.anims.get('explode'+dot.bonusFeature)); 
             this.scene.anims.create(this.scene.cfgbonus1);
             this.scene.anims.create(this.scene.cfgbonus2);
             this.scene.anims.create(this.scene.cfgbonus3);
             dot.bonusFeature = 0; 
             dot.setTexture("dot");
             this.scene.dotFruitDissapear.play();              
          }else{
              this.scene.dotFruitBonusDissapear.play(); 
          };
          dot.despawn();
      };
    });
    Object.keys(columnLowestRowChanged).forEach((column) => {
      let lowestRowChanged = columnLowestRowChanged[column];
      column = Number(column);
      let remainingDots = [];
      for (let row = 0; row <= lowestRowChanged; row++) {
        let dot = this.grid[row][column].dot;
        if (dot) {
          remainingDots.push(dot);
        }
      }
      for (let row = lowestRowChanged; row >= 0; row--) {
        let cell = this.grid[row][column];
        if (remainingDots.length > 0) {
          let dot = remainingDots.pop();
          this.moveDotToRow(dot, dot.row, row);
          dot.setGridPosition(row, column);
          cell.dot = dot;
        }
        else {
          cell.dot = null;
        }
      }
    });
    let colorBucket = this.colorBuckets[colorId];
    let numDots     = 0;
    for (let i = 0; i < colorBucket.length; i++) {
      if (colorBucket[i] !== null) {
        colorBucket[numDots] = colorBucket[i];
        colorBucket[numDots].indexInColorBucket = numDots;
        numDots++;
      }
    }
    this.colorBuckets[colorId] = colorBucket.slice(0, numDots);
    let bonus = 0;       
    if (numberOfClosed % 5 === 0) {
       bonus = 1; 
    }else if (numberOfClosed % 6 === 0) {
       bonus = 2; 
    }else if (numberOfClosed % 8 === 0) {
       bonus = 3; 
    }     
    this.grid.forEach((row, r) => {
      let delay = 300 + (r / this.numRows) * 700;
      this.scene.time.delayedCall(delay, () => {
        row.forEach((cell, c) => {
          if (cell.dot === null) {          
            cell.dot = this.addNewDot(cell.x, cell.y, bonus); 
            cell.dot.setGridPosition(r, c);                 
            if (bonus > 0){  
              this.scene.createScoreAnimation(cell.dot.x, cell.dot.y, "Bonus Dot level " +bonus +"!");
              this.scene.BonusPickup.play();    
              bonus = 0;
            };              
          }
        });
      }, []);
    });
  }
removeDots ( dots , numberOfClosed , dotsScore ) { if ( dots . length === 0 ) return ; let colorId = dots [ 0 ] . colorId ; let columnLowestRowChanged = { } ; dots . forEach ( ( dot ) => { if ( dot != null ) { if ( columnLowestRowChanged [ dot . column ] === undefined || columnLowestRowChanged [ dot . column ] < dot . row ) { columnLowestRowChanged [ dot . column ] = dot . row ; } ; this . colorBuckets [ dot . colorId ] [ dot . indexInColorBucket ] = null ; this . grid [ dot . row ] [ dot . column ] . dot = null ; var result = dotsScore . find ( obj => { return obj . name === dot . name } ) ; if ( result != undefined ) { let pluspoints = 0 ; if ( dot . bonusFeature == 0 ) { pluspoints += 1 ; this . scene . points += pluspoints ; } else { pluspoints += 1 ; pluspoints += dot . bonusFeature ; this . scene . points += pluspoints ; } ; this . scene . createScoreAnimation ( dot . x , dot . y , "+" + pluspoints ) ; } ; if ( dot . bonusFeature > 0 ) { dot . anims . stop ( ) ; dot . anims . remove ( this . scene . anims . get ( 'explode' + dot . bonusFeature ) ) ; this . scene . anims . create ( this . scene . cfgbonus1 ) ; this . scene . anims . create ( this . scene . cfgbonus2 ) ; this . scene . anims . create ( this . scene . cfgbonus3 ) ; dot . bonusFeature = 0 ; dot . setTexture ( "dot" ) ; this . scene . dotFruitDissapear . play ( ) ; } else { this . scene . dotFruitBonusDissapear . play ( ) ; } ; dot . despawn ( ) ; } ; } ) ; Object . keys ( columnLowestRowChanged ) . forEach ( ( column ) => { let lowestRowChanged = columnLowestRowChanged [ column ] ; column = Number ( column ) ; let remainingDots = [ ] ; for ( let row = 0 ; row <= lowestRowChanged ; row ++ ) { let dot = this . grid [ row ] [ column ] . dot ; if ( dot ) { remainingDots . push ( dot ) ; } } for ( let row = lowestRowChanged ; row >= 0 ; row -- ) { let cell = this . grid [ row ] [ column ] ; if ( remainingDots . length > 0 ) { let dot = remainingDots . pop ( ) ; this . moveDotToRow ( dot , dot . row , row ) ; dot . setGridPosition ( row , column ) ; cell . dot = dot ; } else { cell . dot = null ; } } } ) ; let colorBucket = this . colorBuckets [ colorId ] ; let numDots = 0 ; for ( let i = 0 ; i < colorBucket . length ; i ++ ) { if ( colorBucket [ i ] !== null ) { colorBucket [ numDots ] = colorBucket [ i ] ; colorBucket [ numDots ] . indexInColorBucket = numDots ; numDots ++ ; } } this . colorBuckets [ colorId ] = colorBucket . slice ( 0 , numDots ) ; let bonus = 0 ; if ( numberOfClosed % 5 === 0 ) { bonus = 1 ; } else if ( numberOfClosed % 6 === 0 ) { bonus = 2 ; } else if ( numberOfClosed % 8 === 0 ) { bonus = 3 ; } this . grid . forEach ( ( row , r ) => { let delay = 300 + ( r / this . numRows ) * 700 ; this . scene . time . delayedCall ( delay , ( ) => { row . forEach ( ( cell , c ) => { if ( cell . dot === null ) { cell . dot = this . addNewDot ( cell . x , cell . y , bonus ) ; cell . dot . setGridPosition ( r , c ) ; if ( bonus > 0 ) { this . scene . createScoreAnimation ( cell . dot . x , cell . dot . y , "Bonus Dot level " + bonus + "!" ) ; this . scene . BonusPickup . play ( ) ; bonus = 0 ; } ; } } ) ; } , [ ] ) ; } ) ; }
Alexandr + 16/02/2021 - getting a number of closed points
Alexandr + 16 / 02 / 2021 - getting a number of closed points
// Remove dots and leave nulls where they were referenced //Alexandr + 28/03/2021 //console.log(dot.bonusFeature);   //Alexandr - 28/03/2021  //console.log(result);            //Alexander + 21/02/2021 - destroying animations     //console.log("bonus " + dot.bonusFeature);  //console.log(dot.currentAnim);     //console.log(dot); //Alexander - 21/02/2021  // Move dots downwards. // Remove nulls from color buckets // Remove the nulls from the end //Alexandr + 16/02/2021 - getting a bonus dot //Alexandr - 16/02/2021   //console.log(bonus);   // REPLACE REMOVED CELLS ====================================================================== //Alexandr + 16/02/2021           //Alexandr + 16/02/2021 //Alexandr - 16/02/2021   