diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index fccc811..cc90965 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -508,6 +508,18 @@ /processorParam:MakeSquare=False /processorParam:TextureFormat=Color /build:Textures/GUI/background/waiting.png + +#begin Textures/GUI/checkboxs_off-on.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/GUI/checkboxs_off-on.png #begin Textures/GUI/Button.png /importer:TextureImporter @@ -533,7 +545,7 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/Button2.png -#begin Textures/GUI/checkboxs_off-on.png +#begin Textures/GUI/checkboxs_off.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -543,7 +555,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/GUI/checkboxs_off-on.png +/build:Textures/GUI/checkboxs_off.png #begin Textures/GUI/checkboxs_off.png /importer:TextureImporter @@ -821,6 +833,18 @@ /processorParam:TextureFormat=Color /build:Textures/icons/Collectables/Wood.png +#begin Textures/icons/ExitZone.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/ExitZone.png + #begin Textures/icons/Material/Fabric.png /importer:TextureImporter /processor:TextureProcessor diff --git a/ZoFo/Content/Textures/icons/ExitZone.png b/ZoFo/Content/Textures/icons/ExitZone.png new file mode 100644 index 0000000..0ff693d Binary files /dev/null and b/ZoFo/Content/Textures/icons/ExitZone.png differ diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index ff0a36b..1b4fcba 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -245,7 +245,11 @@ namespace ZoFo.GameCore if (ent != null) DeleteObject(ent); - } + } + else if (update is UpdateGameEnded) + { + GameEnd(); + } else if (update is UpdatePlayerParametrs) { UpdatePlayerHealth(update as UpdatePlayerParametrs); @@ -299,9 +303,13 @@ namespace ZoFo.GameCore (ent as Player).health = (update as UpdatePlayerParametrs).health; (ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin; } - + } + public void GameEnd() + { + AppManager.Instance.SetGUI(new FinishingGUI()); + } public Entity FindEntityById(int id) { diff --git a/ZoFo/GameCore/GameObjects/ExitZone.cs b/ZoFo/GameCore/GameObjects/ExitZone.cs new file mode 100644 index 0000000..5a12e2c --- /dev/null +++ b/ZoFo/GameCore/GameObjects/ExitZone.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects +{ + public class ExitZone : Entity + { + + + public override GraphicsComponent graphicsComponent { get; } = new StaticGraphicsComponent("Textures/icons/ExitZone"); + public ExitZone(Vector2 position) : base(position) + { + collisionComponent.OnTriggerZone += Exit; + graphicsComponent.ObjectDrawRectangle.Width = 100; + graphicsComponent.ObjectDrawRectangle.Height = 100; + position = new Vector2(500f, 500f); + collisionComponent.isTrigger = true; + collisionComponent.triggerRectangle = new Rectangle(0, 0, 100, 100); + } + + + public void Exit(GameObject sender) + { + if (sender is Player && + AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position)).Length == AppManager.Instance.server.players.Count) + { + sender.position = new Vector2(0f, 0f); + AppManager.Instance.server.EndGame(); + AppManager.Instance.debugHud.Set("Exit", sender.position.ToString()); + } + } + } +} diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index 7e4be00..67c73c8 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -122,14 +122,12 @@ namespace ZoFo.GameCore entities = new List(); networkManager.StartGame(); new MapManager().LoadMap(); - - //TODO - //AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0))); + AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140))); //for (int i = 0; i < 20; i++) // for (int j = 0; j < 20; j++) // AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70))); - + } /// @@ -138,7 +136,8 @@ namespace ZoFo.GameCore public void EndGame() { UpdateGameEnded gameEnded = new UpdateGameEnded(); - networkManager.AddData(gameEnded); + networkManager.AddData(gameEnded); + // networkManager.CloseConnection(); } public List gameObjects = new List();