Správné vypnutí serveru v případě crashe z důvodu obsazeného portu, soubor na nastavení rozlišení, odstranění nepoužívané metody Enemy.SilentSpawn a implementace metody SoundManager.GetRandomisedPitchInstance
This commit is contained in:
parent
243f071a43
commit
8742f9eb55
10 changed files with 46 additions and 56 deletions
|
|
@ -9,7 +9,7 @@ using ONDClient.Sound;
|
|||
|
||||
namespace ONDClient;
|
||||
|
||||
public class GameMain() : Core("OND", 1280, 720, false) {
|
||||
public class GameMain(int width, int height) : Core("OND", width, height, false) {
|
||||
protected override void Initialize() {
|
||||
Exiting += (_, _) => {
|
||||
Client.Disconnect();
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public static class EventProcessor {
|
|||
private static void EnemyAttack(int enemyId, int pid) {
|
||||
Console.WriteLine($"E: Enemy {enemyId} attacked player {pid}");
|
||||
if (pid == Client.Player.State.Pid) {
|
||||
UIManager.Jumpscare(ClientEnemyManager.Get(pid));
|
||||
UIManager.Jumpscare(ClientEnemyManager.Get(enemyId));
|
||||
SoundManager.PlayJumpscare();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,21 +43,20 @@
|
|||
<Reference Include="MonoGameLibrary">
|
||||
<HintPath>link\MonoGameLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<!-- <Reference Include="FNAF_Server">-->
|
||||
<!-- <HintPath>link\FNAF_Server.dll</HintPath>-->
|
||||
<!-- </Reference>-->
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<Content Include="settings\*">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using var game = new ONDClient.GameMain();
|
||||
Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
int resMult = int.Parse(File.ReadLines("settings/resolution.txt").First());
|
||||
using var game = new ONDClient.GameMain(640 * resMult, 360 * resMult);
|
||||
game.Run();
|
||||
|
|
@ -71,27 +71,27 @@ public static class SoundManager {
|
|||
|
||||
public static void PlayDoor(bool doorState) {
|
||||
if (doorState){
|
||||
doorClose.Play();
|
||||
GetRandomisedPitchInstance(doorClose).Play();
|
||||
}
|
||||
else{
|
||||
doorOpen.Play();
|
||||
GetRandomisedPitchInstance(doorOpen).Play();
|
||||
}
|
||||
}
|
||||
public static void PlayDoorRemote(bool doorState) {
|
||||
if (doorState){
|
||||
doorCloseRemote.Play();
|
||||
GetRandomisedPitchInstance(doorCloseRemote).Play();
|
||||
}
|
||||
else{
|
||||
doorOpenRemote.Play();
|
||||
GetRandomisedPitchInstance(doorOpenRemote).Play();
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayLight(bool lightState) {
|
||||
if (lightState){
|
||||
lightOn.Play();
|
||||
GetRandomisedPitchInstance(lightOn).Play();
|
||||
}
|
||||
else{
|
||||
lightOff.Play();
|
||||
GetRandomisedPitchInstance(lightOff).Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,23 +99,23 @@ public static class SoundManager {
|
|||
|
||||
public static void PlayPowerOut() => powerOut.Play();
|
||||
|
||||
public static void PlayNekoMove() => nekoMove.Play();
|
||||
public static void PlayNekoMove() => GetRandomisedPitchInstance(nekoMove).Play();
|
||||
|
||||
public static void PlayNekoAnger() => nekoAnger.Play();
|
||||
|
||||
public static void PlaySpotActivate() => spotActivate.Play();
|
||||
public static void PlaySpotActivate() => GetRandomisedPitchInstance(spotActivate).Play();
|
||||
|
||||
public static void PlaySpotMove() => spotMove.Play();
|
||||
public static void PlaySpotMove() => GetRandomisedPitchInstance(spotMove).Play();
|
||||
|
||||
public static void PlayDashMove() => dashMove.Play();
|
||||
public static void PlayDashMove() => GetRandomisedPitchInstance(dashMove).Play();
|
||||
|
||||
public static void PlayMareMove() => mareMove.Play();
|
||||
public static void PlayMareMove() => GetRandomisedPitchInstance(mareMove).Play();
|
||||
|
||||
public static void PlayMonitorFlip() => monitorFlip.Play();
|
||||
public static void PlayMonitorFlip() => GetRandomisedPitchInstance(monitorFlip).Play();
|
||||
|
||||
public static void PlayCameraSwitch() => camSwitch.Play();
|
||||
public static void PlayCameraSwitch() => GetRandomisedPitchInstance(camSwitch).Play();
|
||||
|
||||
public static void PlayVentWalk() => ventWalk.Play();
|
||||
public static void PlayVentWalk() => GetRandomisedPitchInstance(ventWalk).Play();
|
||||
|
||||
public static void PlayBell() => bell.Play();
|
||||
|
||||
|
|
@ -126,10 +126,9 @@ public static class SoundManager {
|
|||
}
|
||||
|
||||
public static void StopNekoPurr() {
|
||||
nekoPurrInstance.Stop();
|
||||
nekoPurrInstance?.Stop();
|
||||
}
|
||||
|
||||
// unused
|
||||
private static SoundEffectInstance GetRandomisedPitchInstance(SoundEffect effect) {
|
||||
SoundEffectInstance instance = effect.CreateInstance();
|
||||
instance.Pitch = (float)(random.NextDouble() - 0.5) / 5;
|
||||
|
|
|
|||
8
ONDClient/settings/resolution.txt
Normal file
8
ONDClient/settings/resolution.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
2
|
||||
|
||||
# 1 - 640x360
|
||||
# 2 (default) - 1280x720
|
||||
# 3 - 1920x1080 (Full HD)
|
||||
# 4 - 2560x1440 (QHD)
|
||||
# 5 - 3200x1800
|
||||
# 6 - 3840x2160 (4K)
|
||||
|
|
@ -17,12 +17,6 @@ public abstract class Enemy : GlobalEnemy<MapTile, TileConnector> {
|
|||
SetDifficulty(difficulty);
|
||||
}
|
||||
|
||||
// unused
|
||||
public virtual void SpawnSilent(MapTile location) {
|
||||
Console.WriteLine($"!!! Silent spawn not implemented for enemy {Type} ({Name}), reverting to regular spawn");
|
||||
Spawn(location);
|
||||
}
|
||||
|
||||
public override void Spawn(MapTile location) {
|
||||
base.Spawn(location);
|
||||
Spawned = true;
|
||||
|
|
|
|||
|
|
@ -122,10 +122,6 @@ public static class GameLogic {
|
|||
}
|
||||
Thread.Sleep(1000);
|
||||
Server.Stop();
|
||||
|
||||
if (!Server.AutoStop){
|
||||
Program.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
private static (int p1Usage, int p2Usage) CalculatePowerUsage() {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ public static class Server {
|
|||
public static readonly Dictionary<int, ServerPlayer> Players = new();
|
||||
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 NetManager server;
|
||||
|
||||
|
|
@ -61,6 +59,10 @@ public static class Server {
|
|||
listener.PeerDisconnectedEvent += OnPeerDisconnected;
|
||||
|
||||
server.Start(port);
|
||||
if (!server.IsRunning){
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
Run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,8 @@
|
|||
using System.Diagnostics;
|
||||
using ONDServer.Net;
|
||||
using ONDServer.Net;
|
||||
|
||||
namespace ONDServer;
|
||||
|
||||
public static class Program {
|
||||
public static void Main(string[] args) {
|
||||
if (args.Contains("--persistent")){
|
||||
Server.AutoStop = false;
|
||||
}
|
||||
try{
|
||||
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);
|
||||
}
|
||||
finally{
|
||||
Server.Stop();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue