@Override public void show() { musicManager.setVolume(optionsPreferences.getMusicVolume()); dyingSound.setVolume(optionsPreferences.getSfxVolume()); musicManager.play(ZombieMusic.LEVEL); batch = new SpriteBatch(); exit.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { leave.showReassure(); } }); exit.setPosition(380, 558); table.setFillParent(true); stage.addActor(leave.drawReassure(musicManager)); stage.addActor(buttons.drawButtons()); stage.addActor(exit); Gdx.input.setInputProcessor(stage); zombieList = new ZombieList("SpawnTimes/level1.wave"); zombieList1 = new ZombieList("SpawnTimes/level1.wave"); }
water3() { super(); camera = new OrthographicCamera(); camera.setToOrtho(false, ZombieAttack.SCREEN_WIDTH, ZombieAttack.SCREEN_HEIGHT); ui = new Texture(Gdx.files.internal("UI.png")); ZombieAttack.money = 450; /** EDIT* */ noClickZone = new NoClickZone("NoNoZones/level6.nono"); towerList = new TowerList(stage, zombieList, noClickZone); /** EDIT* */ tiledMap = new TmxMapLoader().load("Maps/Level6.tmx"); tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap); fontLabel = new BitmapFont(Gdx.files.internal("fonts/SmallzFont.fnt")); infoText = new InfoText(); buttons = new TurretButtons(infoText, noClickZone); difficulty = optionsPreferences.getDifficulty(); if (difficulty == 1) playerLife = 5; else if (difficulty == 2) playerLife = 3; else if (difficulty == 3) playerLife = 1; }
@Override public void render(float delta) { camera.update(); Vector2 clickLocation = ZombieAttack.getClickLocation(); // refreshing open gl screen Gdx.gl20.glClearColor(0, 102 / 255f, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // rendering map tiledMapRenderer.setView(camera); tiledMapRenderer.render(); ZombieAttack.money = buttons.setSharpTurret(ZombieAttack.money, camera, towerList); ZombieAttack.money = buttons.setMissileTurret(ZombieAttack.money, camera, towerList); ZombieAttack.money = buttons.setIceTurret(ZombieAttack.money, camera, towerList); ZombieAttack.money = buttons.setFlameTurret(ZombieAttack.money, camera, towerList); money = "Money: $" + ZombieAttack.money; // spawning zombies if (!zombieList1.waveBreak() && !zombieList.waveBreak()) { zombieList.spawnZombie(-20, 168, Direction.RIGHT); zombieList1.spawnZombie(-20, 424, Direction.RIGHT); } if (zombieList.isLevelFinished() && zombieList1.isLevelFinished()) { musicManager.stop(); optionsPreferences.setCurrentLevel(6); if (optionsPreferences.getLevel() <= optionsPreferences.getCurrentLevel()) optionsPreferences.setLevel(7); ((Game) Gdx.app.getApplicationListener()).setScreen(new NextLevel(new sand1())); } towerList.drawFOV(camera); batch.begin(); { batch.draw(ui, 0, 0); batch.draw(ui, 0, 543, 800, 58); waveString = "Wave " + zombieList.getCurrentWave(); zombieString = "Zombies " + (zombieList.getZombiesLeft() + zombieList1.getZombiesLeft()); playerLifeString = "Lives " + playerLife; // Display labels fontLabel.setColor(0.0f, 0.7f, 0.05f, 1.0f); fontLabel.draw(batch, money, 620, 570); fontLabel.setColor(1.0f, 1.0f, 1.0f, 1.0f); fontLabel.draw(batch, waveString, 0, 598); fontLabel.draw(batch, zombieString, 0, 570); fontLabel.setColor(1.0f, 0.0f, 0.0f, 1.0f); fontLabel.draw(batch, playerLifeString, 620, 600); // updating the projectiles and turrets towerList.updateProjectiles(delta, zombieList); towerList.updateProjectiles(delta, zombieList1); if (rand.nextInt(2) == 0) { towerList.updateTurrets(clickLocation, batch, delta, zombieList1); towerList.updateTurrets(clickLocation, batch, delta, zombieList); } else { towerList.updateTurrets(clickLocation, batch, delta, zombieList); towerList.updateTurrets(clickLocation, batch, delta, zombieList1); } towerList.drawTowers(batch, delta); // rendering zombie Iterator<Zombie> iter = zombieList.iterator(); while (iter.hasNext()) { RegZombie z = (RegZombie) iter.next(); // zombieList.spawnZombie(-20, 168, Direction.RIGHT); z.changeToY(226, 168, Direction.UP); z.changeToX(226, 240, Direction.RIGHT); z.changeToY(546, 240, Direction.DOWN); z.changeToX(546, 168, Direction.RIGHT); z.move(batch, delta); if (z.health <= 0) { dyingSound.play(ZombieEffects.ZOMBIEDYING); iter.remove(); ZombieAttack.money += 5; money = "Money: $ " + ZombieAttack.money; ++zombieList.zombiesKilled; } if (z.dx > 805) { iter.remove(); --playerLife; if (playerLife <= 0) ((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver(new water3())); } } Iterator<Zombie> iter1 = zombieList1.iterator(); while (iter1.hasNext()) { RegZombie z1 = (RegZombie) iter1.next(); z1.changeToY(226, 424, Direction.DOWN); z1.changeToX(226, 368, Direction.RIGHT); z1.changeToY(546, 368, Direction.UP); z1.changeToX(546, 424, Direction.RIGHT); z1.move(batch, delta); if (z1.health <= 0) { iter1.remove(); ZombieAttack.money += 10; money = "Money: $ " + ZombieAttack.money; ++zombieList1.zombiesKilled; } if (z1.dx > 805) { iter1.remove(); --playerLife; if (playerLife <= 0) ((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver(new water3())); } } infoText.draw(batch, 0); if (zombieList.waveBreak() && zombieList1.waveBreak()) if (zombieList.getWaveBreakTimeLeft() > zombieList1.getWaveBreakTimeLeft()) infoText.draw(batch, zombieList.getWaveBreakTimeLeft()); else infoText.draw(batch, zombieList1.getWaveBreakTimeLeft()); } batch.end(); // end drawing level zombieList.drawHealth(camera); zombieList1.drawHealth(camera); // tower buttons stage.act(); stage.draw(); ZombieAttack.moneyCheat(); }