const schema = require("@colyseus/schema"), GameObject = require("./GameObject.js"); const DEFAULT_VELOCITY = 1, DEFAULT_HEALTH = 100, DEFAULT_WIDTH = 50, DEFAULT_HEIGHT = 50, DEFAULT_DAMAGE = 10, DEFAULT_HIT_BOX_RADIUS = 30; class Enemy extends GameObject { constructor(x, y, width, height, hitBoxRadius, velocity, direction) { super(x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_HIT_BOX_RADIUS, DEFAULT_VELOCITY, direction); this.lp = DEFAULT_HEALTH; this.damage = DEFAULT_DAMAGE; } setFocus() { this.focus = true; } removeFocus() { this.focus = false; } static createEnemy(rangeX, rangeY, targetX, targetY) { let xPos = parseInt(Math.random() * rangeX), yPos = parseInt(Math.random() * rangeY), direction = Math.atan2(targetY - yPos, targetX - xPos) * 180 / Math.PI; return new Enemy(xPos, yPos, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_HIT_BOX_RADIUS, DEFAULT_VELOCITY, direction); } } schema.defineTypes(Enemy, { lp: "number", damage: "number" }); module.exports = Enemy;