home *** CD-ROM | disk | FTP | other *** search
Wrap
function DirectorClass() { this.init(); } delete dr; var dr = DirectorClass.prototype; dr.init = function() { this.floor = Math.floor; this.fakeStage = this.stage = 0; this.stagesConf = $root.stages; this.enemiesCon = $root.createEmptyMovieClip("enemies",$root.hD()); this.enemies = []; this.enemies.push({ln:"Enemy_t1",spd:0.01,energy:10,power:10,score:100,t:0}); this.enemies.push({ln:"Enemy_t2",spd:0.015,energy:15,power:15,score:150,t:1}); this.enemies.push({ln:"Enemy_t3",spd:0.025,energy:35,power:25,score:200,t:2}); this.bonusesCon = $root.createEmptyMovieClip("bonuses",$root.hD()); this.boardMC = "Director_board"; this.outLN = "outArea"; this.scoreBonus = 5000; this.board("Stage " + Number(this.stage + 1) + "\n" + this.stagesConf[this.stage].name); }; dr.board = function(txt) { this.enemiesCon.clearMc(); this.bonusesCon.clearMc(); this.outArea.removeMovieClip(); $root.Player.remove(); var smc = $root.attachMovie(this.boardMC,this.boardMC,$root.hd(),{_x:250,_y:250,path:this}); with(smc.txt) { autoSize = "left"; text = txt; } smc.init = getTimer(); smc.onMouseDown = function() { if(getTimer() - this.init < 1000) { return undefined; } this.path.startPlayin(this); }; }; dr.startPlayin = function(todel) { todel.removeMovieClip(); $root.Player.place(); this.outArea = $root.attachMovie(this.outLN,this.outLN,$root.hd(),{_alpha:0}); this.allEmsQty = this.currEmsQty = this.serie = 0; this.allOut = false; this.throwOutSerie(); this.toutID = setInterval(this,"throwOutSerie",this.stagesConf[this.stage].ivl); if(this.fakeStage != 0 && this.fakeStage % 4 == 0) { $root.Bonus.addToBG(2); } if(this.fakeStage != 0 && this.fakeStage % 6 == 0) { $root.Bonus.addToBG(1); } if(this.fakeStage != 0 && this.fakeStage % 3 == 0) { $root.Bonus.addToBG(3); } }; dr.throwOutSerie = function() { var serie = this.stagesConf[this.stage].series[this.serie]; var sl = serie.length; var t = 100; var f2c = []; var i = -1; while(i++ < sl) { var qty = serie[i]; while(qty--) { f2c.push({t:this,f:"gEnemy",a:i}); } } this.serie = this.serie + 1; if(this.stagesConf[this.stage].series[this.serie] == undefined) { $root.callDelayed(this.enemiesCon,f2c,250,{t:this,f:"finishThem"}); clearInterval(this.toutID); } else { $root.callDelayed(this.enemiesCon,f2c,250); } }; dr.finishThem = function() { var flyers = this.gStrike(); this.attackIvl = setInterval(this,"Strike",2000); this.allOut = true; return undefined; }; dr.Strike = function() { this.attackers = 0; this.strikeIvl = setInterval(this,"gEmy2Strike",300); }; dr.gEmy2Strike = function() { var atonce = 3 + this.floor(this.fakeStage * 0.25); var ec = this.enemiesCon; for(var e in ec) { if(!(e.substr(0,6) != "enemy_" || ec[e].onAir == true)) { ec[e].setCourse(); ec[e].attack(); break; } } this.attackers = this.attackers + 1; if(this.attackers >= atonce) { clearInterval(this.strikeIvl); } }; dr.gEnemy = function(t) { this.allEmsQty = this.allEmsQty + 1; this.currEmsQty = this.currEmsQty + 1; var hd = this.enemiesCon.hd(); var e = this.enemies[t]; var er = this.enemiesCon.attachMovie(e.ln,"enemy_" + this.allEmsQty,hd,{_xscale:5,_yscale:5,spd:e.spd + this.fakeStage * 0.01,energy:e.energy,score:e.score,power:e.power,out:this.outArea,t:e.t}); er._gx = $middle.x; er._gy = $middle.y; }; dr.destroyEnemy = function(r) { this.currEmsQty--; var hd = $root.hD(); var exr = $root.attachMovie("enemy_explosion","enemy_explosion" + hd,hd,{_xscale:r._xscale,_yscale:r._yscale}); exr._gx = r._gx; exr._gy = r._gy; r.removeMovieClip(); if(this.currEmsQty == 0 && this.allOut === true) { this.endIvl = setInterval(this,"stageCompleted",1000); } }; dr.hitEnemy = function(r, p) { r.energy -= p; if(r.energy <= 0) { this.updScore(r.score); this.destroyEnemy(r); } }; dr.updScore = function(s) { $root.score += s; if(Number($root.score) > this.scoreBonus) { $root.Bonus.addToBG(random(5)); this.scoreBonus += 5000; } }; dr.stageCompleted = function() { clearInterval(this.endIvl); clearInterval(this.attackIvl); var l = this.stagesConf.length; this.stage = ++this.stage % l; this.fakeStage = this.fakeStage + 1; this.board("Stage " + Number(this.fakeStage + 1) + "\n" + this.stagesConf[this.stage].name); };