Permalink
Browse files

WavesManager updated

  • Loading branch information...
1 parent 8884908 commit 8a6e4ad09332e7748a086608cdb193cd5067398a @hugeen committed Nov 20, 2012
Showing with 31 additions and 31 deletions.
  1. +2 −0 game/components/wave.js
  2. +20 −2 game/components/waves_manager.js
  3. +7 −0 game/levels.js
  4. +2 −29 game/scenes/level.js
View
@@ -35,6 +35,8 @@ define([
this.delay(function() {
this.next();
}, 1000/this.speed);
+ } else {
+ Crafty.trigger("WaveFinished");
}
};
@@ -7,10 +7,28 @@ define([
Crafty.c("WavesManager", {
init: function() {
- this.start = function(waves) {
- Crafty.e("Wave").start(waves[0]);
+ var manager = this;
+
+ Crafty.bind("WaveFinished", function() {
+ manager.currentWave++;
+ if(manager.currentWave < manager.wavesCount) {
+ manager.next();
+ }
+ });
+
+ this.start = function(waves, speed) {
+ _.extend(this, {
+ currentWave: 0,
+ wavesCount: waves.length,
+ waves: waves,
+ speed: speed || 1
+ });
+ this.next();
};
+ this.next = function() {
+ Crafty.e("Wave").start(this.waves[this.currentWave], this.speed);
+ };
}
});
View
@@ -10,6 +10,13 @@ define(function() {
"4": "***p*",
"5": "*****",
"6": "*****"
+ },{
+ "1": "*****",
+ "2": "*****",
+ "3": "*p***",
+ "4": "***p*",
+ "5": "*****",
+ "6": "*****"
}]
}, {
id: 2
View
@@ -17,35 +17,8 @@ define([
name: "level",
init: function(options) {
- Crafty.e("WavesManager").start(options.level.get("waves"));
- /*
-
- function Wave(wave) {
- var timer = false
- var stepsCount = wave[1].length;
- var step = 0;
- var self = this;
- this.start = function() {
- this.next();
- }
- this.next = function() {
- setTimeout(function() {
- _.each(wave, function(line, index) {
- var symbol = line[step];
- if(symbol !== "*") {
- MonsterEntity.create("Octocat", index);
- }
- });
- if(step <= stepsCount) {
- step++;
- self.next();
- }
- }, 1000);
- }
- }
- var wave = new Wave(waves[0]);
- wave.start();
- */
+ Crafty.e("WavesManager").start(options.level.get("waves"), 0.5);
+
$("#wrapper").append(_.template(_skills));
var player = PlayerEntity.create();

0 comments on commit 8a6e4ad

Please sign in to comment.