Bugfixy, odstranění nepoužívaných tříd CameraSystem a ITargetingEnemy, přidání dedikované třídy ReturnToMenuElement, předělání pathfinding algoritmu z DFS na BFS, přesun správy obtížnosti do abstraktní třídy Enemy, přidání scriptů pro kompilaci na aplikaci nevyžadující dotnet

This commit is contained in:
Perry 2026-03-25 16:37:18 +01:00
parent ceac37920b
commit e5d746d597
24 changed files with 258 additions and 138 deletions

View file

@ -11,23 +11,14 @@ public class MareEnemy : Enemy {
public override bool BlocksTile{ get; set; } = true;
private MarePathfinder pathfinder;
private MovementOpportunity movementOpportunity;
public ServerPlayer Target{ get; set; }
public MareEnemy(int difficulty) : base(difficulty) {
// private MovementOpportunity movementOpportunity;
public ServerPlayer? Target{ get; set; }
public MareEnemy(int difficulty) : base(difficulty, 6000) {
pathfinder = new MarePathfinder(this, 1);
if (Server.P1.state.power > Server.P2.state.power){
Target = Server.P2;
}
else if(Server.P1.state.power < Server.P2.state.power){
Target = Server.P1;
}
else{
Target = new Random().Next(2) == 0 ? Server.P1 : Server.P2;
}
movementOpportunity = new MovementOpportunity(5000);
SetDifficulty(difficulty);
// movementOpportunity = new MovementOpportunity(5000);
// SetDifficulty(difficulty);
}
public override void Reset() {
@ -38,19 +29,28 @@ public class MareEnemy : Enemy {
Location = decision.nextTile!;
}
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);;
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
}
public override void SetDifficulty(int difficulty) {
Difficulty = difficulty;
movementOpportunity.MovementChance =
((5 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (5 + Math.Pow(1.5f, 10));
}
// public override void SetDifficulty(int difficulty) {
// Difficulty = difficulty;
// movementOpportunity.MovementChance =
// ((5 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (5 + Math.Pow(1.5f, 10));
// }
public override void Spawn(MapTile location) {
base.Spawn(location);
// stopwatch.Start();
// stopwatch.Start()
if (Server.P1.state.power > Server.P2.state.power){
Target = Server.P2;
}
else if(Server.P1.state.power < Server.P2.state.power){
Target = Server.P1;
}
else{
Target = new Random().Next(2) == 0 ? Server.P1 : Server.P2;
}
movementOpportunity.Start();
pathfinder.TakenPath.Add(Location);
@ -64,6 +64,8 @@ public class MareEnemy : Enemy {
if (Location.Owner != null && Location.Lit){
Attack(Location.Owner);
}
if (Target == null) return;
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(Target.state.officeTileId));
switch (decision.type){