Projekt přejmenován. Neko nastaven na výchozí pozici

This commit is contained in:
Perry 2026-03-22 18:31:05 +01:00
parent 1a27dd6fab
commit ceac37920b
104 changed files with 873 additions and 208 deletions

View file

@ -0,0 +1,70 @@
using System.Net.Mime;
using GlobalClassLib;
using ONDServer.Map;
using PacketLib;
namespace ONDServer.Enemies;
public class DashEnemy : Enemy {
public DashEnemy(int difficulty) : base(difficulty) {
movementOpportunity = new(5000);
SetDifficulty(difficulty);
}
public override string Name{ get; } = "Dash";
public override int TypeId{ get; } = (int)EnemyType.DASH;
public override bool BlocksTile{ get; set; } = false;
private MovementOpportunity movementOpportunity;
private readonly (MapTile tile, Direction p1AttackDir, Direction p2AttackDir)[] positions =[
(MapManager.Get(7), Direction.EAST, Direction.WEST),
(MapManager.Get(12), Direction.NORTH, Direction.NORTH),
(MapManager.Get(17), Direction.WEST, Direction.EAST)
];
private int currentPosIndex = 0;
private Random random = new();
public override void Reset() {
int roll = random.Next(0, positions.Length - 1);
if (roll >= currentPosIndex) roll++;
currentPosIndex = roll;
Location = positions[roll].tile;
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 Spawn(MapTile location) {
currentPosIndex = positions.ToList().FindIndex(p => p.tile == location);
if (currentPosIndex == -1){
Console.WriteLine("Dash failed to spawn on " + location.Id);
return;
}
base.Spawn(location);
movementOpportunity.Start();
Server.SendUpdateToAll([GameEvent.ENEMY_SPAWN(TypeId, Id, Difficulty, Location.Id)]);
}
public override void Update() {
base.Update();
if (movementOpportunity.CheckAndRoll()){
bool attackP1 = !Server.P1.state.doorStates[(int)positions[currentPosIndex].p1AttackDir];
bool attackP2 = !Server.P2.state.doorStates[(int)positions[currentPosIndex].p2AttackDir];
if (attackP1 != attackP2){
if(attackP1) Attack(Server.P1);
else if(attackP2) Attack(Server.P2);
return;
}
Reset();
}
}
}