home *** CD-ROM | disk | FTP | other *** search
/ Ice Age Fan CD 1 / CD1_Scrat.iso / flash / data / game.swf / scripts / asCode / enemyItemClass.as < prev    next >
Encoding:
Text File  |  2012-07-04  |  3.5 KB  |  156 lines

  1. package asCode
  2. {
  3.    import flash.geom.Point;
  4.    
  5.    public class enemyItemClass
  6.    {
  7.       private static var remove:Boolean;
  8.       
  9.       private static var ENEMY_METEOR:int = 1;
  10.       
  11.       private static var ENEMY_BEE:int = 2;
  12.       
  13.       private static var ENEMY_STICK:int = 3;
  14.       
  15.       private var basey:Number;
  16.       
  17.       private var moveRange:Number;
  18.       
  19.       private var cycleNum:Number;
  20.       
  21.       private var enemySubType:int;
  22.       
  23.       private var maxAnimationFrames:int;
  24.       
  25.       private var animationFrame:int;
  26.       
  27.       private var hitTestRadius:int = 30;
  28.       
  29.       private var id:int;
  30.       
  31.       private var enemyType:int;
  32.       
  33.       private var maxSpeed:Number;
  34.       
  35.       private var speed:Number;
  36.       
  37.       private var xVel:Number = 0;
  38.       
  39.       private var yVel:Number = 0;
  40.       
  41.       private var dir:Number = 0;
  42.       
  43.       private var radians:Number = 0;
  44.       
  45.       private var loc:Point;
  46.       
  47.       public function enemyItemClass(param1:Number, param2:Number, param3:Number, param4:Number, param5:int, param6:*, param7:int)
  48.       {
  49.          super();
  50.          loc = new Point(param1,param2);
  51.          basey = param2;
  52.          dir = param3;
  53.          enemyType = param4;
  54.          maxSpeed = param6;
  55.          speed = 0;
  56.          radians = dir / 180 * Math.PI;
  57.          remove = false;
  58.          id = param7;
  59.          animationFrame = 1;
  60.          enemySubType = param5;
  61.          moveRange = 60;
  62.          cycleNum = 0;
  63.       }
  64.       
  65.       public function getAnimationFrame() : int
  66.       {
  67.          return animationFrame;
  68.       }
  69.       
  70.       public function getType() : int
  71.       {
  72.          return enemyType;
  73.       }
  74.       
  75.       public function manageEnemy(param1:Number) : void
  76.       {
  77.          ++animationFrame;
  78.          if(animationFrame > 15)
  79.          {
  80.             animationFrame = 1;
  81.          }
  82.          if(speed < maxSpeed)
  83.          {
  84.             speed += 0.1;
  85.          }
  86.          switch(enemyType)
  87.          {
  88.             case ENEMY_METEOR:
  89.                break;
  90.             case ENEMY_BEE:
  91.                cycleNum += 2;
  92.                loc.y = basey + Math.cos(cycleNum / 180 * Math.PI) * moveRange;
  93.          }
  94.          xVel = Math.cos(radians) * speed;
  95.          yVel = Math.sin(radians) * speed;
  96.          loc.x += xVel;
  97.          loc.y += yVel + param1;
  98.          basey += yVel + param1;
  99.       }
  100.       
  101.       public function getEnemySubType() : int
  102.       {
  103.          return enemySubType;
  104.       }
  105.       
  106.       private function manageBee() : void
  107.       {
  108.       }
  109.       
  110.       private function manageMeteor() : void
  111.       {
  112.       }
  113.       
  114.       public function getHitRadius() : Number
  115.       {
  116.          return hitTestRadius;
  117.       }
  118.       
  119.       public function getDir() : Number
  120.       {
  121.          return dir;
  122.       }
  123.       
  124.       public function getID() : int
  125.       {
  126.          return id;
  127.       }
  128.       
  129.       public function getRemove() : Boolean
  130.       {
  131.          return remove;
  132.       }
  133.       
  134.       public function getDamage() : int
  135.       {
  136.          switch(enemyType)
  137.          {
  138.             case ENEMY_BEE:
  139.                return 30;
  140.             case ENEMY_METEOR:
  141.                return 35;
  142.             case ENEMY_STICK:
  143.                return 20;
  144.             default:
  145.                return 10;
  146.          }
  147.       }
  148.       
  149.       public function getLoc() : Point
  150.       {
  151.          return new Point(loc.x,loc.y);
  152.       }
  153.    }
  154. }
  155.  
  156.