Advertisement
Uhfgood

Enemy class

Nov 1st, 2015
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.02 KB | None | 0 0
  1. package;
  2.  
  3. import flixel.FlxG;
  4. import flixel.FlxSprite;
  5. import flixel.FlxObject;
  6. import flixel.tweens.FlxEase;
  7. import flixel.tweens.FlxTween;
  8. import flixel.util.FlxMath;
  9. import flixel.util.FlxPoint;
  10. import flixel.util.FlxVelocity;
  11.  
  12. enum HypnoModes
  13. {
  14.     AWAKE;  // means not hypnotized
  15.     HYPNOTIZED;
  16.     LEVITATE;
  17.     CARRIED;
  18. }
  19.  
  20. /**
  21.  * ...
  22.  * @author Keith Weatherby II
  23.  */
  24. class Enemy extends GameObject
  25. {
  26.  
  27.     public var hypnoTimeCounter = 0;
  28.     public var hypnoTime = 420;
  29.     public var awakenTime = 360;
  30.    
  31.     public var hypnoMode : HypnoModes = AWAKE;
  32.    
  33.     public function new( gameLevel : PlayState, object : Dynamic )
  34.     {
  35.         super( gameLevel, object );
  36.        
  37.         ID = object.ID;
  38.         this.awakenTime = object.awakenTime;
  39.         this.hypnoTime = object.hypnoTime;
  40.     }
  41.  
  42.     override public function update():Void
  43.     {
  44.         this.DoActions();
  45.         this.Animate();
  46.         super.update();    
  47.     }
  48.    
  49.     public function DoActions()
  50.     {
  51.         switch( hypnoMode )
  52.         {
  53.             case AWAKE:
  54.             case HYPNOTIZED:
  55.             case LEVITATE:
  56.             case CARRIED:
  57.                
  58.         }  // end switch
  59.        
  60.         if ( hypnoMode == HYPNOTIZED || hypnoMode == LEVITATE || hypnoMode == CARRIED )
  61.         {
  62.             this.hypnoTimeCounter++;
  63.             if ( this.hypnoTimeCounter > this.hypnoTime )
  64.             {
  65.                 this.hypnoTimeCounter = 0;
  66.                 this.hypnoMode = AWAKE;
  67.             }
  68.         }
  69.     }
  70.    
  71.     public function Animate()
  72.     {
  73.         switch( hypnoMode )
  74.         {
  75.             case AWAKE:
  76.                 this.animation.play( "normal" );
  77.                
  78.             case HYPNOTIZED:
  79.                 if ( this.hypnoTimeCounter > this.awakenTime )
  80.                     this.animation.play( "awaken" );
  81.                 else
  82.                     this.animation.play( "hypnotized" );
  83.                    
  84.             case LEVITATE, CARRIED:
  85.                 if ( this.hypnoTimeCounter > this.awakenTime )
  86.                     this.animation.play( "awaken" );
  87.                 else
  88.                     this.animation.play( "pop" );
  89.                    
  90.         }  // end switch
  91.     }
  92.    
  93.     public function Murder()
  94.     {
  95.         this.kill();       
  96.     }
  97.    
  98.     public function SetHypnoMode( mode : HypnoModes )
  99.     {
  100.         hypnoMode = mode;
  101.     }
  102.    
  103.     public override function Regen()
  104.     {
  105.         super.Regen();     
  106.         width = oldWidth - 8;
  107.         offset.x = 4;
  108.         this.immovable = false;
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement