Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package game.enemies{
  2.     import flash.display.MovieClip;
  3.     import flash.utils.getTimer;
  4.  
  5.     public class StatusEffect extends MovieClip {
  6.        
  7.         public var name_:String;
  8.  
  9.         public var enemy:Enemy;
  10.  
  11.         public var duration:int;
  12.  
  13.         public var frequency:int;
  14.  
  15.         private var startTime:int;
  16.         private var lastApplication:int;
  17.  
  18.         public function StatusEffect(name_:String, enemy:Enemy, duration:int, frequency:int) {
  19.             this.name_ = name_;
  20.             this.enemy = enemy;
  21.             this.duration = duration;
  22.             this.frequency = frequency;
  23.             var enemyRotation = enemy.rotation;
  24.             enemy.rotation = 0;
  25.             width = enemy.height * 1.5;
  26.             height = enemy.height * 1.5;
  27.             enemy.rotation = enemyRotation;
  28.             x = enemy.x
  29.             y = enemy.y
  30.             Game.stage_.addChildAt(this, Game.stage_.getChildIndex(enemy) - 1);
  31.             this.startTime = getTimer();
  32.         }
  33.  
  34.         public function applyEffect() {
  35.             x = enemy.x
  36.             y = enemy.y
  37.             if (getTimer() - startTime >= duration) {
  38.                 destroy();
  39.             }
  40.             if (getTimer() - lastApplication >= frequency) {
  41.                 lastApplication = getTimer();
  42.                 specificApplication();
  43.             }
  44.         }
  45.        
  46.         protected function specificApplication() {
  47.            
  48.         }
  49.        
  50.         public function destroy() {
  51.             enemy.status.splice(enemy.status.indexOf(this), 1);
  52.             Game.stage_.removeChild(this);
  53.         }
  54.  
  55.     }
  56.  
  57. }
  58.  
  59. package game.enemies {
  60.    
  61.     public class FireEffect extends StatusEffect {
  62.  
  63.         public function FireEffect(e:Enemy) {
  64.             super("fire", e, 50000, 2500);
  65.         }
  66.        
  67.         override protected function specificApplication() {
  68.             super.enemy.damage(1);
  69.         }
  70.  
  71.     }
  72.    
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement