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

  1. package
  2. {
  3.    import flash.display.*;
  4.    import flash.events.*;
  5.    import flash.text.*;
  6.    
  7.    [Embed(source="/_assets/assets.swf", symbol="BadArrow")]
  8.    public class BadArrow extends MovieClip
  9.    {
  10.        
  11.       
  12.       public var arrowType:int;
  13.       
  14.       public var thrower:Monster;
  15.       
  16.       public var power:int;
  17.       
  18.       public var damageType:int;
  19.       
  20.       public var damage:int;
  21.       
  22.       public var direction:int;
  23.       
  24.       public var dy:Number;
  25.       
  26.       public var dx:Number;
  27.       
  28.       public var alive:Boolean;
  29.       
  30.       public var game:PlatformGame;
  31.       
  32.       public function BadArrow()
  33.       {
  34.          super();
  35.          addFrameScript(0,frame1,1,frame2);
  36.       }
  37.       
  38.       public function init(param1:Monster) : *
  39.       {
  40.          alive = true;
  41.          arrowType = param1.monsterType;
  42.          thrower = param1;
  43.          switch(arrowType)
  44.          {
  45.             case 23:
  46.                damage = 25;
  47.                damageType = 1;
  48.                dx = 0.3 * thrower.direction;
  49.                dy = -0.05;
  50.                x = thrower.x - 6 * thrower.direction;
  51.                y = thrower.y - 36;
  52.                scaleX = thrower.direction;
  53.                power = 0.5;
  54.                break;
  55.             case 28:
  56.                damage = 100;
  57.                damageType = 4;
  58.                gotoAndStop(2);
  59.                power = 0.5;
  60.          }
  61.       }
  62.       
  63.       public function endTime(param1:Event) : *
  64.       {
  65.          deleteMe();
  66.       }
  67.       
  68.       internal function frame1() : *
  69.       {
  70.          stop();
  71.       }
  72.       
  73.       internal function frame2() : *
  74.       {
  75.          stop();
  76.       }
  77.       
  78.       public function updateFlight(param1:*) : *
  79.       {
  80.          var _loc2_:int = 0;
  81.          var _loc3_:* = undefined;
  82.          if(arrowType == 23)
  83.          {
  84.             dy += param1 * 0.0002;
  85.          }
  86.          if(arrowType == 28)
  87.          {
  88.             _loc3_ = Math.atan(dy / dx);
  89.             _loc3_ = 180 / Math.PI * _loc3_;
  90.             rotation = _loc3_;
  91.             if(rotation > 90 && dy < 0)
  92.             {
  93.                rotation -= 180;
  94.             }
  95.             if(dx < 0)
  96.             {
  97.                rotation -= 180;
  98.             }
  99.          }
  100.          x += dx * param1;
  101.          y += dy * param1;
  102.          if(x > 700 || x < -20 || y > 500)
  103.          {
  104.             deleteMe();
  105.          }
  106.          if(game.hero.mc.hitTestPoint(x,y,true))
  107.          {
  108.             if(thrower.monsterType == 28)
  109.             {
  110.                game.sounds.wizardlaugh2.play();
  111.             }
  112.             game.hero.takeDamage(damage,damageType,power,x);
  113.             deleteMe();
  114.          }
  115.          _loc2_ = 0;
  116.          while(_loc2_ < game.fixedObjects.length)
  117.          {
  118.             if(game.fixedObjects[_loc2_].blocktype == 62 && !game.fixedObjects[_loc2_].open)
  119.             {
  120.                if(game.fixedObjects[_loc2_].block62.inner.hitTestPoint(x,y,false))
  121.                {
  122.                   deleteMe();
  123.                }
  124.             }
  125.             if(game.fixedObjects[_loc2_].blocktype == 63 && !game.fixedObjects[_loc2_].open)
  126.             {
  127.                if(game.fixedObjects[_loc2_].block63.inner.hitTestPoint(x,y,false))
  128.                {
  129.                   deleteMe();
  130.                }
  131.             }
  132.             _loc2_++;
  133.          }
  134.       }
  135.       
  136.       public function deleteMe() : *
  137.       {
  138.          game.removeBadArrow(this);
  139.       }
  140.    }
  141. }
  142.