Projekt přejmenován. Neko nastaven na výchozí pozici
This commit is contained in:
parent
1a27dd6fab
commit
ceac37920b
104 changed files with 873 additions and 208 deletions
97
ONDServer/Enemies/SpotEnemy.cs
Normal file
97
ONDServer/Enemies/SpotEnemy.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using GlobalClassLib;
|
||||
using ONDServer.Map;
|
||||
using PacketLib;
|
||||
|
||||
namespace ONDServer.Enemies;
|
||||
|
||||
public class SpotEnemy : Enemy {
|
||||
public SpotEnemy(int difficulty) : base(difficulty) {
|
||||
path = [MapManager.Get(10), MapManager.Get(11), MapManager.Get(12), MapManager.Get(13), MapManager.Get(14)];
|
||||
pathId = 2;
|
||||
movementOpportunity = new(6000);
|
||||
SetDifficulty(difficulty);
|
||||
}
|
||||
|
||||
public override string Name{ get; } = "Spot";
|
||||
public override int TypeId{ get; } = (int)EnemyType.SPOT;
|
||||
public override bool BlocksTile{ get; set; } = false;
|
||||
|
||||
public bool Active{ get; set; } = false;
|
||||
|
||||
private MovementOpportunity movementOpportunity;
|
||||
private MapTile[] path;
|
||||
private int pathId;
|
||||
|
||||
private int p1WatchCounter = 0;
|
||||
private int p2WatchCounter = 0;
|
||||
|
||||
public override void Reset() {
|
||||
pathId = 2;
|
||||
Location = path[pathId];
|
||||
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
|
||||
}
|
||||
|
||||
public override void SetDifficulty(int difficulty) {
|
||||
Difficulty = difficulty;
|
||||
movementOpportunity.MovementChance = (2 * Math.Sign(difficulty) + difficulty) / 12.0;
|
||||
}
|
||||
|
||||
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 = 12_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(TypeId, Id, Difficulty, Location.Id)]);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue