Merge branch 'DevelopmentY' of github.com:progtime-net/ZoFo into DevelopmentY

This commit is contained in:
SergoDobro 2024-09-11 18:04:35 +03:00
commit 6d47993988
4 changed files with 21 additions and 4 deletions

View file

@ -250,7 +250,7 @@ namespace ZoFo.GameCore
}
else if (update is UpdateGameEnded)
{
GameEnd();
EndGame();
}
else if (update is UpdatePlayerParametrs && myPlayer !=null && update.IdEntity == myPlayer.Id) //aaa
{
@ -336,12 +336,16 @@ namespace ZoFo.GameCore
(ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin;
}
}
public void GameEnd()
public void EndGame()
{
networkManager.CloseConnection();
CloseConnection();
AppManager.Instance.ChangeState(GameState.NotPlaying);
AppManager.Instance.SetGUI(new FinishingGUI());
}
public void CloseConnection()
{
networkManager.CloseConnection();
}
public Entity FindEntityById(int id)
{

View file

@ -68,6 +68,7 @@ public class FinishingGUI : AbstractGUI
Elements.Add(ExitButton);
//player itams
if (AppManager.Instance.client.myPlayer is null) return;
foreach (var item in AppManager.Instance.client.myPlayer.lootData.loots)
{
if (item.Value > 0)

View file

@ -48,6 +48,14 @@ public class PauseGUI : AbstractGUI
};
exitButton.LeftButtonPressed += () =>
{
if (AppManager.Instance.gamestate == GameState.HostPlaying)
{
AppManager.Instance.server.EndGame();
}
else
{
AppManager.Instance.client.CloseConnection();
}
AppManager.Instance.SoundManager.StopAllSounds();
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SoundManager.StartAmbientSound("Background menu music");

View file

@ -159,7 +159,11 @@ namespace ZoFo.GameCore
UpdateGameEnded gameEnded = new UpdateGameEnded();
networkManager.AddData(gameEnded);
networkManager.SendData();
networkManager.CloseConnection();
CloseConnection();
}
public void CloseConnection()
{
networkManager.CloseConnection();
}
public List<GameObject> gameObjects = new List<GameObject>();