private void hitTestBulletWithCells(LaserBullet b) { if (b.y < -100) //went out of the screen { b.die(); return; } Cell[,] cells = _cellsLink.cells; Cell cell; double realBulletX = b.x + GameConfig.LASER_BULLET_WIDTH/2; double realBulletY = b.y + BULLET_Y_SHIFT; for (int i = 0; i < _cellsLink.rowsCount; i++) { for (int j = 0; j < _cellsLink.columnsCount; j++) { cell = cells[i, j]; if (cell.notEmpty) { if ((realBulletX >= cell.x && realBulletX <= (cell.x + GameConfig.BRICK_WIDTH)) && (cell.y + GameConfig.BRICK_HEIGHT >= realBulletY && cell.y <= realBulletY)) //hit a cell { b.die(); cell.clearBrick(_fieldLink.ballsManager.currentTick); break; } } } } }
private void shootBullet() { var newBullet = new LaserBullet(); newBullet.upateCoordinates(_bouncerLink.x + (GameConfig.BOUNCER_WIDTH/2) - BULLET_START_X_SHIFT, _bouncerLink.y); _activeBullets.Add(newBullet); _bulletsLaunched++; Console.WriteLine("[Shoot laser bullet]: at: " + _fieldLink.ballsManager.currentTick + " #: " + _bulletsLaunched + " launch counter: " + _launchCounter + " x: " + newBullet.x + " y: " + newBullet.y); }