Renderování textu, jumpscary, win a lose screen
This commit is contained in:
parent
9bfe63a166
commit
e6128dc9f5
21 changed files with 360 additions and 84 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using FNAF_Server.Map;
|
||||
using GlobalClassLib;
|
||||
using PacketLib;
|
||||
|
||||
namespace FNAF_Server.Enemies;
|
||||
|
||||
|
|
@ -18,9 +19,12 @@ public abstract class Enemy : GlobalEnemy<MapTile, TileConnector> {
|
|||
public override void Spawn(MapTile location) {
|
||||
base.Spawn(location);
|
||||
Spawned = true;
|
||||
// EnemyManager.AddEnemy(this);
|
||||
}
|
||||
|
||||
public abstract void Reset();
|
||||
public abstract void Attack(ServerPlayer player);
|
||||
|
||||
public virtual void Attack(ServerPlayer player) {
|
||||
Server.SendUpdateToAll([GameEvent.ENEMY_ATTACK(Id, player.state.pid)]);
|
||||
GameLogic.DeclareWinner(Server.OtherPlayer(player));
|
||||
}
|
||||
}
|
||||
|
|
@ -41,11 +41,6 @@ public class LurkEnemy : Enemy {
|
|||
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
|
||||
}
|
||||
|
||||
public override void Attack(ServerPlayer player) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public override void Update() {
|
||||
base.Update();
|
||||
|
||||
|
|
@ -58,7 +53,8 @@ public class LurkEnemy : Enemy {
|
|||
Console.WriteLine($"Enemy {TypeId} ({Name}) moving to {Location.PositionAsString})");
|
||||
break;
|
||||
case Pathfinder.Decision.AttackType:
|
||||
throw new NotImplementedException();
|
||||
Attack(decision.attackTarget!);
|
||||
break;
|
||||
case Pathfinder.Decision.ResetType:
|
||||
Reset();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -33,11 +33,6 @@ public class NekoEnemy : Enemy {
|
|||
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
|
||||
}
|
||||
|
||||
public override void Attack(ServerPlayer player) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public override void Update() {
|
||||
base.Update();
|
||||
|
||||
|
|
@ -50,7 +45,8 @@ public class NekoEnemy : Enemy {
|
|||
Console.WriteLine($"Enemy {TypeId} ({Name}) moving to {Location.PositionAsString})");
|
||||
break;
|
||||
case Pathfinder.Decision.AttackType:
|
||||
throw new NotImplementedException();
|
||||
Attack(decision.attackTarget!);
|
||||
break;
|
||||
case Pathfinder.Decision.ResetType:
|
||||
Reset();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@ public class SpotEnemy : Enemy {
|
|||
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
|
||||
}
|
||||
|
||||
public override void Attack(ServerPlayer player) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
if (GameLogic.NSecondUpdate){
|
||||
if(!movementOpportunity.Running)
|
||||
|
|
@ -65,7 +61,7 @@ public class SpotEnemy : Enemy {
|
|||
Reset();
|
||||
}
|
||||
else if (pathId == path.Length - 1){
|
||||
Attack(Server.P1);
|
||||
Attack(Server.P2);
|
||||
}
|
||||
}
|
||||
else if (p2WatchCounter > p1WatchCounter){
|
||||
|
|
@ -74,7 +70,7 @@ public class SpotEnemy : Enemy {
|
|||
Reset();
|
||||
}
|
||||
else if (pathId == 0){
|
||||
Attack(Server.P2);
|
||||
Attack(Server.P1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ public class GameLogic {
|
|||
Server.SendPacket(new MapInitPacket{Connectors = connectorsConverted, UpsideDown = false}, Server.P1.peer);
|
||||
Server.SendPacket(new MapInitPacket{Connectors = connectorsConverted, UpsideDown = true}, Server.P2.peer);
|
||||
|
||||
// EnemyManager.AddEnemy(new LurkEnemy(0)).Spawn(MapManager.Get(12));
|
||||
EnemyManager.AddEnemy(new NekoEnemy(10)).Spawn(MapManager.Get(2));
|
||||
EnemyManager.AddEnemy(new LurkEnemy(10)).Spawn(MapManager.Get(12));
|
||||
EnemyManager.AddEnemy(new NekoEnemy(0)).Spawn(MapManager.Get(2));
|
||||
EnemyManager.AddEnemy(new SpotEnemy(0)).Spawn(MapManager.Get(12));
|
||||
|
||||
secondCycleTimer.Start();
|
||||
|
|
@ -47,5 +47,10 @@ public class GameLogic {
|
|||
|
||||
NSecondUpdate = false;
|
||||
}
|
||||
|
||||
|
||||
public static void DeclareWinner(ServerPlayer player) {
|
||||
Server.SendUpdateToAll([GameEvent.PLAYER_WIN(player.state.pid)]);
|
||||
Server.Stop();
|
||||
Console.WriteLine("Player " + player.state.pid + " won!");
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ public class Server {
|
|||
public static ServerPlayer P1;
|
||||
public static ServerPlayer P2;
|
||||
public static readonly Dictionary<int, ServerPlayer> Players = new();
|
||||
public static ServerPlayer OtherPlayer(ServerPlayer player) => player.state.pid == P1.state.pid ? P2 : P1;
|
||||
|
||||
private static EventBasedNetListener listener;
|
||||
private static NetManager server;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue