diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index ea0d2f4..c966a97 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -73,12 +73,6 @@ /processorParam:Quality=Best /build:sounds/Tabletki 2.wav -#begin sounds/Tabletki.mp3 -/importer:Mp3Importer -/processor:SongProcessor -/processorParam:Quality=Best -/build:sounds/Tabletki.mp3 - #begin sounds/Zombi napal.wav /importer:WavImporter /processor:SoundEffectProcessor @@ -91,18 +85,6 @@ /processorParam:Quality=Best /build:sounds/Zombi stoit.wav -#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.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/AnimationTextures/Character/hr-level1_idle_gun.png - #begin Textures/AnimationTextures/Character/hr-level1_idle.png /importer:TextureImporter /processor:TextureProcessor @@ -115,6 +97,18 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_idle.png +#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.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/AnimationTextures/Character/hr-level1_idle_gun.png + #begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png /importer:TextureImporter /processor:TextureProcessor @@ -139,18 +133,6 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png -#begin Textures/AnimationTextures/Character/hr-level1_running_gun.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/AnimationTextures/Character/hr-level1_running_gun.png - #begin Textures/AnimationTextures/Character/hr-level1_running.png /importer:TextureImporter /processor:TextureProcessor @@ -163,6 +145,18 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_running.png +#begin Textures/AnimationTextures/Character/hr-level1_running_gun.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/AnimationTextures/Character/hr-level1_running_gun.png + #begin Textures/AnimationTextures/unicorn.png /importer:TextureImporter /processor:TextureProcessor diff --git a/ZoFo/Content/sounds/Tabletki.mp3 b/ZoFo/Content/sounds/Tabletki.mp3 deleted file mode 100644 index 1a44967..0000000 Binary files a/ZoFo/Content/sounds/Tabletki.mp3 and /dev/null differ diff --git a/ZoFo/GameCore/GUI/AbstractGUI.cs b/ZoFo/GameCore/GUI/AbstractGUI.cs index 0134477..e8ceb33 100644 --- a/ZoFo/GameCore/GUI/AbstractGUI.cs +++ b/ZoFo/GameCore/GUI/AbstractGUI.cs @@ -52,7 +52,7 @@ public abstract class AbstractGUI { Manager.Draw(spriteBatch); spriteBatch.Begin(); - spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.Red); + spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White); spriteBatch.End(); } } \ No newline at end of file diff --git a/ZoFo/GameCore/GUI/MainMenuGUI.cs b/ZoFo/GameCore/GUI/MainMenuGUI.cs index e0d0c15..5d258eb 100644 --- a/ZoFo/GameCore/GUI/MainMenuGUI.cs +++ b/ZoFo/GameCore/GUI/MainMenuGUI.cs @@ -40,6 +40,7 @@ public class MainMenuGUI : AbstractGUI }; playButton.LeftButtonPressed += () => { + AppManager.Instance.SoundManager.StartAmbientSound("Loot"); AppManager.Instance.SetGUI(new SelectModeMenu()); }; Elements.Add(playButton); @@ -54,6 +55,7 @@ public class MainMenuGUI : AbstractGUI }; optionButton.LeftButtonPressed += () => { + AppManager.Instance.SoundManager.StartAmbientSound("Loot"); AppManager.Instance.SetGUI(new OptionsGUI()); }; Elements.Add(optionButton); diff --git a/ZoFo/GameCore/GameManagers/AppManager.cs b/ZoFo/GameCore/GameManagers/AppManager.cs index fba2e17..909423b 100644 --- a/ZoFo/GameCore/GameManagers/AppManager.cs +++ b/ZoFo/GameCore/GameManagers/AppManager.cs @@ -117,8 +117,7 @@ namespace ZoFo.GameCore.GameManagers { GraphicsDevice.Clear(Color.CornflowerBlue); - currentGUI.Draw(_spriteBatch); - debugHud.Draw(_spriteBatch); + // Pointwrap _spriteBatch.Begin(samplerState: SamplerState.PointWrap); @@ -132,7 +131,10 @@ namespace ZoFo.GameCore.GameManagers default: break; } + _spriteBatch.End(); + currentGUI.Draw(_spriteBatch); + debugHud.Draw(_spriteBatch); base.Draw(gameTime); } diff --git a/ZoFo/GameCore/GameManagers/InputManager.cs b/ZoFo/GameCore/GameManagers/InputManager.cs index 4ee0980..9bf702b 100644 --- a/ZoFo/GameCore/GameManagers/InputManager.cs +++ b/ZoFo/GameCore/GameManagers/InputManager.cs @@ -1,16 +1,19 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics.PackedVector; using Microsoft.Xna.Framework.Input; using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Formats.Tar; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Text; using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers { - public enum ScopeState { Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight } + public enum ScopeState { Idle, Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight } public class InputManager { @@ -19,10 +22,11 @@ namespace ZoFo.GameCore.GameManagers public event Delegat OnInteract; // событие взаимодействия с collectable(например, лутом) //с помощью кнопки E. + public Vector2 InputMovementDirection; + public Vector2 InputAttackDirection; public event Delegat TalkEvent; - Vector2 vectorMovementDirection; ScopeState currentScopeState; // Положение оружия. Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight. private bool _cheatsEnabled = false; public bool InvincibilityCheat { get; private set; } = false; @@ -34,18 +38,16 @@ namespace ZoFo.GameCore.GameManagers private KeyboardState lastKeyboardState; private GamePadState lastGamePadState; - - - public Vector2 VectorMovementDirection { get => vectorMovementDirection; } public ScopeState ScopeState { get => currentScopeState; } public string currentControlsState; public ScopeState CurrentScopeState { get => currentScopeState; } // получить текущее состояние public InputManager() { + InputMovementDirection = new Vector2(0, 0); + InputAttackDirection = new Vector2(0, 0); this.isShoot = false; - currentScopeState = ScopeState.Straight; - vectorMovementDirection = new Vector2(0, 0); + currentScopeState = ScopeState.Idle; } public void Update() { @@ -59,7 +61,8 @@ namespace ZoFo.GameCore.GameManagers #region Работа с GamePad #region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика. GamePadState gamePadState = GamePad.GetState(0); - vectorMovementDirection = gamePadState.ThumbSticks.Left; + InputMovementDirection = gamePadState.ThumbSticks.Left; + InputAttackDirection = gamePadState.ThumbSticks.Right; #endregion #region читы @@ -75,39 +78,38 @@ namespace ZoFo.GameCore.GameManagers } #endregion // Cheats - #region Обработка положения оружия. Задает значение полю scopeState. - if (vectorMovementDirection.Y >= 0.6) - { - currentScopeState = ScopeState.Straight; - } - else if(vectorMovementDirection.Y <= 0.6) - { - currentScopeState = ScopeState.Back; - } - else if(vectorMovementDirection.X >= 0.6) - { + #region set ScopeState + int currentSection = (int)Math.Ceiling(Math.Atan2(InputMovementDirection.Y, + InputMovementDirection.X) * 180 / Math.PI * 16 / 360); + switch(currentSection){ + case 1 or 0 or 16: currentScopeState = ScopeState.Right; - } - else if(vectorMovementDirection.X <= 0.6) - { - currentScopeState = ScopeState.Left; - } - else if(vectorMovementDirection.Y >= 0.6 && vectorMovementDirection.X >= 0.6) - { + break; + case 2 or 3: currentScopeState = ScopeState.StraightRight; - } - else if(vectorMovementDirection.Y >= 0.6 && vectorMovementDirection.X <= 0.6) - { + break; + case 4 or 5: + currentScopeState = ScopeState.Straight; + break; + case 6 or 7: currentScopeState = ScopeState.StraightLeft; - } - else if(vectorMovementDirection.Y <= 0.6 && vectorMovementDirection.X >= 0.6) - { - currentScopeState = ScopeState.BackRight; - } - else if(vectorMovementDirection.Y <= 0.6 && vectorMovementDirection.X <= 0.6) - { + break; + case 8 or 9: + currentScopeState = ScopeState.Left; + break; + case 10 or 11: currentScopeState = ScopeState.BackLeft; + break; + case 12 or 13: + currentScopeState = ScopeState.Back; + break; + case 14 or 15: + currentScopeState = ScopeState.BackRight; + break; + default: + break; } + #endregion #region Обработка нажатия выстрела. Вызывает событие ShootEvent @@ -126,10 +128,20 @@ namespace ZoFo.GameCore.GameManagers lastGamePadState = gamePadState; #endregion #region Работа с KeyBoard + #region InputAttack with mouse + MouseState mouseState = Mouse.GetState(); + AppManager.Instance.debugHud.Set("mouse position", $"({mouseState.X}, {mouseState.Y}"); + // TODO: CurentScreenResolution + Vector2 a = (AppManager.Instance.CurentScreenResolution / new Point(2, 2)).ToVector2(); + + InputAttackDirection = Vector2.Normalize(new Vector2(mouseState.X - a.X, mouseState.Y - a.Y)); + AppManager.Instance.debugHud.Set("AttackDir(normalize)", $"({a.X}, {a.Y})"); + #endregion + #region Состояние клавиатуры KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры #endregion - + #region читы if (keyBoardState.IsKeyDown(Keys.LeftShift) && keyBoardState.IsKeyDown(Keys.RightShift)) _cheatsEnabled = true; diff --git a/ZoFo/GameCore/GameManagers/SoundManager.cs b/ZoFo/GameCore/GameManagers/SoundManager.cs index 5f39e97..7e8d408 100644 --- a/ZoFo/GameCore/GameManagers/SoundManager.cs +++ b/ZoFo/GameCore/GameManagers/SoundManager.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using System.Linq; -using DangerousD.GameCore.Graphics; + using Newtonsoft.Json; using Microsoft.Xna.Framework.Media; @@ -20,23 +20,28 @@ namespace ZoFo.GameCore.GameManagers public void LoadSounds() // метод для загрузки звуков из папки { - var k = Directory.GetFiles("Content/sounds").Where(x => x.EndsWith("wav")); - + //List sounds = AppManager.Instance.Content.Load>("sounds/"); + + var k = Directory.GetFiles(Directory.GetCurrentDirectory() + "//Content//sounds").Where(x => x.EndsWith("xnb")); if (k.Count() > 0) { - string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".wav", "")).ToArray();// папка со звуками там где exe + 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)); } } - - if (k.Count() > 0) + /*/if (sounds.Count() > 0) { + foreach (var soundFile in sounds) + { + Sounds.Add(soundFile, AppManager.Instance.Content.Load("sounds/" + soundFile)); + } + }/*/ + - } } public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index d3c5d64..05edc34 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -19,7 +19,6 @@ public abstract class GameObject public GameObject(Vector2 position) { this.position = position; - graphicsComponent.LoadContent(); } public virtual void UpdateLogic(GameTime gameTime) diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index 4bea6cc..93c7018 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using MonogameLibrary.UI.Elements; using System; using System.Collections.Generic; using System.Linq; @@ -121,6 +122,7 @@ namespace ZoFo.GameCore /// public void RegisterGameObject(GameObject gameObject) { + gameObjects.Add(gameObject); if (gameObject is MapObject) { diff --git a/ZoFo/ZoFo.csproj b/ZoFo/ZoFo.csproj index c3a2b36..b4a9088 100644 --- a/ZoFo/ZoFo.csproj +++ b/ZoFo/ZoFo.csproj @@ -11,8 +11,11 @@ Icon.ico + + + @@ -32,7 +35,6 @@ -