package com.palepail.TestGame.Enemies;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.palepail.TestGame.Actions.SmoothMoveTo;
import com.palepail.TestGame.Actions.ToggleShooting;
import com.palepail.TestGame.Actions.Wait;
import com.palepail.TestGame.Model.HealthBar;
import com.palepail.TestGame.Model.Ship;
import com.palepail.TestGame.Utilities.Audio;
import com.palepail.TestGame.Utilities.Configuration;
import com.palepail.TestGame.View.World;
public class BossOne extends Boss {
public BossOne(float SPEED, float rotation, float width, float height, Vector2 position) {
super(SPEED, rotation, width, height, position);
this.health = 750;
maxStageHealth = 750;
this.setActive(true);
stage = 3;
setStage(stage);
setHealthQueue(0);
hb = new HealthBar(0f, -90f, 19 * Configuration.gameScale, (float) .5 * Configuration.gameScale, new Vector2(1*Configuration.gameScale, 22.5f*Configuration.gameScale));
spriteName = "BossOne";
hbSpriteName = "healthBar";
variation = VARIATION_BLUE;
renderScaleX = 2 * Configuration.gameScale/40;
renderScaleY = 2* Configuration.gameScale/40;
topSpeed = 30;
acceleration = 30;
fireRate = 10;
value = 3000;
setShooting(false);
dropCount=20;
}
@Override
public void update(Ship ship, World world) {
super.update(ship);
time += Gdx.graphics.getDeltaTime();
if (prevCounter != world.getCounter()) {
ticks++;
attackCounter++;
cooldownCounter++;
prevCounter = world.getCounter();
}
if (isBombed()) {
if (time - timeBombed > ship.getBombDuration() / Configuration.frameRate) {
setBombed(false);
}
}
position.add(velocity.tmp().mul(Gdx.graphics.getDeltaTime() * SPEED));
if (cooldownCounter >= cooldown) {
cooldownCounter = 0;
if (variation.equals(VARIATION_BLUE)) {
setShooting(true, 5);
} else if (variation.equals(VARIATION_RED)) {
setShooting(true, 5);
} else if (variation.equals(VARIATION_GREEN)) {
setShooting(true, 5);
}
}
if (health < 0 && stage <= 1) {
die(world);
//world.getShip().getInfoBox().addScore(world.getLevel().getName(), this.getValue());
world.addToScoreQueue(this.getValue());
addExplosions(world);
Audio.explosion();
}
if (health < 0 && stage > 1) {
setShooting(false);
sequentialScript.clear();
stage--;
setStage(stage);
world.clearBullets();
if (stage == 3) {
variation = VARIATION_BLUE;
}
if (stage == 2) {
variation = VARIATION_RED;
}
if (stage == 1) {
variation = VARIATION_GREEN;
}
health = 750;
maxStageHealth=750;
hb.setWidth(19*Configuration.gameScale);
}
if (isShooting()) {
if (attackCounter >= fireRate) {
if (clip > 0 || clip == -1) {
if (stage == 3) {
shootFullBurst(world, ship , bulletScale);
}
if (stage == 2) {
shootFullSquiggleBurst(world, ship, bulletScale);
}
if (stage == 1) {
shootFullSplitBurst(world, ship, bulletScale, 45, 1f, false);
}
if (clip != -1) {
clip--;
}
if (clip == 0) {
setShooting(false);
}
}
attackCounter = 0;
}
}
scriptIterator = sequentialScript.iterator();
if (scriptIterator.hasNext()) {
action = scriptIterator.next();
if (action.isDone()) {
scriptIterator.remove();
} else {
action.update(ticks);
}
} else {
setStage(stage);
}
if (ticks > 90000) {
ticks = 0;
}
if (rotation > 360) {
rotation -= 360;
}
}
protected void setStage(int stage) {
switch (stage) {
case 3: {
sequentialScript.add(new SmoothMoveTo(this, new Vector2(10 * Configuration.gameScale, 18 * Configuration.gameScale),
10));
sequentialScript.add(new ToggleShooting(this, true, 1, 100));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(17 * Configuration.gameScale, 14 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(10 * Configuration.gameScale, 18 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(3 * Configuration.gameScale, 14 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
break;
}
case 2: {
sequentialScript.add(new SmoothMoveTo(this, new Vector2(10 * Configuration.gameScale, 18 * Configuration.gameScale),
10));
sequentialScript.add(new ToggleShooting(this, true, 1, 100));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(17 * Configuration.gameScale, 14 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(10 * Configuration.gameScale, 18 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(3 * Configuration.gameScale, 14 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
break;
}
case 1: {
sequentialScript.add(new SmoothMoveTo(this, new Vector2(10 * Configuration.gameScale, 18 * Configuration.gameScale),
10));
sequentialScript.add(new ToggleShooting(this, true, 1, 100));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(17 * Configuration.gameScale, 14 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(10 * Configuration.gameScale, 18 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
sequentialScript.add(new SmoothMoveTo(this, new Vector2(3 * Configuration.gameScale, 14 * Configuration.gameScale),
10));
sequentialScript.add(new Wait(this, 100));
}
}
}
}