public void nextTileAnimatedSprite(final AnimatedSprite pAnimatedSprite) { int index = pAnimatedSprite.getCurrentTileIndex(); if (index >= pAnimatedSprite.getTileCount() - 1) { index = 0; } else { index++; } pAnimatedSprite.setCurrentTileIndex(index); }
private void toggleSpeedFactor() { speedFactor = (speedFactor == 0.5f) ? 1.0f : 0.5f; int startIndex = startButton.getCurrentTileIndex(); if (startIndex < 2) startButton.setCurrentTileIndex((startIndex + 1) % 2); else { if (startIndex == 2) startButton.setCurrentTileIndex(3); else startButton.setCurrentTileIndex(2); } }
/** * Attaches the move modifiers to each of the enemies in the next wave and attaches the enemies to * the scene */ private void startCurrentWave() { if (waveFinished) { startButton.setCurrentTileIndex(startButton.getCurrentTileIndex() + 2); Log.i("START WAVE", "START WAVE"); waveFinished = false; initializedNewWave = false; waveGenerator.startWave(); startInWaveUpdateHandlers(); } else { toggleSpeedFactor(); } }
/** Initializes paths and move modifiers of all enemies in the next wave */ public void initializeNextWave() { Log.i("Init wave", "here"); // If the previous wave was eliminated even before all enemies technically started, the time // handler // that handles their first move modifier would never get unregistered, putting the game in // limbo this.unregisterUpdateHandler(waveGenerator.getTimeHandler()); if (startButton.getCurrentTileIndex() > 1) startButton.setCurrentTileIndex(startButton.getCurrentTileIndex() - 2); // The player wins the game!! if (waveCount == 70 && lives != 0) { displayWinScreen(); return; } waveGenerator.initWave(waveCount); currentWave = waveGenerator.get(waveCount); enemies = (CopyOnWriteArrayList<Enemy>) currentWave.getEnemies(); waveCount++; panel.setWaveText(waveCount); this.aStarHelper.finishWave(); this.deadEnemies = 0; /** Just for debugging */ for (Enemy enemy : currentWave.getEnemies()) { if (enemy == null) continue; enemy.setUserData(null); enemy.returnHealthToNormal(); } for (ITower tower : towers) { tower.onWaveEnd(); } }