Exemplo n.º 1
0
 /**
  * Handles collision with walls and opposing players bullets.
  *
  * @param hardBlocks The walls.
  * @param spawnPoint The spawnpoint on which this player will be transfered.
  * @param opponent The opposing player.
  */
 public void checkForCollision(Array<Rectangle> hardBlocks, Vector2 spawnPoint, Player opponent) {
   for (Rectangle rect : hardBlocks) {
     if (bounds.overlaps(rect)) {
       die(spawnPoint);
     }
     // check if bullets collided with walls
     for (int i = 0; i < bullets.size; i++) {
       if (bullets.get(i).getBounds().overlaps(rect)) {
         if (Settings.reversedBullets) {
           bullets.get(i).setMovementReversed(true);
         } else {
           bullets.get(i).dispose();
           bullets.removeIndex(i);
         }
       }
     }
   }
   if (gameMode == GameMode.MULTI_PLAYER) {
     for (Bullet bullet : bullets) {
       if (bullet.getBounds().overlaps(opponent.getBounds())) {
         opponent.die(spawnPoint);
         bullet.dispose();
         bullets.removeValue(bullet, true);
         score++;
       }
     }
   }
 }
 @Override
 public void removePower(Player player) {
   player.setReversedSteering(false);
 }
 @Override
 public void affectEntity(Player player) {
   player.setReversedSteering(true);
 }