using GlobalClassLib; using ONDServer.Map; using ONDServer.Net; using PacketLib; namespace ONDServer.Enemies; public abstract class Enemy : GlobalEnemy { public int Difficulty { get; protected set; } public abstract bool BlocksTile { get; set; } public bool Spawned { get; set; } protected OpportunityTimer MovementOpportunity; protected Enemy(int difficulty, int movementInterval) { MovementOpportunity = new(movementInterval); SetDifficulty(difficulty); } // unused public virtual void SpawnSilent(MapTile location) { Console.WriteLine($"!!! Silent spawn not implemented for enemy {Type} ({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) { if (difficulty > 10) return; Difficulty = difficulty; MovementOpportunity.MovementChance = ((5 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (5 + Math.Pow(1.5f, 10)); } }