home *** CD-ROM | disk | FTP | other *** search
- function BonusClass()
- {
- this.init();
- }
- delete br;
- var br = BonusClass.prototype;
- br.init = function()
- {
- this.pow = Math.pow;
- this.sqrt = Math.sqrt;
- this.bonuses = [];
- this.bonuses.push({ln:"Bonus_t1",t:$root.Player,f:"hitMe",a:-20,spd:0.02});
- this.bonuses.push({ln:"Bonus_t2",t:$root.Player,f:"extendEnergy",a:20,spd:0.03});
- this.bonuses.push({ln:"Bonus_t3",t:$root.Player,f:"switchAmmo",a:1,spd:0.03});
- this.bonuses.push({ln:"Bonus_t4",t:$root.Player,f:"generateShield",spd:0.03});
- this.bonuses.push({ln:"Bonus_t5",t:$root.Player,f:"generateWingmans",spd:0.03});
- this.gContainer = [{qty:0,t:getTimer()},{qty:0,t:getTimer()},{qty:0,t:getTimer()},{qty:0,t:getTimer()},{qty:0,t:getTimer()}];
- };
- br.setCourse = function()
- {
- var xram = random(($ray + 50) * 2);
- var yram = this.sqrt(this.pow($ray + 50,2) - this.pow(xram - $middle.x,2)) + $middle.y;
- if(random(2) == 0)
- {
- yram -= 2 * (yram - $middle.y);
- }
- return {x:xram,y:yram};
- };
- br.initialize = function(t)
- {
- var bonus = this.bonuses[t];
- var dest = this.setCourse();
- var hd = $root.hd();
- var br = $root.Director.bonusesCon.attachMovie(bonus.ln,bonus.ln + hd,hd,bonus);
- br._gx = $middle.x;
- br._gy = $middle.y;
- br.path = this;
- br.dest = this.setCourse();
- br.onEnterFrame = function()
- {
- this.path.go(this);
- };
- };
- br.go = function(t)
- {
- var is = this.detectHT(t);
- if(!is)
- {
- return undefined;
- }
- var x = t.dest.x;
- var y = t.dest.y;
- with(t)
- {
- var xDis = _x - x;
- var yDis = _y - y;
- _x -= (xDis - 15) * spd;
- _y -= (yDis - 15) * spd;
- _xscale -= (_xscale - 100) * spd;
- _yscale -= (_yscale - 100) * spd;
- }
- };
- br.detectHT = function(t)
- {
- if(t.hitTest($root.Player.tgt.obj) === true)
- {
- t.t[t.f](t.a);
- t.removeMovieClip();
- return false;
- }
- if($root.Director.outArea.hitTest(t._x,t._y,1) === true)
- {
- t.removeMovieClip();
- return false;
- }
- return true;
- };
- br.addToBG = function(t)
- {
- if(this.gContainer[t] == undefined)
- {
- return undefined;
- }
- var bc = $root.Director.bonusesCon;
- if(bc.onEnterFrame == undefined)
- {
- bc.path = this;
- bc.onEnterFrame = function()
- {
- this.path.bonusGenerator();
- };
- }
- this.gContainer[t].qty = this.gContainer[t].qty + 1;
- };
- br.bonusGenerator = function()
- {
- var gc = this.gContainer;
- var l = gc.length;
- while(--l >= 0)
- {
- if(!(gc[l].qty < 1 || getTimer() - gc[l].t < 15000))
- {
- this.initialize(l);
- gc[l].t = getTimer();
- gc[l].qty--;
- }
- }
- };
-