2026-03-08 16:55:49 +01:00
|
|
|
using GlobalClassLib;
|
2026-03-22 18:31:05 +01:00
|
|
|
using ONDServer.Map;
|
2026-03-28 09:59:31 +01:00
|
|
|
using ONDServer.Net;
|
2026-03-09 20:05:21 +01:00
|
|
|
using PacketLib;
|
2026-03-08 16:55:49 +01:00
|
|
|
|
2026-03-22 18:31:05 +01:00
|
|
|
namespace ONDServer.Enemies;
|
2026-03-08 16:55:49 +01:00
|
|
|
|
|
|
|
|
public abstract class Enemy : GlobalEnemy<MapTile, TileConnector> {
|
2026-03-17 20:14:29 +01:00
|
|
|
public int Difficulty { get; protected set; }
|
2026-03-28 09:59:31 +01:00
|
|
|
public abstract bool BlocksTile { get; set; }
|
|
|
|
|
public bool Spawned { get; set; }
|
|
|
|
|
|
|
|
|
|
protected OpportunityTimer MovementOpportunity;
|
2026-03-25 16:37:18 +01:00
|
|
|
|
|
|
|
|
protected Enemy(int difficulty, int movementInterval) {
|
2026-03-28 09:59:31 +01:00
|
|
|
MovementOpportunity = new(movementInterval);
|
2026-03-25 16:37:18 +01:00
|
|
|
SetDifficulty(difficulty);
|
2026-03-08 16:55:49 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-28 09:59:31 +01:00
|
|
|
// unused
|
2026-03-08 16:55:49 +01:00
|
|
|
public virtual void SpawnSilent(MapTile location) {
|
2026-03-28 09:59:31 +01:00
|
|
|
Console.WriteLine($"!!! Silent spawn not implemented for enemy {Type} ({Name}), reverting to regular spawn");
|
2026-03-08 16:55:49 +01:00
|
|
|
Spawn(location);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Spawn(MapTile location) {
|
|
|
|
|
base.Spawn(location);
|
|
|
|
|
Spawned = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract void Reset();
|
2026-03-09 20:05:21 +01:00
|
|
|
|
|
|
|
|
public virtual void Attack(ServerPlayer player) {
|
2026-03-28 09:59:31 +01:00
|
|
|
Server.SendUpdateToAll([GameEvent.ENEMY_ATTACK(Id, player.State.Pid)]);
|
2026-03-09 20:05:21 +01:00
|
|
|
GameLogic.DeclareWinner(Server.OtherPlayer(player));
|
|
|
|
|
}
|
2026-03-25 16:37:18 +01:00
|
|
|
|
|
|
|
|
public virtual void SetDifficulty(int difficulty) {
|
2026-03-28 09:59:31 +01:00
|
|
|
if (difficulty > 10) return;
|
2026-03-25 16:37:18 +01:00
|
|
|
Difficulty = difficulty;
|
2026-03-28 09:59:31 +01:00
|
|
|
MovementOpportunity.MovementChance = ((5 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (5 + Math.Pow(1.5f, 10));
|
2026-03-25 16:37:18 +01:00
|
|
|
}
|
2026-03-08 16:55:49 +01:00
|
|
|
}
|