From a69f133d0a2dd529ce862e07d6e703ed12bbd22e Mon Sep 17 00:00:00 2001 From: Lev Date: Sun, 18 Aug 2024 12:47:13 +0300 Subject: [PATCH 1/2] fix SounManager --- .../NetworkManager/ServerNetworkManager.cs | 5 +++-- ZoFo/GameCore/GameManagers/SoundManager.cs | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index 76e72c2..7b9501d 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -53,8 +53,9 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager /// public static IPAddress GetIp() { - string hostName = Dns.GetHostName(); // Retrive the Name of HOST - string myIP = Dns.GetHostByName(hostName).AddressList[1].ToString();// Get the IP + string hostName = Dns.GetHostName(); // Retrive the Name of HOST + var ipList =Dns.GetHostByName(hostName).AddressList; + string myIP = ipList[ipList.Count()-1].ToString();// Get the IP return IPAddress.Parse(myIP); } diff --git a/ZoFo/GameCore/GameManagers/SoundManager.cs b/ZoFo/GameCore/GameManagers/SoundManager.cs index 7e8d408..e5c5699 100644 --- a/ZoFo/GameCore/GameManagers/SoundManager.cs +++ b/ZoFo/GameCore/GameManagers/SoundManager.cs @@ -9,6 +9,7 @@ using System.Linq; using Newtonsoft.Json; using Microsoft.Xna.Framework.Media; +using System.Runtime.InteropServices; namespace ZoFo.GameCore.GameManagers { @@ -22,8 +23,16 @@ namespace ZoFo.GameCore.GameManagers { //List sounds = AppManager.Instance.Content.Load>("sounds/"); - var k = Directory.GetFiles(Directory.GetCurrentDirectory() + "//Content//sounds").Where(x => x.EndsWith("xnb")); - if (k.Count() > 0) + string a = Path.Combine("Content", "sounds"); + string[] k; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + k = Directory.GetFiles(Path.Combine("bin", "Debug", "net8.0", "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray(); + } + else{ + k = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray(); + } + if (k.Length > 0) { string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".xnb", "")).ToArray();// папка со звуками там где exe From 593f53fc4745fcd2d763edeb61b184482f3f3222 Mon Sep 17 00:00:00 2001 From: Lev Date: Sun, 18 Aug 2024 13:23:31 +0300 Subject: [PATCH 2/2] fix minor ClientNetworkManager and ServerNetworkManager --- .../GameManagers/NetworkManager/ClientNetworkManager.cs | 4 ++-- .../GameManagers/NetworkManager/ServerNetworkManager.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs index 2a93f71..70cfe76 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs @@ -98,8 +98,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager public static IPAddress GetIp() { string hostName = Dns.GetHostName(); // Retrive the Name of HOST - string myIP = Dns.GetHostByName(hostName).AddressList[1].ToString();// Get the IP - return IPAddress.Parse(myIP); + //string myIP = Dns.GetHostByName(hostName).AddressList[1].ToString();// Get the IP + return IPAddress.Parse("127.0.0.1"); } //поток 2 diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index 7b9501d..fedcac4 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -54,9 +54,9 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager public static IPAddress GetIp() { string hostName = Dns.GetHostName(); // Retrive the Name of HOST - var ipList =Dns.GetHostByName(hostName).AddressList; - string myIP = ipList[ipList.Count()-1].ToString();// Get the IP - return IPAddress.Parse(myIP); + //var ipList =Dns.GetHostByName(hostName).AddressList; + //string myIP = ipList[ipList.Count()-1].ToString();// Get the IP + return IPAddress.Parse("127.0.0.1"); } ///