using GlobalClassLib; using ONDServer.Map; using ONDServer.Net; using PacketLib; namespace ONDServer.Enemies; public class SpotEnemy : Enemy { public SpotEnemy(int difficulty) : base(difficulty, 6000) { path = [MapManager.Get(10), MapManager.Get(11), MapManager.Get(12), MapManager.Get(13), MapManager.Get(14)]; pathId = 2; } public override string Name{ get; } = "Spot"; public override EnemyType Type{ get; } = EnemyType.SPOT; public override bool BlocksTile{ get; set; } = false; public bool Active{ get; set; } = false; private MapTile[] path; private int pathId; private int p1WatchCounter = 0; private int p2WatchCounter = 0; public override void Reset() { if (Location.Owner != null){ Location.Owner.State.Power -= 200; } pathId = 2; Location = path[pathId]; Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]); } public override void Update() { if (GameLogic.NSecondUpdate){ if(!MovementOpportunity.Running) MovementOpportunity.Start(); if (Active){ if (Server.P1.State.MonitorUp && Server.P1.State.Camera == Location.Id) p1WatchCounter++; if (Server.P2.State.MonitorUp && Server.P2.State.Camera == Location.Id) p2WatchCounter++; Console.WriteLine($"P1: {p1WatchCounter} | P2: {p2WatchCounter}"); } } if (MovementOpportunity.CheckAndRoll()){ if(!Active) { Active = true; MovementOpportunity.Interval = 10_000; MovementOpportunity.GuaranteeSuccess(true); Server.SendUpdateToAll([GameEvent.SPOT_SET_ACTIVE(Id, true)]); } else{ MovementOpportunity.Interval = 6000; MovementOpportunity.GuaranteeSuccess(false); MovementOpportunity.Stop(); if (p1WatchCounter > p2WatchCounter){ pathId++; if (Location.GetConnector(path[pathId])!.Blocked){ Reset(); } else if (pathId == path.Length - 1){ Attack(Server.P2); } } else if (p2WatchCounter > p1WatchCounter){ pathId--; if (Location.GetConnector(path[pathId])!.Blocked){ Reset(); } else if (pathId == 0){ Attack(Server.P1); } } Location = path[pathId]; Active = false; p1WatchCounter = 0; p2WatchCounter = 0; Server.SendUpdateToAll([GameEvent.ENEMY_MOVEMENT(Id, Location.Id), GameEvent.SPOT_SET_ACTIVE(Id, false)]); } } } public override void Spawn(MapTile location) { base.Spawn(location); Server.SendUpdateToAll([GameEvent.ENEMY_SPAWN(Type, Id, Difficulty, Location.Id)]); } }