Oprava spawnování monster, optimalizace v CommandProcessor a EventProcessor. Přesunutí některých tříd do vlastních namespaců, pročištění kódu, úpravy formátování, odstranění nepoužívaných souborů a zakomentovaného kódu
This commit is contained in:
parent
e5d746d597
commit
243f071a43
62 changed files with 873 additions and 1217 deletions
99
ONDClient/Enemies/ClientEnemyManager.cs
Normal file
99
ONDClient/Enemies/ClientEnemyManager.cs
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GlobalClassLib;
|
||||
using Microsoft.Xna.Framework;
|
||||
using ONDClient.GUI;
|
||||
using ONDClient.Map;
|
||||
|
||||
namespace ONDClient.Enemies;
|
||||
|
||||
public static class ClientEnemyManager {
|
||||
|
||||
private static Dictionary<int, ClientEnemy> enemies = new();
|
||||
private static readonly Point cameraCorner = new(64, 64);
|
||||
private static readonly Action defaultAfterJumpscare = UIManager.ShowDeathScreen;
|
||||
|
||||
public static void AddEnemy(ClientEnemy enemy) {
|
||||
enemies.Add(enemy.Id, enemy);
|
||||
UIManager.AddEnemySprite(enemy.Id, enemy.Sprite, enemy.JumpscareSprite);
|
||||
}
|
||||
|
||||
public static void AddEnemyByTemplate(EnemyType type, int id, MapTileProjection location) {
|
||||
switch (type){
|
||||
case EnemyType.LURK:
|
||||
AddEnemy(new ClientEnemy(
|
||||
type,
|
||||
"Lurk",
|
||||
id,
|
||||
new EnemyUIElement(UIManager.EnemyAtlas["lurk-lit"], UIManager.EnemyAtlas["lurk-unlit"], cameraCorner),
|
||||
location,
|
||||
new JumpscareUIElement(UIManager.EnemyAtlas["lurk-lit"], new(0, 0), 3, 2, 2, afterStop:defaultAfterJumpscare)
|
||||
));
|
||||
break;
|
||||
case EnemyType.NEKO:
|
||||
AddEnemy(new ClientEnemy(
|
||||
type,
|
||||
"Neko",
|
||||
id,
|
||||
new EnemyUIElement(UIManager.EnemyAtlas["neko-lit"], UIManager.EnemyAtlas["neko-unlit"], cameraCorner, 1),
|
||||
location,
|
||||
new JumpscareUIElement(UIManager.EnemyAtlas["neko-lit"], new(0, -30), 3, 2, 2, afterStop:defaultAfterJumpscare)
|
||||
));
|
||||
break;
|
||||
case EnemyType.SPOT:
|
||||
EnemyUIElement element =
|
||||
new EnemyUIElement([UIManager.EnemyAtlas["spot-awake-lit"], UIManager.EnemyAtlas["spot-asleep-lit"]],[UIManager.EnemyAtlas["spot-awake-unlit"], UIManager.EnemyAtlas["spot-asleep-unlit"]], cameraCorner, 2);
|
||||
element.SetTexture(true, 1);
|
||||
AddEnemy(new ClientEnemy(
|
||||
type,
|
||||
"Spot",
|
||||
id,
|
||||
element,
|
||||
location,
|
||||
new JumpscareUIElement(UIManager.EnemyAtlas["spot-awake-lit"], new(0, 0), 3, 2, 2, afterStop:defaultAfterJumpscare)
|
||||
));
|
||||
break;
|
||||
case EnemyType.DASH:
|
||||
AddEnemy(new ClientEnemy(
|
||||
type,
|
||||
"Dash",
|
||||
id,
|
||||
new EnemyUIElement(UIManager.EnemyAtlas["dash-lit"], UIManager.EnemyAtlas["dash-unlit"], cameraCorner, 3),
|
||||
location,
|
||||
new JumpscareUIElement(UIManager.EnemyAtlas["dash-lit"], new(0, 0), 3, 2, 2, afterStop:defaultAfterJumpscare)
|
||||
));
|
||||
break;
|
||||
case EnemyType.MARE:
|
||||
AddEnemy(new ClientEnemy(
|
||||
type,
|
||||
"Mare",
|
||||
id,
|
||||
new EnemyUIElement(UIManager.EnemyAtlas["mare-lit"], UIManager.EnemyAtlas["mare-unlit"], cameraCorner),
|
||||
location,
|
||||
new JumpscareUIElement(UIManager.EnemyAtlas["mare-lit"], new(0, 0), 3, 2, 2, afterStop:defaultAfterJumpscare)
|
||||
));
|
||||
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();
|
||||
}
|
||||
|
||||
public static void ClearEnemies() {
|
||||
enemies.Clear();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue