diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 3c8e320..7f25a41 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -16,6 +16,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { Width = 32; Height = 64; + /*GraphicsComponent.actionOfAnimationEnd += () => + { + AppManager.Instance.ChangeGameState(GameState.GameOver); + };*/ } public bool IsAlive { get { return isAlive; } } @@ -31,6 +35,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities if(monsterName == "Zombie") { DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); + //GraphicsComponent.actionOfAnimationEnd(); } isAlive = false; } diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index e4eb390..6c86077 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -8,9 +8,10 @@ using System.Text; namespace DangerousD.GameCore.Graphics { + public class GraphicsComponent { - //public Action actionOfAnimationEnd; + public Action actionOfAnimationEnd; private List animations; private List textures; private List texturesNames; @@ -115,8 +116,12 @@ namespace DangerousD.GameCore.Graphics { if (!currentAnimation.IsCycle) { + if(actionOfAnimationEnd != null) + { + actionOfAnimationEnd(currentAnimation.Id); + } currentAnimation = neitralAnimation; - //actionOfAnimationEnd(); + } currentFrame = 0; @@ -199,4 +204,4 @@ namespace DangerousD.GameCore.Graphics } } } -} \ No newline at end of file +} diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index dc44ba9..ab061b9 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -13,7 +13,7 @@ using DangerousD.GameCore.Managers; namespace DangerousD.GameCore { - public enum GameState { Menu, Options, Lobby, Game, Login } + public enum GameState { Menu, Options, Lobby, Game, Login, GameOver } public class AppManager : Game { public static AppManager Instance { get; private set; } diff --git a/DangerousD/GameCore/Managers/SettingsManager.cs b/DangerousD/GameCore/Managers/SettingsManager.cs index b04f3e6..7a55447 100644 --- a/DangerousD/GameCore/Managers/SettingsManager.cs +++ b/DangerousD/GameCore/Managers/SettingsManager.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Newtonsoft.Json.Serialization; namespace DangerousD.GameCore.Managers { @@ -21,10 +22,12 @@ namespace DangerousD.GameCore.Managers public void SetResolution(Point resolution) { settingsContainer.Resolution = resolution; + AppManager.Instance.resolution = resolution; } public void SetMainVolume(float volume) { settingsContainer.MainVolume = MainVolume; + ///AppManager.Instance.SoundManager. } public void SetMusicVolume(float volume) @@ -45,22 +48,30 @@ namespace DangerousD.GameCore.Managers { if (!File.Exists("GameSettings.txt")) { - File.Create("GameSettings.txt"); SaveSettings(); return; } - - var serializedObject = JsonConvert.DeserializeObject(File.ReadAllText("GameSettings.txt")); - + + settingsContainer = JsonConvert.DeserializeObject(File.ReadAllText("GameSettings.txt")); + SetIsFullScreen(settingsContainer.IsFullScreen); + SetMainVolume(settingsContainer.MainVolume); + SetMusicVolume(settingsContainer.MusicVolume); + SetResolution(settingsContainer.Resolution); + SetSoundEffectsVolume(settingsContainer.SoundEffectsVolume); + + } public void SaveSettings() { - if (!File.Exists("GameSettings.txt")) - File.Create("GameSettings.txt"); - File.WriteAllText("GameSettings.txt", JsonConvert.SerializeObject(settingsContainer)); + using (StreamWriter streamWriter = new StreamWriter("GameSettings.txt")) + { + string _str = JsonConvert.SerializeObject(settingsContainer); + streamWriter.Write(_str); + } } } + [Serializable] public class SettingsContainer { [JsonProperty("IsFullScreen")]