From 7a1883c6d003fe8b78f895c2b06c6eface1596d7 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Sun, 18 Aug 2024 14:24:04 +0300 Subject: [PATCH 1/2] Fix soundManager --- ZoFo/GameCore/GameManagers/SoundManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZoFo/GameCore/GameManagers/SoundManager.cs b/ZoFo/GameCore/GameManagers/SoundManager.cs index 7e8d408..da8880b 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 ZoFo.GameCore.GUI; namespace ZoFo.GameCore.GameManagers { @@ -21,15 +22,14 @@ namespace ZoFo.GameCore.GameManagers public void LoadSounds() // метод для загрузки звуков из папки { //List sounds = AppManager.Instance.Content.Load>("sounds/"); - - var k = Directory.GetFiles(Directory.GetCurrentDirectory() + "//Content//sounds").Where(x => x.EndsWith("xnb")); + var k = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "sounds")).Where(x => x.EndsWith("xnb")); if (k.Count() > 0) { string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".xnb", "")).ToArray();// папка со звуками там где exe foreach (var soundFile in soundFiles) { - Sounds.Add(soundFile, AppManager.Instance.Content.Load("sounds//" + soundFile)); + Sounds.Add(soundFile, AppManager.Instance.Content.Load(Path.Combine("sounds", soundFile))); } } From 18b507047a7b778e1f8f94b6f96f6561a81d18f0 Mon Sep 17 00:00:00 2001 From: SergoDobro Date: Sun, 18 Aug 2024 14:24:30 +0300 Subject: [PATCH 2/2] fixing Content! --- ZoFo/Content/Content.mgcb | 191 +++++++++++++++++- .../{TileSetImages => TileSets}/Tilelist1.png | Bin .../{TileSetImages => TileSets}/Tilelist2.png | Bin .../{TileSetImages => TileSets}/Tilelist3.png | Bin .../{TileSetImages => TileSets}/Tilelist4.png | Bin .../TilesetFloor.png | Bin .../GameManagers/MapManager/MapManager.cs | 4 +- .../NetworkManager/ClientNetworkManager.cs | 11 +- .../NetworkManager/ServerNetworkManager.cs | 11 +- 9 files changed, 201 insertions(+), 16 deletions(-) rename ZoFo/Content/Textures/{TileSetImages => TileSets}/Tilelist1.png (100%) rename ZoFo/Content/Textures/{TileSetImages => TileSets}/Tilelist2.png (100%) rename ZoFo/Content/Textures/{TileSetImages => TileSets}/Tilelist3.png (100%) rename ZoFo/Content/Textures/{TileSetImages => TileSets}/Tilelist4.png (100%) rename ZoFo/Content/Textures/{TileSetImages => TileSets}/TilesetFloor.png (100%) diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index 3df811a..d8fde75 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -351,8 +351,8 @@ /processorParam:MakeSquare=False /processorParam:TextureFormat=Color /build:Textures/GUI/switch.png - -#begin Textures/Test/pickaxe.webp + +#begin Textures/icons/12.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -362,10 +362,129 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color +/build:Textures/icons/12.png +#begin Textures/icons/13.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/13.png + +#begin Textures/icons/14.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/14.png + +#begin Textures/icons/21.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/21.png + +#begin Textures/icons/22.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/22.png + +#begin Textures/icons/5.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/5.png + +#begin Textures/icons/6.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/6.png + +#begin Textures/icons/7.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/7.png + +#begin Textures/icons/8.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/8.png + +#begin Textures/icons/9.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/icons/9.png + +#begin Textures/Test/pickaxe.webp +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color /build:Textures/Test/pickaxe.webp -#begin Textures/Test/rock.jpg +#begin Textures/Test/rock.jpg /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -375,11 +494,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color - /build:Textures/Test/rock.jpg #begin Textures/Test/steel.png - /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -389,11 +506,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color - /build:Textures/Test/steel.png #begin Textures/Test/wood.jpg - /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -403,11 +518,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color - /build:Textures/Test/wood.jpg -#begin Textures/TileSets/TilesetFloor.png - +#begin Textures/TileSets/Tilelist1.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -417,7 +530,65 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color +/build:Textures/TileSets/Tilelist1.png +#begin Textures/TileSets/Tilelist2.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/TileSets/Tilelist2.png + +#begin Textures/TileSets/Tilelist3.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/TileSets/Tilelist3.png + +#begin Textures/TileSets/Tilelist4.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/TileSets/Tilelist4.png + +#begin Textures/TileSets/TilesetFloor.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color /build:Textures/TileSets/TilesetFloor.png +#begin Textures/TileSets/TilesetFloor.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/TileSets/TilesetFloor.png diff --git a/ZoFo/Content/Textures/TileSetImages/Tilelist1.png b/ZoFo/Content/Textures/TileSets/Tilelist1.png similarity index 100% rename from ZoFo/Content/Textures/TileSetImages/Tilelist1.png rename to ZoFo/Content/Textures/TileSets/Tilelist1.png diff --git a/ZoFo/Content/Textures/TileSetImages/Tilelist2.png b/ZoFo/Content/Textures/TileSets/Tilelist2.png similarity index 100% rename from ZoFo/Content/Textures/TileSetImages/Tilelist2.png rename to ZoFo/Content/Textures/TileSets/Tilelist2.png diff --git a/ZoFo/Content/Textures/TileSetImages/Tilelist3.png b/ZoFo/Content/Textures/TileSets/Tilelist3.png similarity index 100% rename from ZoFo/Content/Textures/TileSetImages/Tilelist3.png rename to ZoFo/Content/Textures/TileSets/Tilelist3.png diff --git a/ZoFo/Content/Textures/TileSetImages/Tilelist4.png b/ZoFo/Content/Textures/TileSets/Tilelist4.png similarity index 100% rename from ZoFo/Content/Textures/TileSetImages/Tilelist4.png rename to ZoFo/Content/Textures/TileSets/Tilelist4.png diff --git a/ZoFo/Content/Textures/TileSetImages/TilesetFloor.png b/ZoFo/Content/Textures/TileSets/TilesetFloor.png similarity index 100% rename from ZoFo/Content/Textures/TileSetImages/TilesetFloor.png rename to ZoFo/Content/Textures/TileSets/TilesetFloor.png diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs index 07b0e86..0d6a569 100644 --- a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs +++ b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs @@ -76,7 +76,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager AppManager.Instance.server.RegisterGameObject(new MapObject(position, new Vector2(tileSet.TileWidth, tileSet.TileHeight), sourceRectangle, - "Textures/TileSetImages/" + + "Textures/TileSets/" + Path.GetFileName(tileSet.Image).Replace(".png", ""))); break; case "StopObject": @@ -84,7 +84,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager AppManager.Instance.server.RegisterGameObject(new StopObject(position/4,//TODO new Vector2(tileSet.TileWidth, tileSet.TileHeight), sourceRectangle, - "Textures/TileSetImages/" + + "Textures/TileSets/" + Path.GetFileName(tileSet.Image).Replace(".png", ""), collisionRectangles.ToArray())); break; diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs index 79ab597..465eabf 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs @@ -100,8 +100,15 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager { 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); + foreach (var ip in ipList) + { + if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { + return ip; + } + } + return IPAddress.Loopback; + } //поток 2 diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index be2e989..fa4a718 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -54,8 +54,15 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager { 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); + foreach (var ip in ipList) + { + if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { + return ip; + } + } + return IPAddress.Loopback; + } ///