Přidán build script, předělaná struktura, funkční spouštění serveru z clienta. Client je schopen fungovat po více her bez restartu. Bugfixy
This commit is contained in:
parent
c942d23a87
commit
1a27dd6fab
22 changed files with 269 additions and 136 deletions
5
.idea/.idea.FNAF_Clone/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/.idea.FNAF_Clone/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
|
|
@ -12,10 +12,17 @@
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AKeyValuePair_00602_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F384e456bc26f45f5a6a6a20ae50c6e0dd1a400_003Fe8_003F7272ae72_003FKeyValuePair_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AKeyValuePair_00602_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F384e456bc26f45f5a6a6a20ae50c6e0dd1a400_003Fe8_003F7272ae72_003FKeyValuePair_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003Fe4_003F9c3fcf71_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003Fe4_003F9c3fcf71_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetManager_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3d47105f47a240929625d0f531812b9e1c000_003Fd6_003Fec041615_003FNetManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetManager_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3d47105f47a240929625d0f531812b9e1c000_003Fd6_003Fec041615_003FNetManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetPacketProcessor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3d47105f47a240929625d0f531812b9e1c000_003F68_003Fc826a80a_003FNetPacketProcessor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetSerializer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3d47105f47a240929625d0f531812b9e1c000_003Fcc_003F8a34584a_003FNetSerializer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetSerializer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3d47105f47a240929625d0f531812b9e1c000_003Fcc_003F8a34584a_003FNetSerializer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASdlGamePlatform_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa69b121f85054691b2a8d28643003c23136600_003F57_003F45ea073b_003FSdlGamePlatform_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASpriteBatch_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa69b121f85054691b2a8d28643003c23136600_003F98_003F17ad8de4_003FSpriteBatch_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASpriteBatch_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa69b121f85054691b2a8d28643003c23136600_003F98_003F17ad8de4_003FSpriteBatch_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003Fb3_003F92670209_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003Fb3_003F92670209_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffd792102e2a04b889c29784ca9de4981d1a000_003F2a_003Fa31b08a3_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelpers_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003F48_003F95b0ef9d_003FThrowHelpers_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelpers_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003F48_003F95b0ef9d_003FThrowHelpers_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003Ffb_003Fa0fd6fc3_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003Ffb_003Fa0fd6fc3_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffd792102e2a04b889c29784ca9de4981d1a000_003F8f_003F6419ac7c_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATitleContainer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa69b121f85054691b2a8d28643003c23136600_003F62_003F374a72ad_003FTitleContainer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATitleContainer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa69b121f85054691b2a8d28643003c23136600_003F62_003F374a72ad_003FTitleContainer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AValueTuple_00602_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003F09_003F312b9770_003FValueTuple_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AValueTuple_00602_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5e56f40aa42e4fc4b94786ec57da7544d1a400_003F09_003F312b9770_003FValueTuple_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||||
|
<Assembly Path="/home/perry/RiderProjects/FNAF_Clone/FNAF_Clone/link/MonoGameLibrary.dll" />
|
||||||
|
</AssemblyExplorer></s:String></wpf:ResourceDictionary>
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
@ -37,9 +38,8 @@ public class Client {
|
||||||
public static ClientPlayer Opponent { get; } = new();
|
public static ClientPlayer Opponent { get; } = new();
|
||||||
|
|
||||||
public static ClientPlayer GetPlayer(int pid) => Player.state.pid == pid ? Player : Opponent;
|
public static ClientPlayer GetPlayer(int pid) => Player.state.pid == pid ? Player : Opponent;
|
||||||
|
|
||||||
public static void Connect(string endPoint, int port) {
|
public static void Init() {
|
||||||
State = ConnectionState.CONNECTING;
|
|
||||||
writer = new NetDataWriter();
|
writer = new NetDataWriter();
|
||||||
processor = new NetPacketProcessor();
|
processor = new NetPacketProcessor();
|
||||||
|
|
||||||
|
|
@ -57,9 +57,6 @@ public class Client {
|
||||||
client = new NetManager(listener){
|
client = new NetManager(listener){
|
||||||
AutoRecycle = true
|
AutoRecycle = true
|
||||||
};
|
};
|
||||||
|
|
||||||
client.Start();
|
|
||||||
Console.WriteLine($"Connecting to server @ {endPoint}:{port}");
|
|
||||||
|
|
||||||
listener.NetworkReceiveEvent += (peer, reader, channel, method) => {
|
listener.NetworkReceiveEvent += (peer, reader, channel, method) => {
|
||||||
OnNetworkReceive(peer, reader, method);
|
OnNetworkReceive(peer, reader, method);
|
||||||
|
|
@ -71,6 +68,13 @@ public class Client {
|
||||||
State = ConnectionState.CONNECTED;
|
State = ConnectionState.CONNECTED;
|
||||||
SendPacket(new JoinPacket {username = Player.username == "" ? "Anonymous" : Player.username}, DeliveryMethod.ReliableOrdered);
|
SendPacket(new JoinPacket {username = Player.username == "" ? "Anonymous" : Player.username}, DeliveryMethod.ReliableOrdered);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Connect(string endPoint, int port) {
|
||||||
|
State = ConnectionState.CONNECTING;
|
||||||
|
|
||||||
|
client.Start();
|
||||||
|
Console.WriteLine($"Connecting to server @ {endPoint}:{port}");
|
||||||
|
|
||||||
new Thread(() => client.Connect(endPoint, port, "")).Start(); // TODO: figure out how keys work
|
new Thread(() => client.Connect(endPoint, port, "")).Start(); // TODO: figure out how keys work
|
||||||
}
|
}
|
||||||
|
|
@ -108,9 +112,18 @@ public class Client {
|
||||||
public static void OnPlayerUpdate(UpdatePlayerPacket packet) { // TODO: move this to a separate class
|
public static void OnPlayerUpdate(UpdatePlayerPacket packet) { // TODO: move this to a separate class
|
||||||
EventProcessor.Evaluate(packet.events);
|
EventProcessor.Evaluate(packet.events);
|
||||||
//Player.state = Player.state.pid == 0 ? packet.stateP1 : packet.stateP2;
|
//Player.state = Player.state.pid == 0 ? packet.stateP1 : packet.stateP2;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Disconnect() {
|
||||||
|
if (client == null || client.ConnectedPeersCount == 0) return;
|
||||||
|
client.DisconnectAll();
|
||||||
|
client.Stop();
|
||||||
|
State = ConnectionState.IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void StartServer() {
|
||||||
|
Process.Start("FNAF_Server");
|
||||||
|
// new Thread(() => Server.Start(9012)).Start();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -99,4 +99,8 @@ public static class ClientEnemyManager {
|
||||||
|
|
||||||
return output.ToArray();
|
return output.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ClearEnemies() {
|
||||||
|
enemies.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +105,8 @@ public class EventProcessor {
|
||||||
case 11:
|
case 11:
|
||||||
Console.WriteLine($"E: Player {e.Args[0]} won");
|
Console.WriteLine($"E: Player {e.Args[0]} won");
|
||||||
if(Client.Player.state.pid == e.Args[0]) UIManager.ShowVictoryScreen();
|
if(Client.Player.state.pid == e.Args[0]) UIManager.ShowVictoryScreen();
|
||||||
|
Client.Disconnect();
|
||||||
|
ClientEnemyManager.ClearEnemies();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 12: // game start
|
case 12: // game start
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,63 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<RollForward>Major</RollForward>
|
<RollForward>Major</RollForward>
|
||||||
<PublishReadyToRun>false</PublishReadyToRun>
|
<PublishReadyToRun>false</PublishReadyToRun>
|
||||||
<TieredCompilation>false</TieredCompilation>
|
<TieredCompilation>false</TieredCompilation>
|
||||||
<LangVersion>14</LangVersion>
|
<LangVersion>14</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<None Remove="Icon.ico"/>
|
<OutputPath>../bin/Client/</OutputPath>
|
||||||
<None Remove="Icon.bmp"/>
|
</PropertyGroup>
|
||||||
<None Remove="Input\**" />
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
</ItemGroup>
|
<OutputPath>../bin/Debug/Client/</OutputPath>
|
||||||
<ItemGroup>
|
</PropertyGroup>
|
||||||
<EmbeddedResource Include="Icon.ico">
|
<ItemGroup>
|
||||||
<LogicalName>Icon.ico</LogicalName>
|
<None Remove="Icon.ico"/>
|
||||||
</EmbeddedResource>
|
<None Remove="Icon.bmp"/>
|
||||||
<EmbeddedResource Include="Icon.bmp">
|
<None Remove="Input\**" />
|
||||||
<LogicalName>Icon.bmp</LogicalName>
|
</ItemGroup>
|
||||||
</EmbeddedResource>
|
<ItemGroup>
|
||||||
<EmbeddedResource Remove="Input\**" />
|
<EmbeddedResource Include="Icon.ico">
|
||||||
</ItemGroup>
|
<LogicalName>Icon.ico</LogicalName>
|
||||||
<ItemGroup>
|
</EmbeddedResource>
|
||||||
<PackageReference Include="LiteNetLib" Version="1.3.1" />
|
<EmbeddedResource Include="Icon.bmp">
|
||||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*"/>
|
<LogicalName>Icon.bmp</LogicalName>
|
||||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.*"/>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
<EmbeddedResource Remove="Input\**" />
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<Folder Include="lib\" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<PackageReference Include="LiteNetLib" Version="1.3.1" />
|
||||||
<ItemGroup>
|
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*"/>
|
||||||
<Reference Include="MonoGameLibrary">
|
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.*"/>
|
||||||
<HintPath>lib\MonoGameLibrary.dll</HintPath>
|
</ItemGroup>
|
||||||
</Reference>
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<Folder Include="link\" />
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<ProjectReference Include="..\GlobalClassLib\GlobalClassLib.csproj" />
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PacketLib\PacketLib.csproj" />
|
<Reference Include="MonoGameLibrary">
|
||||||
</ItemGroup>
|
<HintPath>link\MonoGameLibrary.dll</HintPath>
|
||||||
<ItemGroup>
|
</Reference>
|
||||||
<Compile Remove="Input\**" />
|
<!-- <Reference Include="FNAF_Server">-->
|
||||||
</ItemGroup>
|
<!-- <HintPath>link\FNAF_Server.dll</HintPath>-->
|
||||||
<Target Name="RestoreDotnetTools" BeforeTargets="CollectPackageReferences">
|
<!-- </Reference>-->
|
||||||
<Message Text="Restoring dotnet tools (this might take a while depending on your internet speed and should only happen upon building your project for the first time, or after upgrading MonoGame, or clearing your nuget cache)" Importance="High"/>
|
</ItemGroup>
|
||||||
<Exec Command="dotnet tool restore"/>
|
<ItemGroup>
|
||||||
</Target>
|
<ProjectReference Include="..\GlobalClassLib\GlobalClassLib.csproj" />
|
||||||
|
<ProjectReference Include="..\PacketLib\PacketLib.csproj" />
|
||||||
|
<!-- <ProjectReference Include="..\FNAF_Server\FNAF_Server.csproj" />-->
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Input\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Target Name="RestoreDotnetTools" BeforeTargets="CollectPackageReferences">
|
||||||
|
<Message Text="Restoring dotnet tools (this might take a while depending on your internet speed and should only happen upon building your project for the first time, or after upgrading MonoGame, or clearing your nuget cache)" Importance="High"/>
|
||||||
|
<Exec Command="dotnet tool restore"/>
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -73,6 +73,8 @@ public class Screen {
|
||||||
public bool Active { get; private set; } = false;
|
public bool Active { get; private set; } = false;
|
||||||
private InputListenerHook mouseInputHook = new(true);
|
private InputListenerHook mouseInputHook = new(true);
|
||||||
private bool temporary = false;
|
private bool temporary = false;
|
||||||
|
|
||||||
|
private List<string> temporaryElements = new();
|
||||||
|
|
||||||
public Screen(string label) {
|
public Screen(string label) {
|
||||||
Label = label;
|
Label = label;
|
||||||
|
|
@ -87,7 +89,7 @@ public class Screen {
|
||||||
public UIElement this[string id] => elements[id];
|
public UIElement this[string id] => elements[id];
|
||||||
public UIElement TryGetElement(string id) => elements.TryGetValue(id, out var val) ? val : null;
|
public UIElement TryGetElement(string id) => elements.TryGetValue(id, out var val) ? val : null;
|
||||||
|
|
||||||
public UIElement AddElement(string id, UIElement element) {
|
public UIElement AddElement(string id, UIElement element, bool temporary = false) {
|
||||||
elements.Add(id, element);
|
elements.Add(id, element);
|
||||||
|
|
||||||
int insertIndex = elementsInDrawOrder.FindLastIndex(e => e.DrawPriority == element.DrawPriority);
|
int insertIndex = elementsInDrawOrder.FindLastIndex(e => e.DrawPriority == element.DrawPriority);
|
||||||
|
|
@ -97,10 +99,25 @@ public class Screen {
|
||||||
else{
|
else{
|
||||||
elementsInDrawOrder.Insert(insertIndex + 1, element);
|
elementsInDrawOrder.Insert(insertIndex + 1, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (temporary){
|
||||||
|
temporaryElements.Add(id);
|
||||||
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemoveElement(string id) {
|
||||||
|
if (!elements.ContainsKey(id)) return;
|
||||||
|
elements.Remove(id, out var element);
|
||||||
|
elementsInDrawOrder.RemoveAll(e => e == element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveTemporary() {
|
||||||
|
temporaryElements.ForEach(RemoveElement);
|
||||||
|
temporaryElements.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetActive(bool active) {
|
public void SetActive(bool active) {
|
||||||
Active = active;
|
Active = active;
|
||||||
if (Active == active) return;
|
if (Active == active) return;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class TimerUIElement : TextUIElement{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start() {
|
public void Start() {
|
||||||
stopwatch.Start();
|
stopwatch.Restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop() {
|
public void Stop() {
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,14 @@ public class UIManager {
|
||||||
cameraView = new UIElement(rooms.ToArray(), new(64, 64));
|
cameraView = new UIElement(rooms.ToArray(), new(64, 64));
|
||||||
monitorScreen.AddElement("camera-view", cameraView);
|
monitorScreen.AddElement("camera-view", cameraView);
|
||||||
|
|
||||||
|
monitorScreen.AddElement("p1-office-door-left", new UIElement([MonitorAtlas["door-office-p1-left-open"], MonitorAtlas["door-office-p1-left-closed"]], new Point(400, 272)));
|
||||||
|
monitorScreen.AddElement("p1-office-door-centre", new UIElement([MonitorAtlas["door-office-p1-centre-open"], MonitorAtlas["door-office-p1-centre-closed"]], new Point(400, 272)));
|
||||||
|
monitorScreen.AddElement("p1-office-door-right", new UIElement([MonitorAtlas["door-office-p1-right-open"], MonitorAtlas["door-office-p1-right-closed"]], new Point(400, 272)));
|
||||||
|
monitorScreen.AddElement("p2-office-door-right", new UIElement([MonitorAtlas["door-office-p2-right-open"], MonitorAtlas["door-office-p2-right-closed"]], new Point(400, 144)));
|
||||||
|
monitorScreen.AddElement("p2-office-door-centre", new UIElement([MonitorAtlas["door-office-p2-centre-open"], MonitorAtlas["door-office-p2-centre-closed"]], new Point(400, 144)));
|
||||||
|
monitorScreen.AddElement("p2-office-door-left", new UIElement([MonitorAtlas["door-office-p2-left-open"], MonitorAtlas["door-office-p2-left-closed"]], new Point(400, 144)));
|
||||||
|
|
||||||
|
|
||||||
// main menu
|
// main menu
|
||||||
timerElement = new(new(0, 0), PixelMonoFont);
|
timerElement = new(new(0, 0), PixelMonoFont);
|
||||||
overlayScreen.AddElement("timer", timerElement);
|
overlayScreen.AddElement("timer", timerElement);
|
||||||
|
|
@ -119,20 +127,70 @@ public class UIManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuScreen.AddElement("host-button",
|
menuScreen.AddElement("host-button",
|
||||||
new TextUIElement(new(connectButton.Bounds.Item1.X, connectButton.Bounds.Item2.Y + 30), PixelMonoFont) {Text = "HOST"});
|
new TextUIElement(new(connectButton.Bounds.Item1.X, connectButton.Bounds.Item2.Y + 30), PixelMonoFont) {Text = "HOST", Pressable = true,
|
||||||
|
OnMousePress = () => {
|
||||||
|
Client.StartServer();
|
||||||
|
Client.Player.username = usernameField.Text;
|
||||||
|
Client.Connect("127.0.0.1", 9012);
|
||||||
|
Screen.SetScreen(ScreenTypes.LOADING);
|
||||||
|
|
||||||
|
}});
|
||||||
|
|
||||||
loadingScreen.AddElement("loading-text", new LoadingUIElement(new(320, 180), PixelMonoFont, field.Text));
|
loadingScreen.AddElement("loading-text", new LoadingUIElement(new(320, 180), PixelMonoFont, field.Text));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DisplayMainMenu() {
|
public static void DisplayMainMenu() {
|
||||||
|
ResetUI();
|
||||||
Screen.SetScreen(ScreenTypes.MENU);
|
Screen.SetScreen(ScreenTypes.MENU);
|
||||||
CommandManager.AllowGameControls(false);
|
CommandManager.AllowGameControls(false);
|
||||||
// if(Client.Player.username != null)
|
// if(Client.Player.username != null)
|
||||||
// ((MenuInputField)menuScreen["username-field"]).Text = Client.Player.username;
|
// ((MenuInputField)menuScreen["username-field"]).Text = Client.Player.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SpawnMapElements(TileConnectorProjection[] doors) {
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server
|
||||||
|
for (int j = 0; j < 5; j++){
|
||||||
|
int id = ClientMapManager.CoordsToId(i, 4 - j);
|
||||||
|
if (Client.Player.state.officeTileId == id || Client.Opponent.state.officeTileId == id) continue; // TODO: remove the other check for office
|
||||||
|
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
|
||||||
|
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
|
||||||
|
monitorScreen.AddElement(
|
||||||
|
$"room{id}", new UIElement(point1, point2)
|
||||||
|
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(id))},
|
||||||
|
true);
|
||||||
|
lightIndicators.Add(id,
|
||||||
|
monitorScreen.AddElement(
|
||||||
|
$"light{id}", new UIElement(MonitorAtlas["map-light-indicator"], point1)
|
||||||
|
{Visible = false},
|
||||||
|
true));
|
||||||
|
|
||||||
|
//
|
||||||
|
// if (doorPositions.ContainsKey((i, j))){
|
||||||
|
// monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
monitorScreen.AddElement("eye-player", new UIElement(MonitorAtlas["eye-small-player"], monitorScreen["room"+Client.Player.state.camera].Bounds.Item1), true);
|
||||||
|
monitorScreen.AddElement("eye-opponent", new UIElement([MonitorAtlas["eye-small-opponent-closed"], MonitorAtlas["eye-small-opponent-open"]], monitorScreen["room"+Client.Opponent.state.camera].Bounds.Item1), true);
|
||||||
|
|
||||||
|
foreach (var door in doors){
|
||||||
|
if(door.Type != ConnectorType.DOOR_REMOTE) continue;
|
||||||
|
|
||||||
|
(int x, int y) dpos = (Math.Abs(door.Tiles.tile1.GridPosition.x - door.Tiles.tile2.GridPosition.x), Math.Abs(door.Tiles.tile1.GridPosition.y - door.Tiles.tile2.GridPosition.y));
|
||||||
|
|
||||||
|
if (dpos.y == 1){
|
||||||
|
int targetId = door.Tiles.tile1.GridPosition.y > door.Tiles.tile2.GridPosition.y ? door.Tiles.tile1.Id : door.Tiles.tile2.Id;
|
||||||
|
UIElement tile = monitorScreen["room"+targetId];
|
||||||
|
|
||||||
|
monitorScreen.AddElement("door"+Math.Max(door.Tiles.tile1.Id, door.Tiles.tile2.Id)+"-"+Math.Min(door.Tiles.tile1.Id, door.Tiles.tile2.Id), new UIElement([MonitorAtlas["door-remote-open"], MonitorAtlas["door-remote-closed"]], tile.Bounds.Item1), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void DisplayGameUI() {
|
public static void DisplayGameUI() {
|
||||||
Screen.SetScreen(ScreenTypes.OFFICE);
|
Screen.SetScreen(ScreenTypes.OFFICE);
|
||||||
Screen.SetOverlayScreen(ScreenTypes.OVERLAY);
|
Screen.SetOverlayScreen(ScreenTypes.OVERLAY);
|
||||||
|
|
@ -145,53 +203,10 @@ public class UIManager {
|
||||||
timerElement.Start();
|
timerElement.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SpawnMapElements(TileConnectorProjection[] doors) {
|
|
||||||
for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server
|
|
||||||
for (int j = 0; j < 5; j++){
|
|
||||||
int id = ClientMapManager.CoordsToId(i, 4 - j);
|
|
||||||
if (Client.Player.state.officeTileId == id || Client.Opponent.state.officeTileId == id) continue; // TODO: remove the other check for office
|
|
||||||
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
|
|
||||||
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
|
|
||||||
monitorScreen.AddElement($"room{id}", new UIElement(point1, point2)
|
|
||||||
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(id))});
|
|
||||||
lightIndicators.Add(id, monitorScreen.AddElement($"light{id}", new UIElement(MonitorAtlas["map-light-indicator"], point1){Visible = false}));
|
|
||||||
|
|
||||||
//
|
|
||||||
// if (doorPositions.ContainsKey((i, j))){
|
|
||||||
// monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
monitorScreen.AddElement("eye-player", new UIElement(MonitorAtlas["eye-small-player"], monitorScreen["room"+Client.Player.state.camera].Bounds.Item1));
|
|
||||||
monitorScreen.AddElement("eye-opponent", new UIElement([MonitorAtlas["eye-small-opponent-closed"], MonitorAtlas["eye-small-opponent-open"]], monitorScreen["room"+Client.Opponent.state.camera].Bounds.Item1));
|
|
||||||
|
|
||||||
foreach (var door in doors){
|
|
||||||
if(door.Type != ConnectorType.DOOR_REMOTE) continue;
|
|
||||||
|
|
||||||
(int x, int y) dpos = (Math.Abs(door.Tiles.tile1.GridPosition.x - door.Tiles.tile2.GridPosition.x), Math.Abs(door.Tiles.tile1.GridPosition.y - door.Tiles.tile2.GridPosition.y));
|
|
||||||
|
|
||||||
if (dpos.y == 1){
|
|
||||||
int targetId = door.Tiles.tile1.GridPosition.y > door.Tiles.tile2.GridPosition.y ? door.Tiles.tile1.Id : door.Tiles.tile2.Id;
|
|
||||||
UIElement tile = monitorScreen["room"+targetId];
|
|
||||||
|
|
||||||
monitorScreen.AddElement("door"+Math.Max(door.Tiles.tile1.Id, door.Tiles.tile2.Id)+"-"+Math.Min(door.Tiles.tile1.Id, door.Tiles.tile2.Id), new UIElement([MonitorAtlas["door-remote-open"], MonitorAtlas["door-remote-closed"]], tile.Bounds.Item1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
monitorScreen.AddElement("p1-office-door-left", new UIElement([MonitorAtlas["door-office-p1-left-open"], MonitorAtlas["door-office-p1-left-closed"]], new Point(400, 272)));
|
|
||||||
monitorScreen.AddElement("p1-office-door-centre", new UIElement([MonitorAtlas["door-office-p1-centre-open"], MonitorAtlas["door-office-p1-centre-closed"]], new Point(400, 272)));
|
|
||||||
monitorScreen.AddElement("p1-office-door-right", new UIElement([MonitorAtlas["door-office-p1-right-open"], MonitorAtlas["door-office-p1-right-closed"]], new Point(400, 272)));
|
|
||||||
monitorScreen.AddElement("p2-office-door-right", new UIElement([MonitorAtlas["door-office-p2-right-open"], MonitorAtlas["door-office-p2-right-closed"]], new Point(400, 144)));
|
|
||||||
monitorScreen.AddElement("p2-office-door-centre", new UIElement([MonitorAtlas["door-office-p2-centre-open"], MonitorAtlas["door-office-p2-centre-closed"]], new Point(400, 144)));
|
|
||||||
monitorScreen.AddElement("p2-office-door-left", new UIElement([MonitorAtlas["door-office-p2-left-open"], MonitorAtlas["door-office-p2-left-closed"]], new Point(400, 144)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddEnemySprite(int id, UIElement sprite, UIElement jumpscareSprite = null) {
|
public static void AddEnemySprite(int id, UIElement sprite, UIElement jumpscareSprite = null) {
|
||||||
monitorScreen.AddElement($"enemy{id}", sprite);
|
monitorScreen.AddElement($"enemy{id}", sprite, true);
|
||||||
if (jumpscareSprite != null){
|
if (jumpscareSprite != null){
|
||||||
officeScreen.AddElement($"enemy{id}-jumpscare", jumpscareSprite);
|
officeScreen.AddElement($"enemy{id}-jumpscare", jumpscareSprite, true);
|
||||||
jumpscareSprite.Active = false;
|
jumpscareSprite.Active = false;
|
||||||
jumpscareSprite.Visible = false;
|
jumpscareSprite.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
@ -314,6 +329,16 @@ public class UIManager {
|
||||||
SoundManager.StopAmbience();
|
SoundManager.StopAmbience();
|
||||||
InputManager.AddListener(Keys.Space, DisplayMainMenu, InputTiming.PRESS, new InputListenerHook(true, true));
|
InputManager.AddListener(Keys.Space, DisplayMainMenu, InputTiming.PRESS, new InputListenerHook(true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ResetUI() {
|
||||||
|
foreach (Screen screen in Screen.Screens.Values){
|
||||||
|
screen.RemoveTemporary();
|
||||||
|
}
|
||||||
|
lightIndicators.Clear();
|
||||||
|
enemyElements.Clear();
|
||||||
|
|
||||||
|
timerElement.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
// private static Point GetRoomUIPos((int x, int y) pos) {
|
// private static Point GetRoomUIPos((int x, int y) pos) {
|
||||||
// return new Point(336 + (32 * pos.x), 144 + (32 * pos.y));
|
// return new Point(336 + (32 * pos.x), 144 + (32 * pos.y));
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ public class GameMain() : Core("fnafkooo", 1280, 720, false) {
|
||||||
|
|
||||||
|
|
||||||
protected override void Initialize() {
|
protected override void Initialize() {
|
||||||
|
Exiting += (_, _) => {
|
||||||
|
Client.Disconnect();
|
||||||
|
};
|
||||||
|
|
||||||
// Client.Connect("127.0.0.1", 9012);
|
// Client.Connect("127.0.0.1", 9012);
|
||||||
CommandManager.InitInputListeners();
|
CommandManager.InitInputListeners();
|
||||||
|
|
||||||
|
|
@ -23,6 +27,7 @@ public class GameMain() : Core("fnafkooo", 1280, 720, false) {
|
||||||
|
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
Client.Init();
|
||||||
UIManager.InitUI();
|
UIManager.InitUI();
|
||||||
UIManager.DisplayMainMenu();
|
UIManager.DisplayMainMenu();
|
||||||
}
|
}
|
||||||
|
|
@ -35,9 +40,9 @@ public class GameMain() : Core("fnafkooo", 1280, 720, false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(GameTime gameTime) {
|
protected override void Update(GameTime gameTime) {
|
||||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
if (Keyboard.GetState().IsKeyDown(Keys.Escape)){
|
||||||
Keyboard.GetState().IsKeyDown(Keys.Escape))
|
|
||||||
Exit();
|
Exit();
|
||||||
|
}
|
||||||
|
|
||||||
InputManager.NextInputCycle();
|
InputManager.NextInputCycle();
|
||||||
Screen.UpdateAll();
|
Screen.UpdateAll();
|
||||||
|
|
@ -59,4 +64,6 @@ public class GameMain() : Core("fnafkooo", 1280, 720, false) {
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,2 +1,5 @@
|
||||||
using var game = new FNAF_Clone.GameMain();
|
using System;
|
||||||
|
|
||||||
|
using var game = new FNAF_Clone.GameMain();
|
||||||
|
Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
game.Run();
|
game.Run();
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../../MonoGameLibrary/MonoGameLibrary/bin/Debug/net8.0/MonoGameLibrary.dll
|
|
||||||
1
FNAF_Clone/link/MonoGameLibrary.dll
Symbolic link
1
FNAF_Clone/link/MonoGameLibrary.dll
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../MonoGameLibrary/MonoGameLibrary/bin/Release/net9.0/publish/MonoGameLibrary.dll
|
||||||
|
|
@ -55,25 +55,22 @@ public class NekoEnemy : Enemy {
|
||||||
Server.SendUpdateToAll([GameEvent.NEKO_ANGERED(Location.Owner.state.pid, Id)]);
|
Server.SendUpdateToAll([GameEvent.NEKO_ANGERED(Location.Owner.state.pid, Id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movementOpportunity.CheckAndRoll() || (Aggressive && GameLogic.NSecondUpdate)){
|
if (Target == null){
|
||||||
if (Target == null){
|
if (Server.P1.state.power > Server.P2.state.power){
|
||||||
if (Server.P1.state.power > Server.P2.state.power){
|
Target = Server.P2;
|
||||||
Target = Server.P2;
|
}
|
||||||
}
|
else if (Server.P1.state.power < Server.P2.state.power){
|
||||||
else if (Server.P1.state.power < Server.P2.state.power){
|
Target = Server.P1;
|
||||||
Target = Server.P1;
|
}
|
||||||
}
|
else{
|
||||||
else{
|
if (GameLogic.PhaseCounter > 1){
|
||||||
if (GameLogic.PhaseCounter > 1){
|
Target = Server.Players[new Random().Next(2)];
|
||||||
Target = Server.Players[new Random().Next(2)];
|
SetDifficulty(8);
|
||||||
SetDifficulty(8);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Target != null && (movementOpportunity.CheckAndRoll() || (Aggressive && GameLogic.NSecondUpdate))){
|
||||||
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(Target.state.officeTileId));
|
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(Target.state.officeTileId));
|
||||||
switch (decision.type){
|
switch (decision.type){
|
||||||
case Pathfinder.Decision.MoveType:
|
case Pathfinder.Decision.MoveType:
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,14 @@
|
||||||
<LangVersion>14</LangVersion>
|
<LangVersion>14</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<OutputPath>../bin/Debug/Server</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<OutputPath>../bin/Server</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteNetLib" Version="1.3.1" />
|
<PackageReference Include="LiteNetLib" Version="1.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ public class GameLogic {
|
||||||
public const int START_CAMERA = 12;
|
public const int START_CAMERA = 12;
|
||||||
|
|
||||||
private static MovementOpportunity secondCycleTimer = new(1000);
|
private static MovementOpportunity secondCycleTimer = new(1000);
|
||||||
private static MovementOpportunity gamePhaseTimer = new(30_000);
|
private static MovementOpportunity gamePhaseTimer = new(60_000);
|
||||||
public static bool NSecondUpdate{ get; private set; } = false;
|
public static bool NSecondUpdate{ get; private set; } = false;
|
||||||
|
|
||||||
public static MapTile P1Office;
|
public static MapTile P1Office;
|
||||||
|
|
@ -84,7 +84,7 @@ public class GameLogic {
|
||||||
// EnemyManager.AddEnemy(new MareEnemy(10)).Spawn(MapManager.Get(22));
|
// EnemyManager.AddEnemy(new MareEnemy(10)).Spawn(MapManager.Get(22));
|
||||||
|
|
||||||
EnemyManager.AddEnemy(new LurkEnemy(4)).Spawn(MapManager.Get(2));
|
EnemyManager.AddEnemy(new LurkEnemy(4)).Spawn(MapManager.Get(2));
|
||||||
EnemyManager.AddEnemy(new NekoEnemy(4)).Spawn(MapManager.Get(22));
|
EnemyManager.AddEnemy(new NekoEnemy(4)).Spawn(MapManager.Get(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void Update() {
|
public static void Update() {
|
||||||
|
|
@ -122,9 +122,16 @@ public class GameLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeclareWinner(ServerPlayer player) {
|
public static void DeclareWinner(ServerPlayer player) {
|
||||||
Server.SendUpdateToAll([GameEvent.PLAYER_WIN(player.state.pid)]);
|
if (Server.Players.Count == 2){
|
||||||
|
Server.SendUpdateToAll([GameEvent.PLAYER_WIN(player.state.pid)]);
|
||||||
|
Console.WriteLine("Player " + player.state.pid + " won!");
|
||||||
|
}
|
||||||
|
Thread.Sleep(1000);
|
||||||
Server.Stop();
|
Server.Stop();
|
||||||
Console.WriteLine("Player " + player.state.pid + " won!");
|
|
||||||
|
if (!Server.AutoStop){
|
||||||
|
Program.Restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (int p1Usage, int p2Usage) CalculatePowerUsage() {
|
private static (int p1Usage, int p2Usage) CalculatePowerUsage() {
|
||||||
|
|
@ -158,7 +165,7 @@ public class GameLogic {
|
||||||
PhaseCounter++;
|
PhaseCounter++;
|
||||||
Server.SendUpdateToAll([GameEvent.NEXT_PHASE()]);
|
Server.SendUpdateToAll([GameEvent.NEXT_PHASE()]);
|
||||||
|
|
||||||
int roll = random.Next(3);
|
int roll = spawnOrder.Count > 0 ? random.Next(3) : random.Next(1,3);
|
||||||
switch (roll){
|
switch (roll){
|
||||||
case 0:
|
case 0:
|
||||||
int spawnRoll = random.Next(spawnOrder[0].Count);
|
int spawnRoll = random.Next(spawnOrder[0].Count);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace FNAF_Server;
|
namespace FNAF_Server;
|
||||||
|
|
||||||
public class Program {
|
public class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
|
if (args.Contains("--persistent")){
|
||||||
|
Server.AutoStop = false;
|
||||||
|
}
|
||||||
Server.Start(9012);
|
Server.Start(9012);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Restart() {
|
||||||
|
Console.WriteLine("Game concluded -> restarting server");
|
||||||
|
Process.Start(new ProcessStartInfo{ FileName = Environment.ProcessPath, UseShellExecute = false });
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,8 @@ public class Server {
|
||||||
public static ServerPlayer P2;
|
public static ServerPlayer P2;
|
||||||
public static readonly Dictionary<int, ServerPlayer> Players = new();
|
public static readonly Dictionary<int, ServerPlayer> Players = new();
|
||||||
public static ServerPlayer OtherPlayer(ServerPlayer player) => player.state.pid == P1.state.pid ? P2 : P1;
|
public static ServerPlayer OtherPlayer(ServerPlayer player) => player.state.pid == P1.state.pid ? P2 : P1;
|
||||||
|
|
||||||
|
public static bool AutoStop{ get; set; } = true;
|
||||||
|
|
||||||
private static EventBasedNetListener listener;
|
private static EventBasedNetListener listener;
|
||||||
private static NetManager server;
|
private static NetManager server;
|
||||||
|
|
@ -138,6 +140,8 @@ public class Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) {
|
public static void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) {
|
||||||
|
GameLogic.DeclareWinner(OtherPlayer(Players.Values.First(p => Equals(p.peer, peer))));
|
||||||
|
|
||||||
if (peer.Tag != null) {
|
if (peer.Tag != null) {
|
||||||
Players.Remove(peer.Id);
|
Players.Remove(peer.Id);
|
||||||
}
|
}
|
||||||
|
|
@ -193,6 +197,7 @@ public class Server {
|
||||||
public static void Stop()
|
public static void Stop()
|
||||||
{
|
{
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
|
server.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
namespace GlobalClassLib;
|
namespace GlobalClassLib;
|
||||||
|
|
||||||
public static class Power {
|
public static class Power {
|
||||||
public const int MAX_POWER_VALUE = 1000;
|
public const int MAX_POWER_VALUE = 4000;
|
||||||
}
|
}
|
||||||
7
build-linux.sh
Executable file
7
build-linux.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
dotnet publish MonoGameLibrary
|
||||||
|
ln -sfrv MonoGameLibrary/MonoGameLibrary/bin/Release/net9.0/publish/MonoGameLibrary.dll FNAF_Clone/link/MonoGameLibrary.dll
|
||||||
|
|
||||||
|
dotnet publish
|
||||||
|
|
||||||
|
ln -sfrv bin/Server/net9.0/publish/FNAF_Server bin/Client/net9.0/publish/FNAF_Server
|
||||||
|
ln -sfrv bin/Client/net9.0/publish/FNAF_Clone outexe
|
||||||
5
launch-server.sh
Executable file
5
launch-server.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
bin/Server/net9.0/publish/FNAF_Server
|
||||||
|
echo "Restarting server..."
|
||||||
|
done
|
||||||
1
outexe
Symbolic link
1
outexe
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
bin/Client/net9.0/publish/FNAF_Clone
|
||||||
Loading…
Add table
Add a link
Reference in a new issue