Merge pull request #100 from progtime-net/exitzone

Exitzone
This commit is contained in:
SergoDobro 2024-08-20 18:00:31 +03:00 committed by GitHub
commit fd996c732d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 82 additions and 9 deletions

View file

@ -508,6 +508,18 @@
/processorParam:MakeSquare=False /processorParam:MakeSquare=False
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/background/waiting.png /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 #begin Textures/GUI/Button.png
/importer:TextureImporter /importer:TextureImporter
@ -533,7 +545,7 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/Button2.png /build:Textures/GUI/Button2.png
#begin Textures/GUI/checkboxs_off-on.png #begin Textures/GUI/checkboxs_off.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255 /processorParam:ColorKeyColor=255,0,255,255
@ -543,7 +555,7 @@
/processorParam:ResizeToPowerOfTwo=False /processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False /processorParam:MakeSquare=False
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/checkboxs_off-on.png /build:Textures/GUI/checkboxs_off.png
#begin Textures/GUI/checkboxs_off.png #begin Textures/GUI/checkboxs_off.png
/importer:TextureImporter /importer:TextureImporter
@ -821,6 +833,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Wood.png /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 #begin Textures/icons/Material/Fabric.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

View file

@ -245,7 +245,11 @@ namespace ZoFo.GameCore
if (ent != null) if (ent != null)
DeleteObject(ent); DeleteObject(ent);
} }
else if (update is UpdateGameEnded)
{
GameEnd();
}
else if (update is UpdatePlayerParametrs) else if (update is UpdatePlayerParametrs)
{ {
UpdatePlayerHealth(update as UpdatePlayerParametrs); UpdatePlayerHealth(update as UpdatePlayerParametrs);
@ -299,9 +303,13 @@ namespace ZoFo.GameCore
(ent as Player).health = (update as UpdatePlayerParametrs).health; (ent as Player).health = (update as UpdatePlayerParametrs).health;
(ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin; (ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin;
} }
} }
public void GameEnd()
{
AppManager.Instance.SetGUI(new FinishingGUI());
}
public Entity FindEntityById(int id) public Entity FindEntityById(int id)
{ {

View file

@ -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());
}
}
}
}

View file

@ -122,14 +122,12 @@ namespace ZoFo.GameCore
entities = new List<Entity>(); entities = new List<Entity>();
networkManager.StartGame(); networkManager.StartGame();
new MapManager().LoadMap(); new MapManager().LoadMap();
//TODO
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140))); AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140)));
//for (int i = 0; i < 20; i++) //for (int i = 0; i < 20; i++)
// for (int j = 0; j < 20; j++) // for (int j = 0; j < 20; j++)
// AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70))); // AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70)));
} }
/// <summary> /// <summary>
@ -138,7 +136,8 @@ namespace ZoFo.GameCore
public void EndGame() public void EndGame()
{ {
UpdateGameEnded gameEnded = new UpdateGameEnded(); UpdateGameEnded gameEnded = new UpdateGameEnded();
networkManager.AddData(gameEnded); networkManager.AddData(gameEnded);
// networkManager.CloseConnection();
} }
public List<GameObject> gameObjects = new List<GameObject>(); public List<GameObject> gameObjects = new List<GameObject>();