home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / sinta.swf / scripts / Arrow.as < prev    next >
Encoding:
Text File  |  2008-08-08  |  4.5 KB  |  166 lines

  1. package
  2. {
  3.    import flash.display.*;
  4.    import flash.events.*;
  5.    import flash.text.*;
  6.    import flash.utils.*;
  7.    
  8.    [Embed(source="/_assets/assets.swf", symbol="Arrow")]
  9.    public class Arrow extends MovieClip
  10.    {
  11.        
  12.       
  13.       public var isFlame:Boolean;
  14.       
  15.       public var inner:*;
  16.       
  17.       public var targ:MovieClip;
  18.       
  19.       public var damage:int;
  20.       
  21.       public var direction:int;
  22.       
  23.       public var dy:Number;
  24.       
  25.       public var fireFX:*;
  26.       
  27.       public var hit:Boolean;
  28.       
  29.       public var hitbit:*;
  30.       
  31.       public var dx:Number;
  32.       
  33.       public var game:PlatformGame;
  34.       
  35.       public function Arrow()
  36.       {
  37.          super();
  38.          addFrameScript(0,frame1,1,frame2);
  39.          damage = 25;
  40.       }
  41.       
  42.       public function hitSomething() : *
  43.       {
  44.          var _loc1_:Timer = null;
  45.          hit = true;
  46.          _loc1_ = new Timer(750,1);
  47.          _loc1_.start();
  48.          _loc1_.addEventListener(TimerEvent.TIMER_COMPLETE,endTime);
  49.       }
  50.       
  51.       public function endTime(param1:Event) : *
  52.       {
  53.          deleteMe();
  54.       }
  55.       
  56.       internal function frame1() : *
  57.       {
  58.          stop();
  59.       }
  60.       
  61.       internal function frame2() : *
  62.       {
  63.          stop();
  64.       }
  65.       
  66.       public function updateFlight(param1:*) : *
  67.       {
  68.          var _loc2_:* = undefined;
  69.          var _loc3_:int = 0;
  70.          if(targ != null)
  71.          {
  72.             dx = targ.dx;
  73.             dy = targ.dy;
  74.          }
  75.          x += dx * param1;
  76.          y += dy * param1;
  77.          _loc2_ = Math.atan(dy / dx);
  78.          _loc2_ = 180 / Math.PI * _loc2_;
  79.          if(targ == null)
  80.          {
  81.             rotation = _loc2_;
  82.          }
  83.          if(rotation > 90 && dy < 0)
  84.          {
  85.             rotation -= 180;
  86.          }
  87.          if(dx < 0 && dy > 0)
  88.          {
  89.          }
  90.          if(x > 700 || x < -20 || y > 500)
  91.          {
  92.             deleteMe();
  93.          }
  94.          if(!hit)
  95.          {
  96.             _loc3_ = 0;
  97.             while(_loc3_ < game.enemies.length)
  98.             {
  99.                if(game.enemies[_loc3_].monsterType != 28)
  100.                {
  101.                   if(Boolean(game.enemies[_loc3_].inner.hitbithurt.hitTestObject(hitbit)) && Boolean(game.enemies[_loc3_].alive))
  102.                   {
  103.                      if(game.enemies[_loc3_].monsterType == 26)
  104.                      {
  105.                         if(!isFlame)
  106.                         {
  107.                            game.sounds.elementalimmune.play();
  108.                            deleteMe();
  109.                            break;
  110.                         }
  111.                         game.sounds.elementalhit.play();
  112.                      }
  113.                      game.enemies[_loc3_].takeDamage(damage);
  114.                      targ = game.enemies[_loc3_];
  115.                      hitSomething();
  116.                   }
  117.                }
  118.                else if(Boolean(game.enemies[_loc3_].inner.movewiz.hitbithurt.hitTestObject(hitbit)) && Boolean(game.enemies[_loc3_].alive))
  119.                {
  120.                   game.sounds.wizardimmune.play();
  121.                   deleteMe();
  122.                   break;
  123.                }
  124.                _loc3_++;
  125.             }
  126.             _loc3_ = 0;
  127.             while(_loc3_ < game.fixedObjects.length)
  128.             {
  129.                if(game.fixedObjects[_loc3_].blocktype == 62 && !game.fixedObjects[_loc3_].open)
  130.                {
  131.                   if(game.fixedObjects[_loc3_].block62.inner.hitTestPoint(x,y,false))
  132.                   {
  133.                      targ = game.fixedObjects[_loc3_];
  134.                      hitSomething();
  135.                   }
  136.                }
  137.                if(game.fixedObjects[_loc3_].blocktype == 63 && !game.fixedObjects[_loc3_].open)
  138.                {
  139.                   if(game.fixedObjects[_loc3_].block63.inner.hitTestPoint(x,y,false))
  140.                   {
  141.                      targ = game.fixedObjects[_loc3_];
  142.                      hitSomething();
  143.                   }
  144.                }
  145.                _loc3_++;
  146.             }
  147.             _loc3_ = 0;
  148.             while(_loc3_ < game.lustras.length)
  149.             {
  150.                if(game.lustras[_loc3_].hitbithurt.hitTestObject(hitbit))
  151.                {
  152.                   game.lustras[_loc3_].takeDamage(damage);
  153.                   deleteMe();
  154.                }
  155.                _loc3_++;
  156.             }
  157.          }
  158.       }
  159.       
  160.       public function deleteMe() : *
  161.       {
  162.          game.removeArrow(this);
  163.       }
  164.    }
  165. }
  166.