diff --git a/AnimatorFileCreatorAdvanced/Core/GUI/CreatingAnimationGUI.cs b/AnimatorFileCreatorAdvanced/Core/GUI/CreatingAnimationGUI.cs index 631efeb..83c1e05 100644 --- a/AnimatorFileCreatorAdvanced/Core/GUI/CreatingAnimationGUI.cs +++ b/AnimatorFileCreatorAdvanced/Core/GUI/CreatingAnimationGUI.cs @@ -459,7 +459,7 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI { if (!buildDone) return; ticksPassed++; - if (ticksPassed > 3) + if (ticksPassed > 1) { ticksPassed = 0; SetNextFrame(); diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index e7e525d..dc4239b 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -146,6 +146,9 @@ #begin Textures/Animations/explosion_1.animation /copy:Textures/Animations/explosion_1.animation +#begin Textures/Animations/OneAnimationPerItem/granade_spinning.animation +/copy:Textures/Animations/OneAnimationPerItem/granade_spinning.animation + #begin Textures/Animations/player_idle_down_mining.animation /copy:Textures/Animations/player_idle_down_mining.animation @@ -383,6 +386,18 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_running.png +#begin Textures/AnimationTextures/OneAnimationPerItem/granade.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/OneAnimationPerItem/granade.png + #begin Textures/AnimationTextures/Player/Grenade.png /importer:TextureImporter /processor:TextureProcessor @@ -683,6 +698,18 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/MenuBackground.jpg +#begin Textures/GUI/mouse_pressed.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/mouse_pressed.png + #begin Textures/GUI/mouse.png /importer:TextureImporter /processor:TextureProcessor diff --git a/ZoFo/Content/Textures/AnimationTextures/OneAnimationPerItem/granade.png b/ZoFo/Content/Textures/AnimationTextures/OneAnimationPerItem/granade.png new file mode 100644 index 0000000..8bc27de Binary files /dev/null and b/ZoFo/Content/Textures/AnimationTextures/OneAnimationPerItem/granade.png differ diff --git a/ZoFo/Content/Textures/Animations/OneAnimationPerItem/granade_spinning.animation b/ZoFo/Content/Textures/Animations/OneAnimationPerItem/granade_spinning.animation new file mode 100644 index 0000000..c83a560 --- /dev/null +++ b/ZoFo/Content/Textures/Animations/OneAnimationPerItem/granade_spinning.animation @@ -0,0 +1 @@ +{"id":"granade_spinning","textureName":"Textures/AnimationTextures/OneAnimationPerItem/granade","startSpriteRectangle":{"X":0,"Y":0,"Width":256,"Height":256},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":6,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/Player/player_running.animation b/ZoFo/Content/Textures/Animations/Player/player_running.animation index 68ee9e9..89100da 100644 --- a/ZoFo/Content/Textures/Animations/Player/player_running.animation +++ b/ZoFo/Content/Textures/Animations/Player/player_running.animation @@ -1 +1 @@ -{"id":"player_running","textureName":"Textures/AnimationTextures/Player/Run","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":1}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} +{"id":"player_running","textureName":"Textures/AnimationTextures/Player/Run","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/zombie_walk.animation b/ZoFo/Content/Textures/Animations/zombie_walk.animation index 872e797..c99061c 100644 --- a/ZoFo/Content/Textures/Animations/zombie_walk.animation +++ b/ZoFo/Content/Textures/Animations/zombie_walk.animation @@ -1 +1 @@ -{"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} +{"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/GUI/mouse_pressed.png b/ZoFo/Content/Textures/GUI/mouse_pressed.png new file mode 100644 index 0000000..98ffdd6 Binary files /dev/null and b/ZoFo/Content/Textures/GUI/mouse_pressed.png differ diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index 9ea8a50..413e3d2 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -74,7 +74,7 @@ namespace ZoFo.GameCore }; } - public void OnDataSend(string data) + public void OnDataSend(string data)//А это нужно? 0 использований метода :/ { //List updateDatas = JsonSerializer.Deserialize>(data); JArray jToken = JsonConvert.DeserializeObject(data) as JArray; @@ -94,7 +94,11 @@ namespace ZoFo.GameCore } public void GameEndedUnexpectedly() { } - + /// + /// Подключиться к комнате + /// + /// + /// public void JoinRoom(string ip, int port) { networkManager.JoinRoom(ip, port); @@ -113,7 +117,11 @@ namespace ZoFo.GameCore float shakeEffect = 0; public void AddShaking(float power) { - shakeEffect += power*3; + shakeEffect += power; + if (shakeEffect>10) + { + shakeEffect = 10; + } } public void UpdateShaking() { diff --git a/ZoFo/GameCore/GUI/AbstractGUI.cs b/ZoFo/GameCore/GUI/AbstractGUI.cs index 6aafbb2..073f360 100644 --- a/ZoFo/GameCore/GUI/AbstractGUI.cs +++ b/ZoFo/GameCore/GUI/AbstractGUI.cs @@ -22,6 +22,7 @@ public abstract class AbstractGUI private bool isStartedPrint = false; private bool isPressed = false; private Texture2D mouse; + private Texture2D mouse_pressed; private MouseState mouseState; public AbstractGUI() @@ -40,6 +41,7 @@ public abstract class AbstractGUI { Manager.LoadContent(AppManager.Instance.Content, "Fonts/Font"); mouse = AppManager.Instance.Content.Load("Textures/GUI/mouse"); + mouse_pressed = AppManager.Instance.Content.Load("Textures/GUI/mouse_pressed"); } public virtual void Update(GameTime gameTime) @@ -52,7 +54,11 @@ public abstract class AbstractGUI { Manager.Draw(spriteBatch); spriteBatch.Begin(); - spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White); - spriteBatch.End(); - } -} \ No newline at end of file + if (Mouse.GetState().LeftButton == ButtonState.Pressed) + spriteBatch.Draw(mouse_pressed, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White); + else + 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/HUD.cs b/ZoFo/GameCore/GUI/HUD.cs index ce556c0..c4d5411 100644 --- a/ZoFo/GameCore/GUI/HUD.cs +++ b/ZoFo/GameCore/GUI/HUD.cs @@ -20,6 +20,7 @@ public class HUD : AbstractGUI public AbstractGUI overlayGUI; protected override void CreateUI() { + int width = AppManager.Instance.CurentScreenResolution.X; int height = AppManager.Instance.CurentScreenResolution.Y; diff --git a/ZoFo/GameCore/GUI/LoadingGameScreenGUI.cs b/ZoFo/GameCore/GUI/LoadingGameScreenGUI.cs new file mode 100644 index 0000000..9d67e88 --- /dev/null +++ b/ZoFo/GameCore/GUI/LoadingGameScreenGUI.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using MonogameLibrary.UI.Base; +using MonogameLibrary.UI.Elements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using ZoFo.GameCore.GameManagers; + +namespace ZoFo.GameCore.GUI +{ + internal class LoadingGameScreenGUI : AbstractGUI + { + private DrawableUIElement menuBackground; + protected override void CreateUI() + { + int width = AppManager.Instance.CurentScreenResolution.X; + int height = AppManager.Instance.CurentScreenResolution.Y; + + + menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/waiting" }; + Elements.Add(menuBackground); + menuBackground.LoadTexture(AppManager.Instance.Content); + + var loading = new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), + text = "Loading...", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font3" }; + + Elements.Add(loading); + + } + + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + } + } +} diff --git a/ZoFo/GameCore/GUI/SelectModeMenu.cs b/ZoFo/GameCore/GUI/SelectModeMenu.cs index b4ee1e0..c8c67f1 100644 --- a/ZoFo/GameCore/GUI/SelectModeMenu.cs +++ b/ZoFo/GameCore/GUI/SelectModeMenu.cs @@ -50,7 +50,8 @@ public class SelectModeMenu : AbstractGUI server.CreateRoom(false); client.JoinYourself(server.MyIp.Port); //AppManager.Instance.ChangeState(GameState.HostPlaying); - AppManager.Instance.SetGUI(new HUD()); + AppManager.Instance.SetGUI(new HUD() { }); + //server.CreateRoom(1); //client.JoinYourself(); diff --git a/ZoFo/GameCore/GameManagers/InputManager.cs b/ZoFo/GameCore/GameManagers/InputManager.cs index c4aa94d..35033de 100644 --- a/ZoFo/GameCore/GameManagers/InputManager.cs +++ b/ZoFo/GameCore/GameManagers/InputManager.cs @@ -8,12 +8,12 @@ using System.Diagnostics; using ZoFo.GameCore.GUI; namespace ZoFo.GameCore.GameManagers -{ +{ public enum ScopeState { Idle, Left, Right, Top, Down, TopLeft, TopRight, DownLeft, DownRight } public class InputManager { public event Action ShootEvent; // событие удара(когда нажат X, событие срабатывает) - + public event Action OnInteract; // событие взаимодействия с collectable(например, лутом) //с помощью кнопки E. @@ -57,205 +57,235 @@ namespace ZoFo.GameCore.GameManagers } #region Работа с GamePad - #region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика. - GamePadState gamePadState = GamePad.GetState(0); - InputMovementDirection = gamePadState.ThumbSticks.Left; - InputAttackDirection = gamePadState.ThumbSticks.Right; - #endregion + #region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика. + GamePadState gamePadState = GamePad.GetState(0); + InputMovementDirection = gamePadState.ThumbSticks.Left; + InputAttackDirection = gamePadState.ThumbSticks.Right; + #endregion - #region читы - if (gamePadState.Triggers.Left >= 0.9 && gamePadState.Triggers.Right >= 0.9) - _cheatsEnabled = true; - if (_cheatsEnabled) - { - if (gamePadState.Buttons.Y == ButtonState.Pressed && lastGamePadState.Buttons.Y == ButtonState.Released) - InvincibilityCheat = !InvincibilityCheat; - if (gamePadState.Buttons.B == ButtonState.Pressed && lastGamePadState.Buttons.B == ButtonState.Released) - CollisionsCheat = !CollisionsCheat; - //TODO: infinite ammo cheat by gamepad - } - #endregion // Cheats + #region читы + if (gamePadState.Triggers.Left >= 0.9 && gamePadState.Triggers.Right >= 0.9) + _cheatsEnabled = true; + if (_cheatsEnabled) + { + if (gamePadState.Buttons.Y == ButtonState.Pressed && lastGamePadState.Buttons.Y == ButtonState.Released) + InvincibilityCheat = !InvincibilityCheat; + if (gamePadState.Buttons.B == ButtonState.Pressed && lastGamePadState.Buttons.B == ButtonState.Released) + CollisionsCheat = !CollisionsCheat; + //TODO: infinite ammo cheat by gamepad + } + #endregion // Cheats - #region set ScopeState - ConvertVector2ToState(InputMovementDirection); - #endregion + #region set ScopeState + ConvertVector2ToState(InputMovementDirection); + #endregion - #region Обработка нажатия выстрела. Вызывает событие ShootEvent - if (gamePadState.Buttons.X == ButtonState.Pressed && !isShoot) - { - isShoot = true; - ShootEvent?.Invoke(); - Debug.WriteLine("Выстрел"); - } - else if (gamePadState.Buttons.X == ButtonState.Released) - { - isShoot = false; - } - #endregion + #region Обработка нажатия выстрела. Вызывает событие ShootEvent + if (gamePadState.Buttons.X == ButtonState.Pressed && !isShoot) + { + isShoot = true; + ShootEvent?.Invoke(); + Debug.WriteLine("Выстрел"); + } + else if (gamePadState.Buttons.X == ButtonState.Released) + { + isShoot = false; + } + #endregion - lastGamePadState = gamePadState; + 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; - if (_cheatsEnabled) - { - if (keyBoardState.IsKeyDown(Keys.I) && lastKeyboardState.IsKeyUp(Keys.I)) - InvincibilityCheat = !InvincibilityCheat; - if (keyBoardState.IsKeyDown(Keys.C) && lastKeyboardState.IsKeyUp(Keys.C)) - CollisionsCheat = !CollisionsCheat; - if (keyBoardState.IsKeyDown(Keys.N) && lastKeyboardState.IsKeyUp(Keys.N)) - InfiniteAmmoCheat = !InfiniteAmmoCheat; - - List lvls = new List() { Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9 }; - - for (int i = 0; i < lvls.Count; i++) - { - //if (keyBoardState.IsKeyDown(lvls[i]) && lastKeyboardState.IsKeyUp(lvls[i])) //TODO - // AppManager.Instance.Restart($"lvl{i}"); - } - } - #endregion // Cheats - - #region Обработка состояния объекта. Задает значение полю scopeState. - if (keyBoardState.IsKeyDown(Keys.Up) || keyBoardState.IsKeyDown(Keys.W)) - { - InputMovementDirection += new Vector2(0, -1); - } - if (keyBoardState.IsKeyDown(Keys.Down) || keyBoardState.IsKeyDown(Keys.S)) - { - InputMovementDirection += new Vector2(0, 1); - } - if (keyBoardState.IsKeyDown(Keys.Right) || keyBoardState.IsKeyDown(Keys.D)) - { - InputMovementDirection += new Vector2(1, 0); - } - if (keyBoardState.IsKeyDown(Keys.Left) || keyBoardState.IsKeyDown(Keys.A)) - { - InputMovementDirection += new Vector2(-1, 0); - - } - ConvertVector2ToState(InputMovementDirection); - #endregion - - #region Обработка нажатия выстрела. Вызывает событие ShootEvent - if ((keyBoardState.IsKeyDown(Keys.P) || keyBoardState.IsKeyDown(Keys.F)) && !isShoot) - { - isShoot = true; - ShootEvent?.Invoke(); - Debug.WriteLine("Выстрел"); - } - else if (keyBoardState.IsKeyUp(Keys.F)) - { - isShoot = false; - } - #endregion - - #region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract - if ((keyBoardState.IsKeyDown(Keys.E) || mouseState.LeftButton == ButtonState.Pressed) && !isInteract) - { - OnInteract?.Invoke(); - Debug.WriteLine("взаимодействие с Collectable"); - } - else if (keyBoardState.IsKeyUp(Keys.E)) - { - isInteract = false; - } - #endregion - lastKeyboardState = keyBoardState; - - #endregion - #region ActionEvent - if(InputMovementDirection != prevInputMovementDirection || - InputAttackDirection != prevInputAttackDirection || - currentScopeState != prevCurrentScopeState) - { - ActionEvent?.Invoke(); - } - prevInputMovementDirection = InputMovementDirection; - prevInputAttackDirection = InputAttackDirection; - prevCurrentScopeState = currentScopeState; + #region Состояние клавиатуры + KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры #endregion - + + #region InputAttack with mouse + MouseState mouseState = Mouse.GetState(); + AppManager.Instance.debugHud.Set("mouse position", $"({mouseState.X}, {mouseState.Y}"); + + Vector2 a = (AppManager.Instance.CurentScreenResolution / new Point(2, 2)).ToVector2(); //player is always in the centre + + InputAttackDirection = Vector2.Normalize(new Vector2(mouseState.X - a.X, mouseState.Y - a.Y)); + AppManager.Instance.debugHud.Set("AttackDir(normalize)", $"({a.X}, {a.Y})"); + + if (keyBoardState.IsKeyDown(Keys.Down)) + { + InputAttackDirection.Y = 1; + } + else if (keyBoardState.IsKeyDown(Keys.Up)) + InputAttackDirection.Y = -1; + else + InputAttackDirection.Y = 0; + + if (keyBoardState.IsKeyDown(Keys.Right)) + { + InputAttackDirection.X = 1; + } + else if (keyBoardState.IsKeyDown(Keys.Left)) + InputAttackDirection.X = -1; + else + InputAttackDirection.X = 0; + + + #endregion + + + + #region читы + if (keyBoardState.IsKeyDown(Keys.LeftShift) && keyBoardState.IsKeyDown(Keys.RightShift)) + _cheatsEnabled = true; + if (_cheatsEnabled) + { + if (keyBoardState.IsKeyDown(Keys.I) && lastKeyboardState.IsKeyUp(Keys.I)) + InvincibilityCheat = !InvincibilityCheat; + if (keyBoardState.IsKeyDown(Keys.C) && lastKeyboardState.IsKeyUp(Keys.C)) + CollisionsCheat = !CollisionsCheat; + if (keyBoardState.IsKeyDown(Keys.N) && lastKeyboardState.IsKeyUp(Keys.N)) + InfiniteAmmoCheat = !InfiniteAmmoCheat; + + List lvls = new List() { Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9 }; + + for (int i = 0; i < lvls.Count; i++) + { + //if (keyBoardState.IsKeyDown(lvls[i]) && lastKeyboardState.IsKeyUp(lvls[i])) //TODO + // AppManager.Instance.Restart($"lvl{i}"); + } + } + #endregion // Cheats + + #region Обработка состояния объекта. Задает значение полю scopeState. + bool useReverseControls = false; + if ((keyBoardState.IsKeyDown(Keys.Up) && useReverseControls) + || (keyBoardState.IsKeyDown(Keys.W) && !useReverseControls)) + { + InputMovementDirection += new Vector2(0, -1); + } + if ((keyBoardState.IsKeyDown(Keys.Down) && useReverseControls) + || (keyBoardState.IsKeyDown(Keys.S) && !useReverseControls)) + { + InputMovementDirection += new Vector2(0, 1); + } + if ((keyBoardState.IsKeyDown(Keys.Right) && useReverseControls) + || (keyBoardState.IsKeyDown(Keys.D) && !useReverseControls)) + { + InputMovementDirection += new Vector2(1, 0); + } + if ((keyBoardState.IsKeyDown(Keys.Left) && useReverseControls) + || (keyBoardState.IsKeyDown(Keys.A) && !useReverseControls)) + { + InputMovementDirection += new Vector2(-1, 0); + + } + ConvertVector2ToState(InputMovementDirection); + #endregion + + #region Обработка нажатия выстрела. Вызывает событие ShootEvent + if ((keyBoardState.IsKeyDown(Keys.P) || keyBoardState.IsKeyDown(Keys.F)) && !isShoot) + { + isShoot = true; + ShootEvent?.Invoke(); + Debug.WriteLine("Выстрел"); + } + else if (keyBoardState.IsKeyUp(Keys.F)) + { + isShoot = false; + } + #endregion + + #region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract + if ((keyBoardState.IsKeyDown(Keys.E) || mouseState.LeftButton == ButtonState.Pressed) && !isInteract) + { + OnInteract?.Invoke(); + Debug.WriteLine("взаимодействие с Collectable"); + } + else if (keyBoardState.IsKeyUp(Keys.E)) + { + isInteract = false; + } + #endregion + lastKeyboardState = keyBoardState; + + #endregion + #region ActionEvent + if (InputMovementDirection != prevInputMovementDirection || + InputAttackDirection != prevInputAttackDirection || + currentScopeState != prevCurrentScopeState) + { + ActionEvent?.Invoke(); + } + prevInputMovementDirection = InputMovementDirection; + prevInputAttackDirection = InputAttackDirection; + prevCurrentScopeState = currentScopeState; + #endregion + DebugHUD.Instance.Set("controls", currentScopeState.ToString()); } #region работа с ScopeState и Vector2 - /// - /// возвращает число от -14 до 16, начиная с - /// - /// - /// - public int ConvertAttackVector2ToState(Vector2 vector){ - int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, - vector.X) * (180 / Math.PI) / 360 * 32); - return currentSection; - } - public ScopeState ConvertVector2ToState(Vector2 vector) + /// + /// возвращает число от -14 до 16, начиная с + /// + /// + /// + public int ConvertAttackVector2ToState(Vector2 vector) + { + int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, + vector.X) * (180 / Math.PI) / 360 * 32); + return currentSection; + } + public ScopeState ConvertVector2ToState(Vector2 vector) + { + int currentSection = 0; + if (vector.X == 0f && vector.Y == 0f) { - int currentSection = 0; - if(vector.X == 0f && vector.Y == 0f){ - currentScopeState = ScopeState.Idle; - } - else - { - currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, - vector.X) * (180 / Math.PI) / 360 * 16); - + currentScopeState = ScopeState.Idle; + } + else + { + currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, + vector.X) * (180 / Math.PI) / 360 * 16); - switch(currentSection) + + switch (currentSection) { case -1: currentScopeState = ScopeState.Idle; break; case 0 or 1: - currentScopeState = ScopeState.Right; - break; + currentScopeState = ScopeState.Right; + break; case 2 or 3: - currentScopeState = ScopeState.DownRight; - break; + currentScopeState = ScopeState.DownRight; + break; case 4 or 5: - currentScopeState = ScopeState.Down; - break; + currentScopeState = ScopeState.Down; + break; case 6 or 7: - currentScopeState = ScopeState.DownLeft; - break; + currentScopeState = ScopeState.DownLeft; + break; case 8 or -7: - currentScopeState = ScopeState.Left; - break; + currentScopeState = ScopeState.Left; + break; case -6 or -5: - currentScopeState = ScopeState.TopLeft; - break; + currentScopeState = ScopeState.TopLeft; + break; case -4 or -3: - currentScopeState = ScopeState.Top; - break; + currentScopeState = ScopeState.Top; + break; case -2 or -1: - currentScopeState = ScopeState.TopRight; - break; + currentScopeState = ScopeState.TopRight; + break; default: - break; + break; } - + DebugHUD.DebugSet("current section", currentSection.ToString()); DebugHUD.DebugSet("y", vector.Y.ToString()); DebugHUD.DebugSet("x", vector.X.ToString()); - } - return currentScopeState; + } + return currentScopeState; } public static Vector2 ConvertStateToVector2(ScopeState scopeState) { @@ -281,7 +311,7 @@ namespace ZoFo.GameCore.GameManagers return new Vector2(1, 1); default: return new Vector2(0, 0); - } + } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index b05b093..1756d71 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -205,7 +205,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager } currentDatagrammId++; AppManager.Instance.ChangeState(GameState.HostPlaying); - AppManager.Instance.SetGUI(new HUD());//// + AppManager.Instance.SetGUI(new HUD());//// КАКОЙ В СЕРВЕРЕ ЭТО ПИСАТЬ??? } public void CloseConnection() { diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs index a8eca18..bc29d61 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs @@ -22,7 +22,7 @@ namespace ZoFo.GameCore.GameObjects public Zombie(Vector2 position) : base(position) { health = 5; - speed = 7.5f; + speed = 6.5f; graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30); collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10); isAttacking = false; diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index a99cdd9..b498618 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -290,12 +290,12 @@ public class Player : LivingEntity { direction.Normalize(); var rect = collisionComponent.stopRectangle.SetOrigin(position); - int size = 10; + int size = 30; rect.X -= size; rect.Y -= size; rect.Width += 2 * size; rect.Height += 2 * size; - rect = rect.SetOrigin(direction * 40 * mult); + rect = rect.SetOrigin(direction * 60 * mult); return rect; } } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/Particles/Granade.cs b/ZoFo/GameCore/GameObjects/Entities/Particles/Granade.cs index 9add728..4d7eee4 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Particles/Granade.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Particles/Granade.cs @@ -14,7 +14,7 @@ namespace ZoFo.GameCore.GameObjects /// public class Granade : GameObject { - public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "explosion_1" }, "explosion_1"); + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "granade_spinning" }, "granade_spinning"); /// /// TODO updates with directed effect @@ -26,7 +26,7 @@ namespace ZoFo.GameCore.GameObjects if (AppManager.Instance.client.myPlayer != null) this.positionFrom = AppManager.Instance.client.myPlayer.position; this.positionTo = positionTo; - graphicsComponent.ObjectDrawRectangle = new Rectangle(-30, -30, 60, 60).SetOrigin(position); + graphicsComponent.ObjectDrawRectangle = new Rectangle(-15, -15, 30, 30).SetOrigin(position); AppManager.Instance.SoundManager.StartSound("gun-gunshot-01", Vector2.Zero, Vector2.Zero, 0.5f, (float)(Random.Shared.NextDouble() * 2 - 1)); (graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += _ => { @@ -34,6 +34,8 @@ namespace ZoFo.GameCore.GameObjects //Delete_OnClient(this); }; + graphicsComponent.ObjectDrawRectangle.X = (int)position.X; + graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y; } Vector2 positionFrom; Vector2 positionTo; @@ -46,7 +48,7 @@ namespace ZoFo.GameCore.GameObjects position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt + (4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y; - if (dt >= 0.9) + if (dt >= 1) { FlightEndedOnServer(); return; @@ -72,18 +74,25 @@ namespace ZoFo.GameCore.GameObjects } public override void Update_OnClient() { + float m = Math.Min(positionFrom.Y, positionTo.Y)-40; + position.X = (1 - dt) * positionFrom.X + dt * positionTo.X; + position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt + + (4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y; + + dt += 0.05f; + + if (dt >= 1) { //Granade Finished the flight - Instantiate_OnClient(new Explosion(position + ExtentionClass.RandomVector()*10)); + Instantiate_OnClient(new Explosion(position + ExtentionClass.RandomVector() * 10)); Delete_OnClient(this); - base.Update_OnClient(); for (int i = 0; i < 10; i++) { if (Random.Shared.NextDouble() < 0.1) continue; float angl = i / 10f * (float)Math.PI * 2; - Instantiate_OnClient(new Explosion(position + + Instantiate_OnClient(new Explosion(position + new Vector2((float)Math.Cos(angl), (float)Math.Sin(angl) ) * 30)); @@ -91,15 +100,10 @@ namespace ZoFo.GameCore.GameObjects var rect = GetDamageRectangle(); - + return; } - float m = Math.Min(positionFrom.Y, positionTo.Y)-40; - position.X = (1 - dt) * positionFrom.X + dt * positionTo.X; - position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt + - (4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y; - dt += 0.05f; //position = //base.Update_OnClient(); @@ -121,7 +125,7 @@ namespace ZoFo.GameCore.GameObjects var rect = graphicsComponent.ObjectDrawRectangle; rect.X = (int)position.X; rect.Y = (int)position.Y; - int size = 10; + int size = 20; rect.X -= size; rect.Y -= size; rect.Width += 2 * size;