コード例 #1
0
 /**
  * Resets the game
  *
  * @param difficulty Which difficulty it should be reset to.
  */
 public void reset(Difficulty difficulty) {
   bulletManager.clearAllBullets();
   enemyManager.clearAllEnemies();
   pickupManager.clearAllPickups();
   enemySpawner = new EnemySpawner(new RandomWaveList(difficulty));
   enemySpawner.addPropertyChangeListener(enemyManager);
   player.reset();
   player.giveWeapon(new BasicWeapon(bulletManager));
 }
コード例 #2
0
  /** @param difficulty Which difficulty level the game model should be on. */
  public GameModel(Difficulty difficulty) {
    bulletManager = new BulletManager();
    enemyManager = new EnemyManager();
    pickupManager = new PickupManager();
    WeaponFactory.initialize(bulletManager);
    enemySpawner = new EnemySpawner(new RandomWaveList(difficulty));
    enemySpawner.addPropertyChangeListener(enemyManager);
    player = new Player(PlayerID.PLAYER1, bulletManager);
    pcs = new PropertyChangeSupport(this);

    // Player listens when enemies are killed
    enemyManager.addPropertyChangeListener(player);
  }