import Phaser from 'phaser'

class Human extends Phaser.Sprite {
    constructor(game, x, y, asset, frame) {
        super(game, x, y, asset, frame);
        this.activeWeapon = null;
        this.activeWeapon = {};
        this.anchor.setTo(0.5, 0.5);
        this.weaponList = [
            'flame',
            'm4',
            'rocket',
            'uzi'
        ];
    }

    loadAnimations() {
        this.animations.add('walking', Phaser.Animation.generateFrameNames('walking_', 1, 4), 8, true);
        this.animations.add('dying', Phaser.Animation.generateFrameNames('dying_', 1, 2), 8, true);
        this.animations.add('rocket', Phaser.Animation.generateFrameNames('rocket_', 1, 5), 8, true);
        this.animations.add('punch', Phaser.Animation.generateFrameNames('punch_', 1, 4), 8, true);
        this.animations.add('uzi', Phaser.Animation.generateFrameNames('uzi_', 1, 5), 8, true);
        this.animations.add('m4', Phaser.Animation.generateFrameNames('m4_', 1, 4), 8, true);
        this.animations.add('flame', Phaser.Animation.generateFrameNames('flame_', 1, 5), 8, true);

        this.animations.add('idle', ['idle'], 8, false);

        this.animations.add('explosion', Phaser.Animation.generateFrameNames('explosion', 1, 36), 8, true);
    }

    startAnimation(animation, repeat = false) {
        switch (animation) {
            case 'walking':
                this.startWalking(repeat);
                break;
            default:
                this.animations.play(animation, 8, repeat);
        }
    }

    startWalking(repeat = false) {
        let activeWeaponName = _.get(this, 'activeWeapon.name');
        if (activeWeaponName) {
            this.animations.play(activeWeaponName, 8, repeat);
        } else {
            this.animations.play('walking', 8, repeat);
        }
    }

    killPlayer() {
        this.body.velocity.x = 0;
        this.body.velocity.y = 0;
        this.startAnimation('dying');
        this.alive = false;
    }
}

export default Human;
@@ -1,21 +1,31 @@
 import 
+%7B
 Phaser
+, Sprite%7D
  from 'p
@@ -1981,16 +1981,271 @@
  false;%0A
+        let bloodSplatter = new Sprite(this.game, 0, 0, %60blood$%7Bthis.game.rnd.integerInRange(1, 3)%7D%60);%0A        bloodSplatter.anchor.setTo(0.5, 0.5);%0A        bloodSplatter.angle = this.game.rnd.integerInRange(0, 359);%0A        this.addChild(bloodSplatter);%0A
     %7D%0A%7D%0A

Add random blood spatter when AI is killed.