51 lines
No EOL
1.8 KiB
C#
51 lines
No EOL
1.8 KiB
C#
using System.Diagnostics;
|
|
using FNAF_Server.Enemies;
|
|
using FNAF_Server.Map;
|
|
using GlobalClassLib;
|
|
using PacketLib;
|
|
|
|
namespace FNAF_Server;
|
|
|
|
public class GameLogic {
|
|
|
|
public const int START_CAMERA = 12;
|
|
|
|
private static MovementOpportunity secondCycleTimer = new(1000);
|
|
public static bool NSecondUpdate{ get; private set; } = false;
|
|
|
|
public static MapTile P1Office;
|
|
public static MapTile P2Office;
|
|
public static MapTile[] Offices =>[P1Office, P2Office];
|
|
|
|
public static void Init() {
|
|
// Create map
|
|
MapManager.InitMap();
|
|
P1Office = MapManager.Get(10);
|
|
P2Office = MapManager.Get(14);
|
|
|
|
//Send map to client
|
|
TileConnector[] connectors = MapManager.GetAllConnectors();
|
|
int[] connectorsConverted = new int[connectors.Length * 3];
|
|
for (int i = 0; i < connectors.Length; i++){
|
|
connectorsConverted[i * 3] = connectors[i].Tiles.tile1.Id;
|
|
connectorsConverted[i * 3 + 1] = connectors[i].Tiles.tile2.Id;
|
|
connectorsConverted[i * 3 + 2] = (int)connectors[i].Type;
|
|
}
|
|
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 SpotEnemy(0)).Spawn(MapManager.Get(12));
|
|
|
|
secondCycleTimer.Start();
|
|
}
|
|
public static void Update() {
|
|
if(secondCycleTimer.Check()) NSecondUpdate = true;
|
|
|
|
EnemyManager.Update();
|
|
|
|
NSecondUpdate = false;
|
|
}
|
|
|
|
} |