using GlobalClassLib; using ONDServer.Map; using PacketLib; namespace ONDServer.Enemies; public abstract class Enemy : GlobalEnemy { public int Difficulty { get; protected set; } protected MovementOpportunity movementOpportunity; protected Enemy(int difficulty, int movementInterval) { movementOpportunity = new(movementInterval); SetDifficulty(difficulty); } public abstract bool BlocksTile { get; set; } public bool Spawned { get; set; } public virtual void SpawnSilent(MapTile location) { Console.WriteLine($"!!! Silent spawn not implemented for enemy {TypeId} ({Name}), reverting to regular spawn"); Spawn(location); } public override void Spawn(MapTile location) { base.Spawn(location); Spawned = true; } public abstract void Reset(); public virtual void Attack(ServerPlayer player) { Server.SendUpdateToAll([GameEvent.ENEMY_ATTACK(Id, player.state.pid)]); GameLogic.DeclareWinner(Server.OtherPlayer(player)); } public virtual void SetDifficulty(int difficulty) { Difficulty = difficulty; movementOpportunity.MovementChance = ((5 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (5 + Math.Pow(1.5f, 10)); } }