home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / DSS145 / DSS145_12 / DSS145_12.swf / scripts / dss145_12 / Enemy.as < prev    next >
Text File  |  2012-07-19  |  3KB  |  106 lines

  1. package dss145_12
  2. {
  3.    import com.touchmypixel.games.utils.Animation;
  4.    import com.touchmypixel.games.utils.AnimationManager;
  5.    import flash.display.MovieClip;
  6.    
  7.    public class Enemy
  8.    {
  9.        
  10.       
  11.       public var type:String;
  12.       
  13.       public var DECOR:Decor;
  14.       
  15.       public var _movie:MovieClip;
  16.       
  17.       protected var _animationPerformerManager:AnimationManager = null;
  18.       
  19.       public var anim:MovieClip;
  20.       
  21.       public var xOriginal:Number = 0;
  22.       
  23.       public var yOriginal:Number = 0;
  24.       
  25.       public var x:Number = 0;
  26.       
  27.       public var y:Number = 0;
  28.       
  29.       public var speed:Number = 4;
  30.       
  31.       public var speedX:Number = 0;
  32.       
  33.       public var speedY:Number = 0;
  34.       
  35.       public var attackParams:Object;
  36.       
  37.       public function Enemy(param1:Decor, param2:MovieClip)
  38.       {
  39.          super();
  40.          this.DECOR = param1;
  41.          this._movie = param2;
  42.          this.x = this.xOriginal = this._movie.x;
  43.          this.y = this.yOriginal = this._movie.y;
  44.          this.anim = this.getPerformedAnim(this._movie);
  45.          this.anim.gotoAndPlay(1);
  46.       }
  47.       
  48.       public function set scaleX(param1:Number) : void
  49.       {
  50.          this.anim.scaleX = param1;
  51.       }
  52.       
  53.       public function get scaleX() : Number
  54.       {
  55.          return this.anim.scaleX;
  56.       }
  57.       
  58.       public function setPos(param1:Number, param2:Number) : void
  59.       {
  60.          this.x = param1;
  61.          this.y = param2;
  62.       }
  63.       
  64.       public function move() : void
  65.       {
  66.          this.x += this.speedX;
  67.          this.y += this.speedY;
  68.       }
  69.       
  70.       public function redraw() : void
  71.       {
  72.          this.anim.x = this.x;
  73.          this.anim.y = this.y;
  74.       }
  75.       
  76.       protected function getPerformedAnim(param1:MovieClip) : MovieClip
  77.       {
  78.          if(this._animationPerformerManager == null)
  79.          {
  80.             this._animationPerformerManager = new AnimationManager();
  81.          }
  82.          var _loc2_:Animation = this._animationPerformerManager.addAnimation(param1);
  83.          if(param1.parent != null)
  84.          {
  85.             _loc2_.x = param1.getRect(param1).x;
  86.             _loc2_.y = param1.getRect(param1).y;
  87.             param1.parent.addChildAt(_loc2_,param1.parent.getChildIndex(param1));
  88.             param1.visible = false;
  89.          }
  90.          _loc2_.gotoAndStop(1);
  91.          return _loc2_;
  92.       }
  93.       
  94.       public function destroy() : void
  95.       {
  96.          if(this.anim is Animation)
  97.          {
  98.             (this.anim as Animation).destroy();
  99.          }
  100.          this.anim = null;
  101.          this._movie = null;
  102.          this.DECOR = null;
  103.       }
  104.    }
  105. }
  106.