Made a timeout between bosses and next levels

This commit is contained in:
Bram van der Veen 2014-07-09 17:59:24 +02:00
parent 33a034bc94
commit 152db1bcfd
2 changed files with 34 additions and 22 deletions

View file

@ -6,6 +6,7 @@ import com.haxepunk.HXP;
import Enemy;
import Explosion;
import Spawner;
class Boss extends Entity {
@ -72,8 +73,15 @@ class Boss extends Entity {
this.scene.add(new Explosion(this.x + (Math.random() * currentSprite.width * 8), this.y + (Math.random() * currentSprite.height * 8) + 100, this.scene.getInstance("player")));
explosionTimer = Math.random() * .2;
counter++;
var spawner:Array<Spawner> = [];
this.scene.getClass(Spawner, spawner);
spawner[0].sublevel = 3;
}
else if (counter == 100) {
var spawner:Array<Spawner> = [];
this.scene.getClass(Spawner, spawner);
spawner[0].bossSpawned = false;
this.scene.remove(this);
}
}

View file

@ -18,40 +18,44 @@ class Spawner extends Entity {
this.scene.getClass(Enemy, enemies);
this.scene.getClass(Boss, bosses);
if (level == 4) {level = 0; trace("YOU BEAT IT!");}
if (enemyType == 6) {sublevel++; enemyType = 1;}
if (level != 4) {
if (enemyType == 6) {sublevel++; enemyType = 1;}
if (enemies.length < 1 && sublevel < 2) {
if (enemyTimer < 0) {
if (sublevel == 0)
this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType++));
else {
this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType++));
if (enemyType != 6) this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType++));
else this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType - 1));
}
if (enemies.length < 1 && sublevel != 2) {
if (enemyTimer < 0) {
if (sublevel == 0)
this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType++));
else {
this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType++));
if (enemyType != 6) this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType++));
else this.scene.add(new Enemy(HXP.halfWidth, -60, level, enemyType - 1));
}
}
else {
enemyTimer = 1;
}
if (sublevel == 2 && !bossSpawned) {
this.scene.add(new Boss(level));
bossSpawned = true;
}
if (sublevel == 3 && !bossSpawned && bosses.length != 1) {
level++; enemyType = 1; sublevel = 0; trace("Next level!");
}
}
else {
enemyTimer = 1;
}
if (sublevel == 2 && !bossSpawned) {
this.scene.add(new Boss(level));
bossSpawned = true;
}
if (sublevel == 2 && bossSpawned && bosses.length != 1) {
level++; enemyType = 1; sublevel = 0; bossSpawned = false; trace("Next level!");
trace("YOU BEAT THE GAME!");
}
}
private var level:Int = 0;
private var sublevel:Int = 0;
public var sublevel:Int = 0;
private var enemyTimer:Float = 1;
private var enemyType:Int = 1;
private var bossSpawned:Bool = false;
public var bossSpawned:Bool = false;
}