Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package game.enemies{
- import flash.display.MovieClip;
- import flash.utils.getTimer;
- public class StatusEffect extends MovieClip {
- public var name_:String;
- public var enemy:Enemy;
- public var duration:int;
- public var frequency:int;
- private var startTime:int;
- private var lastApplication:int;
- public function StatusEffect(name_:String, enemy:Enemy, duration:int, frequency:int) {
- this.name_ = name_;
- this.enemy = enemy;
- this.duration = duration;
- this.frequency = frequency;
- var enemyRotation = enemy.rotation;
- enemy.rotation = 0;
- width = enemy.height * 1.5;
- height = enemy.height * 1.5;
- enemy.rotation = enemyRotation;
- x = enemy.x
- y = enemy.y
- Game.stage_.addChildAt(this, Game.stage_.getChildIndex(enemy) - 1);
- this.startTime = getTimer();
- }
- public function applyEffect() {
- x = enemy.x
- y = enemy.y
- if (getTimer() - startTime >= duration) {
- destroy();
- }
- if (getTimer() - lastApplication >= frequency) {
- lastApplication = getTimer();
- specificApplication();
- }
- }
- protected function specificApplication() {
- }
- public function destroy() {
- enemy.status.splice(enemy.status.indexOf(this), 1);
- Game.stage_.removeChild(this);
- }
- }
- }
- package game.enemies {
- public class FireEffect extends StatusEffect {
- public function FireEffect(e:Enemy) {
- super("fire", e, 50000, 2500);
- }
- override protected function specificApplication() {
- super.enemy.damage(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement