import Phaser from "phaser";
import Graphics from "../assets/Graphics";

const hp = 10;
const damage = 5;
const speed = 50;
const attackSpeed = 500;
const attackDuration = 165;
const attackCooldown = attackDuration * 2;

export default class Professor {
  public sprite: Phaser.Physics.Arcade.Sprite;

  private attackUntil: number;
  private attackLockedUntil: number;
  private body: Phaser.Physics.Arcade.Body;

  constructor(x: number, y: number, scene: Phaser.Scene, player: any) {
	this.alive = true;
	this.hp = hp;
	this.canAttack = false;

	var me = this;
	function hit () {
		//TODO
	}
    this.line = new Phaser.Geom.Line();
	this.player = player;
    this.sprite = scene.physics.add.sprite(x, y, Graphics.professor.name, 0);
    this.sprite.setSize(22, 10);
	this.sprite.setOffset(10, 40);
    this.sprite.anims.play(Graphics.professor.animations.idleProf.name);
	this.sprite.setScale(0.6);

    this.attackUntil = 0;
    this.attackLockedUntil = 0;

    this.body = <Phaser.Physics.Arcade.Body>this.sprite.body;
	this.body.immovable = true;
	scene.physics.add.collider(player.sprite, this.sprite, hit, null, this);
  }

  update(fov: any, map: any, time: number) {
	this.sprite.depth = this.sprite.y;
  }
}
