OneNightDuel/ONDServer/Enemies/Enemy.cs

37 lines
No EOL
1.1 KiB
C#

using GlobalClassLib;
using ONDServer.Map;
using ONDServer.Net;
using PacketLib;
namespace ONDServer.Enemies;
public abstract class Enemy : GlobalEnemy<MapTile, TileConnector> {
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);
}
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));
}
}