2026-03-09 20:05:21 +01:00
|
|
|
using System;
|
2026-03-08 16:55:49 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FNAF_Clone.GUI;
|
|
|
|
|
using FNAF_Clone.Map;
|
|
|
|
|
using GlobalClassLib;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
|
|
|
|
namespace FNAF_Clone;
|
|
|
|
|
|
2026-03-09 20:05:21 +01:00
|
|
|
public static class ClientEnemyManager {
|
2026-03-08 16:55:49 +01:00
|
|
|
private static Dictionary<int, ClientEnemy> enemies = new();
|
|
|
|
|
private static Point cameraCorner = new Point(64, 64);
|
|
|
|
|
|
2026-03-09 20:05:21 +01:00
|
|
|
private static Action defaultAfterJumpscare = UIManager.ShowDeathScreen;
|
2026-03-08 16:55:49 +01:00
|
|
|
public static void AddEnemy(ClientEnemy enemy) {
|
|
|
|
|
enemies.Add(enemy.Id, enemy);
|
2026-03-09 20:05:21 +01:00
|
|
|
UIManager.AddEnemySprite(enemy.Id, enemy.Sprite, enemy.JumpscareSprite);
|
2026-03-08 16:55:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void AddEnemyByTemplate(EnemyType type, int id, int difficulty, MapTileProjection location) {
|
|
|
|
|
switch (type){
|
|
|
|
|
case EnemyType.LURK:
|
2026-03-09 20:05:21 +01:00
|
|
|
AddEnemy(new ClientEnemy(
|
|
|
|
|
(int)type,
|
|
|
|
|
"Lurk",
|
|
|
|
|
id,
|
|
|
|
|
new UIElement(UIManager.EnemyAtlas[0], cameraCorner),
|
|
|
|
|
difficulty,
|
|
|
|
|
location,
|
|
|
|
|
new JumpscareUIElement(UIManager.EnemyAtlas[0], new(0, 0), 3, 2, 2, 0.1f, afterStop:defaultAfterJumpscare)));
|
2026-03-08 16:55:49 +01:00
|
|
|
break;
|
|
|
|
|
case EnemyType.NEKO:
|
2026-03-09 20:05:21 +01:00
|
|
|
AddEnemy(new ClientEnemy(
|
|
|
|
|
(int)type,
|
|
|
|
|
"Neko",
|
|
|
|
|
id,
|
|
|
|
|
new UIElement(UIManager.EnemyAtlas[1], cameraCorner),
|
|
|
|
|
difficulty,
|
|
|
|
|
location,
|
|
|
|
|
new JumpscareUIElement(UIManager.EnemyAtlas[1], new(0, -30), 3, 2, 2, 0.1f, afterStop:defaultAfterJumpscare)));
|
2026-03-08 16:55:49 +01:00
|
|
|
break;
|
|
|
|
|
case EnemyType.SPOT:
|
|
|
|
|
UIElement element =
|
2026-03-09 20:05:21 +01:00
|
|
|
new UIElement([UIManager.EnemyAtlas[2], UIManager.EnemyAtlas[3], UIManager.EnemyAtlas[4], UIManager.EnemyAtlas[5]], cameraCorner);
|
2026-03-08 16:55:49 +01:00
|
|
|
element.SetTexture(2);
|
2026-03-09 20:05:21 +01:00
|
|
|
AddEnemy(new ClientEnemy(
|
|
|
|
|
(int)type,
|
|
|
|
|
"Spot",
|
|
|
|
|
id,
|
|
|
|
|
element,
|
|
|
|
|
difficulty,
|
|
|
|
|
location,
|
|
|
|
|
new JumpscareUIElement(UIManager.EnemyAtlas[2], new(0, 0), 3, 2, 2, 0.1f, afterStop:defaultAfterJumpscare)));
|
2026-03-08 16:55:49 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Move(int id, MapTileProjection tile) {
|
|
|
|
|
enemies[id].Location = tile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ClientEnemy Get(int id) => enemies[id];
|
|
|
|
|
|
|
|
|
|
public static ClientEnemy[] GetByLocation(MapTileProjection tile) {
|
|
|
|
|
List<ClientEnemy> output = new();
|
|
|
|
|
foreach (var e in enemies.Values){
|
|
|
|
|
if (e.Location == tile){
|
|
|
|
|
output.Add(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return output.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|