home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / 2Deep.swf / scripts / frame_94 / DoAction_5.as < prev    next >
Encoding:
Text File  |  2005-08-08  |  4.7 KB  |  174 lines

  1. function DirectorClass()
  2. {
  3.    this.init();
  4. }
  5. delete dr;
  6. var dr = DirectorClass.prototype;
  7. dr.init = function()
  8. {
  9.    this.floor = Math.floor;
  10.    this.fakeStage = this.stage = 0;
  11.    this.stagesConf = $root.stages;
  12.    this.enemiesCon = $root.createEmptyMovieClip("enemies",$root.hD());
  13.    this.enemies = [];
  14.    this.enemies.push({ln:"Enemy_t1",spd:0.01,energy:10,power:10,score:100,t:0});
  15.    this.enemies.push({ln:"Enemy_t2",spd:0.015,energy:15,power:15,score:150,t:1});
  16.    this.enemies.push({ln:"Enemy_t3",spd:0.025,energy:35,power:25,score:200,t:2});
  17.    this.bonusesCon = $root.createEmptyMovieClip("bonuses",$root.hD());
  18.    this.boardMC = "Director_board";
  19.    this.outLN = "outArea";
  20.    this.scoreBonus = 5000;
  21.    this.board("Stage " + Number(this.stage + 1) + "\n" + this.stagesConf[this.stage].name);
  22. };
  23. dr.board = function(txt)
  24. {
  25.    this.enemiesCon.clearMc();
  26.    this.bonusesCon.clearMc();
  27.    this.outArea.removeMovieClip();
  28.    $root.Player.remove();
  29.    var smc = $root.attachMovie(this.boardMC,this.boardMC,$root.hd(),{_x:250,_y:250,path:this});
  30.    with(smc.txt)
  31.    {
  32.       autoSize = "left";
  33.       text = txt;
  34.    }
  35.    smc.init = getTimer();
  36.    smc.onMouseDown = function()
  37.    {
  38.       if(getTimer() - this.init < 1000)
  39.       {
  40.          return undefined;
  41.       }
  42.       this.path.startPlayin(this);
  43.    };
  44. };
  45. dr.startPlayin = function(todel)
  46. {
  47.    todel.removeMovieClip();
  48.    $root.Player.place();
  49.    this.outArea = $root.attachMovie(this.outLN,this.outLN,$root.hd(),{_alpha:0});
  50.    this.allEmsQty = this.currEmsQty = this.serie = 0;
  51.    this.allOut = false;
  52.    this.throwOutSerie();
  53.    this.toutID = setInterval(this,"throwOutSerie",this.stagesConf[this.stage].ivl);
  54.    if(this.fakeStage != 0 && this.fakeStage % 4 == 0)
  55.    {
  56.       $root.Bonus.addToBG(2);
  57.    }
  58.    if(this.fakeStage != 0 && this.fakeStage % 6 == 0)
  59.    {
  60.       $root.Bonus.addToBG(1);
  61.    }
  62.    if(this.fakeStage != 0 && this.fakeStage % 3 == 0)
  63.    {
  64.       $root.Bonus.addToBG(3);
  65.    }
  66. };
  67. dr.throwOutSerie = function()
  68. {
  69.    var serie = this.stagesConf[this.stage].series[this.serie];
  70.    var sl = serie.length;
  71.    var t = 100;
  72.    var f2c = [];
  73.    var i = -1;
  74.    while(i++ < sl)
  75.    {
  76.       var qty = serie[i];
  77.       while(qty--)
  78.       {
  79.          f2c.push({t:this,f:"gEnemy",a:i});
  80.       }
  81.    }
  82.    this.serie = this.serie + 1;
  83.    if(this.stagesConf[this.stage].series[this.serie] == undefined)
  84.    {
  85.       $root.callDelayed(this.enemiesCon,f2c,250,{t:this,f:"finishThem"});
  86.       clearInterval(this.toutID);
  87.    }
  88.    else
  89.    {
  90.       $root.callDelayed(this.enemiesCon,f2c,250);
  91.    }
  92. };
  93. dr.finishThem = function()
  94. {
  95.    var flyers = this.gStrike();
  96.    this.attackIvl = setInterval(this,"Strike",2000);
  97.    this.allOut = true;
  98.    return undefined;
  99. };
  100. dr.Strike = function()
  101. {
  102.    this.attackers = 0;
  103.    this.strikeIvl = setInterval(this,"gEmy2Strike",300);
  104. };
  105. dr.gEmy2Strike = function()
  106. {
  107.    var atonce = 3 + this.floor(this.fakeStage * 0.25);
  108.    var ec = this.enemiesCon;
  109.    for(var e in ec)
  110.    {
  111.       if(!(e.substr(0,6) != "enemy_" || ec[e].onAir == true))
  112.       {
  113.          ec[e].setCourse();
  114.          ec[e].attack();
  115.          break;
  116.       }
  117.    }
  118.    this.attackers = this.attackers + 1;
  119.    if(this.attackers >= atonce)
  120.    {
  121.       clearInterval(this.strikeIvl);
  122.    }
  123. };
  124. dr.gEnemy = function(t)
  125. {
  126.    this.allEmsQty = this.allEmsQty + 1;
  127.    this.currEmsQty = this.currEmsQty + 1;
  128.    var hd = this.enemiesCon.hd();
  129.    var e = this.enemies[t];
  130.    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});
  131.    er._gx = $middle.x;
  132.    er._gy = $middle.y;
  133. };
  134. dr.destroyEnemy = function(r)
  135. {
  136.    this.currEmsQty--;
  137.    var hd = $root.hD();
  138.    var exr = $root.attachMovie("enemy_explosion","enemy_explosion" + hd,hd,{_xscale:r._xscale,_yscale:r._yscale});
  139.    exr._gx = r._gx;
  140.    exr._gy = r._gy;
  141.    r.removeMovieClip();
  142.    if(this.currEmsQty == 0 && this.allOut === true)
  143.    {
  144.       this.endIvl = setInterval(this,"stageCompleted",1000);
  145.    }
  146. };
  147. dr.hitEnemy = function(r, p)
  148. {
  149.    r.energy -= p;
  150.    if(r.energy <= 0)
  151.    {
  152.       this.updScore(r.score);
  153.       this.destroyEnemy(r);
  154.    }
  155. };
  156. dr.updScore = function(s)
  157. {
  158.    $root.score += s;
  159.    if(Number($root.score) > this.scoreBonus)
  160.    {
  161.       $root.Bonus.addToBG(random(5));
  162.       this.scoreBonus += 5000;
  163.    }
  164. };
  165. dr.stageCompleted = function()
  166. {
  167.    clearInterval(this.endIvl);
  168.    clearInterval(this.attackIvl);
  169.    var l = this.stagesConf.length;
  170.    this.stage = ++this.stage % l;
  171.    this.fakeStage = this.fakeStage + 1;
  172.    this.board("Stage " + Number(this.fakeStage + 1) + "\n" + this.stagesConf[this.stage].name);
  173. };
  174.