home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / eolica.swf / scripts / frame_10 / DoAction.as
Encoding:
Text File  |  2005-07-26  |  3.4 KB  |  141 lines

  1. WindGust = function(game_x, game_y, isJetStream)
  2. {
  3.    GAME.mc.attachMovie(!isJetStream ? "wind_gust" : "wind_gust_jetstream","wind_gust" + GAME.drawIndex,GAME.drawIndex);
  4.    this.mc = GAME.mc["wind_gust" + GAME.drawIndex];
  5.    this.mc.obj = this;
  6.    GAME.drawIndex = GAME.drawIndex + 1;
  7.    this.game_x = game_x;
  8.    this.game_y = game_y;
  9.    GAME.drawOnScreen(this,true);
  10.    this.setStatus(1);
  11.    this.onGameFrame = function()
  12.    {
  13.       this.loop();
  14.    };
  15.    GAME.addListener(this);
  16.    GAME.gameFrame.addListener(this);
  17. };
  18. var t = WindGust.prototype;
  19. t.loop = function()
  20. {
  21.    this.updatePosition();
  22.    if(this.curStatusLoop() == false)
  23.    {
  24.       return false;
  25.    }
  26.    GAME.drawOnScreen(this,true);
  27. };
  28. t.status1Loop = function()
  29. {
  30.    if(this.game_y > GAME.parameters.windGustTooFarY)
  31.    {
  32.       this.mc.gotoAndPlay("too_far");
  33.       this.setStatus(3);
  34.       return false;
  35.    }
  36.    var _loc8_ = this.curCell;
  37.    this.curCell = GAME.curGrid.mapCell(this.game_x,this.game_y);
  38.    var _loc7_ = new Array(this.curCell);
  39.    if(_loc8_ != this.curCell)
  40.    {
  41.       _loc7_.push(_loc8_);
  42.    }
  43.    this.mc.cell_out = this.curCell;
  44.    var _loc6_ = 0;
  45.    while(_loc6_ < _loc7_.length)
  46.    {
  47.       var _loc4_ = _loc7_[_loc6_];
  48.       if(_loc4_.contents.length > 0)
  49.       {
  50.       }
  51.       var _loc3_ = 0;
  52.       while(_loc3_ < _loc4_.contents.length)
  53.       {
  54.          var _loc2_ = _loc4_.contents[_loc3_];
  55.          if(_loc2_.game_y >= this.last_y && _loc2_.game_y <= this.game_y && this.game_x <= _loc2_.max_game_x && this.game_x >= _loc2_.min_game_x)
  56.          {
  57.             var _loc5_ = _loc2_.hitByWindGust(this);
  58.             if(!_loc5_)
  59.             {
  60.                this.burst(_loc2_);
  61.                return false;
  62.             }
  63.          }
  64.          _loc3_ = _loc3_ + 1;
  65.       }
  66.       _loc6_ = _loc6_ + 1;
  67.    }
  68. };
  69. t.status2Loop = function()
  70. {
  71.    if(this.game_y > GAME.parameters.windGustTooFarY)
  72.    {
  73.       this.mc.gotoAndPlay("too_far");
  74.       this.setStatus(3);
  75.       return false;
  76.    }
  77. };
  78. t.status3Loop = function()
  79. {
  80. };
  81. t.burst = function(hitObj)
  82. {
  83.    this.setStatus(3);
  84.    GAME.gameFrame.removeListener(this);
  85.    delete this.loop;
  86.    this.mc.gotoAndPlay("burst");
  87.    this.game_y = hitObj.game_y;
  88.    GAME.drawOnScreen(this,true);
  89.    var _loc2_ = hitObj.mc.getDepth();
  90.    _loc2_ += 10;
  91.    this.mc.swapDepths(_loc2_);
  92. };
  93. t.remove = function()
  94. {
  95.    this.markedForDeath = true;
  96.    GAME.gameFrame.removeListener(this);
  97.    GAME.removeObject(this);
  98. };
  99. t.fadeAway = function()
  100. {
  101.    this.mc.gotoAndPlay("too_far");
  102. };
  103. t.updatePosition = function()
  104. {
  105.    this.last_y = this.game_y;
  106.    this.game_x += GAME.windAdjustX;
  107.    this.game_y += this.speed + GAME.windAdjustY;
  108. };
  109. t.setStatus = function(status)
  110. {
  111.    this.status = status;
  112.    this.curStatusLoop = this["status" + status + "Loop"];
  113. };
  114. t.createTrail = function()
  115. {
  116.    GAME.mc.attachMovie("wind_gust_trail","wgt" + GAME.drawIndex,this.mc.getDepth() + 1,{_x:this.mc._x,_y:this.mc._y,_xscale:this.mc._xscale,_yscale:this.mc._yscale});
  117.    GAME.drawIndex = GAME.drawIndex + 1;
  118. };
  119. t.onLevelComplete = function()
  120. {
  121.    this.fadeAway();
  122. };
  123. t.onLevelIncomplete = function()
  124. {
  125.    this.fadeAway();
  126. };
  127. t.mc = false;
  128. t.markedForDeath = false;
  129. t.speed = 35;
  130. t.power = 10;
  131. t.last_x = 0;
  132. t.game_x = 0;
  133. t.game_y = 0;
  134. t.curCell = false;
  135. t.status = 0;
  136. t.statusLoop = false;
  137. t.toString = function()
  138. {
  139.    return "[WindGust " + this.game_x + "," + this.game_y + "]";
  140. };
  141.