diff --git a/DangerousD/Content/Door.tsx b/DangerousD/Content/Door.tsx index a250dd5..8e5687c 100644 --- a/DangerousD/Content/Door.tsx +++ b/DangerousD/Content/Door.tsx @@ -1,4 +1,4 @@ - + diff --git a/DangerousD/Content/LastLvl.tmx b/DangerousD/Content/LastLvl.tmx new file mode 100644 index 0000000..2efe988 --- /dev/null +++ b/DangerousD/Content/LastLvl.tmx @@ -0,0 +1,130 @@ + + + + + + +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0 + + +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,376,375,369,370,388,389,726,390,369,370,376,389,376,388,726, +0,376,389,369,370,390,726,388,388,369,370,390,726,388,389,389, +0,388,726,369,370,390,377,375,377,369,370,431,389,389,431,431, +0,389,431,369,370,377,377,389,388,369,370,431,389,375,375,431, +0,377,377,369,370,390,376,389,431,369,370,375,375,726,388,390, +0,388,431,369,370,388,390,376,726,369,370,375,377,376,388,377, +0,388,375,369,370,376,375,377,388,369,370,376,375,389,388,431, +0,390,726,369,370,377,431,431,388,369,370,389,390,390,376,377, +0,377,376,369,370,389,377,431,376,369,370,389,431,726,431,388, +0,377,431,369,370,375,390,390,377,369,370,375,377,389,388,376, +0,390,390,369,370,431,376,389,390,369,370,390,431,376,389,390, +0,431,377,369,370,376,390,388,388,369,370,377,375,390,389,377, +0,390,726,369,370,375,377,726,390,369,370,389,376,388,388,375, +0,390,389,382,383,388,377,388,390,382,383,431,726,390,388,431, +0,389,377,395,396,389,431,377,431,395,396,375,388,726,376,389 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +389,388,375,369,370,388,377,389,389,369,370,390,375,0,0,0, +390,388,726,369,370,375,726,376,726,369,370,388,375,0,0,0, +388,389,431,369,370,726,377,726,431,369,370,377,375,0,0,0, +388,376,431,369,370,377,375,726,726,369,370,431,376,0,0,0, +376,389,388,369,370,377,390,431,389,369,370,376,431,0,0,0, +389,388,389,369,370,376,726,390,377,369,370,389,377,0,0,0, +431,377,389,369,370,431,726,726,389,369,370,431,390,0,0,0, +390,389,377,369,370,390,390,376,431,369,370,390,376,0,0,0, +388,388,377,369,370,388,431,390,388,369,370,389,377,0,0,0, +388,389,390,369,370,726,377,377,388,369,370,390,390,0,0,0, +388,376,390,369,370,377,377,389,726,369,370,375,726,0,0,0, +431,726,390,369,370,375,431,377,726,369,370,389,389,0,0,0, +390,388,726,369,370,389,375,390,388,369,370,377,726,0,0,0, +375,375,375,382,383,376,390,726,388,382,383,431,726,0,0,0, +389,389,390,395,396,390,390,726,390,395,396,431,390,0,0,0 + + + + + + + + + + + + + + diff --git a/DangerousD/Content/animations/DeathFromSilasHand b/DangerousD/Content/animations/DeathFromSilasHand new file mode 100644 index 0000000..ef28c10 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSilasHand @@ -0,0 +1 @@ +{"id":"DeathFromSilasHand","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":295,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/lvl.tmx b/DangerousD/Content/lvl.tmx index 5fcea6a..5d448e5 100644 --- a/DangerousD/Content/lvl.tmx +++ b/DangerousD/Content/lvl.tmx @@ -1,5 +1,5 @@ - + @@ -683,7 +683,7 @@ - + @@ -698,13 +698,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/DangerousD/GameCore/GUI/DeathGUI.cs b/DangerousD/GameCore/GUI/DeathGUI.cs index bb91470..31bff02 100644 --- a/DangerousD/GameCore/GUI/DeathGUI.cs +++ b/DangerousD/GameCore/GUI/DeathGUI.cs @@ -13,7 +13,7 @@ internal class DeathGUI : AbstractGui { int wigth = AppManager.Instance.inGameResolution.X; int height = AppManager.Instance.inGameResolution.Y; - float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; + float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" }; Elements.Add(menuBackground); menuBackground.LoadTexture(AppManager.Instance.Content); diff --git a/DangerousD/GameCore/GUI/HUD.cs b/DangerousD/GameCore/GUI/HUD.cs index 0e24ff6..7b7a199 100644 --- a/DangerousD/GameCore/GUI/HUD.cs +++ b/DangerousD/GameCore/GUI/HUD.cs @@ -16,22 +16,26 @@ namespace DangerousD.GameCore.GUI { int wigth = AppManager.Instance.inGameResolution.X; int height = AppManager.Instance.inGameResolution.Y; - float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; + float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; Texture2D texture; SpriteFont spriteFont; public void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); - spriteBatch.Draw(texture, new Rectangle(wigth / 35 - 2, height / 35 - 2, 120 + 2, 70 + 2), Color.DarkRed); - spriteBatch.DrawString(spriteFont, "AMMO", new Vector2(wigth / 34 + 4, height / 30 - 6), Color.Gray, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0); - spriteBatch.DrawString(spriteFont, "AMMO", new Vector2(wigth / 34 + 1, height / 30 - 6), Color.White, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, new Rectangle( + (int)((wigth / 35 - 2) * scaler), + (int)((height / 35 - 2) * scaler), + (int)((120 + 2) * scaler), + (int)((70 + 2) * scaler)), Color.DarkRed); + spriteBatch.DrawString(spriteFont, "AMMO", new Vector2((wigth / 34 + 4)* scaler, height / 30 - 6), Color.Gray, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0); + spriteBatch.DrawString(spriteFont, "AMMO", new Vector2((wigth / 34 + 1 )* scaler, height / 30 - 6), Color.White, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0); for (int i = 1; i < 6; i++) { if (i <= AppManager.Instance.GameManager.players[0].Bullets) { - spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13 + 2, height / 17 + 4, 5, 20), new Color(0.8f, 0.8f, 0, 1f)); - spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13, height / 17 + 4, 5, 20), Color.Yellow); + spriteBatch.Draw(texture, new Rectangle((int)((wigth / 30 + i * 13 + 2) * scaler), (int)((height / 17 + 4) * scaler), (int)((5) * scaler), (int)((20) * scaler)), new Color(0.8f, 0.8f, 0, 1f)); + spriteBatch.Draw(texture, new Rectangle((int)((wigth / 30 + i * 13) * scaler), (int)((height / 17 + 4) * scaler), (int)((5) * scaler), (int)((20) * scaler)), Color.Yellow); } else { diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs index 3b8b9ab..90ba3c9 100644 --- a/DangerousD/GameCore/GUI/LobbyGUI.cs +++ b/DangerousD/GameCore/GUI/LobbyGUI.cs @@ -25,7 +25,7 @@ namespace DangerousD.GameCore.GUI { int screenWidth = AppManager.Instance.inGameResolution.X; int screenHeight = AppManager.Instance.inGameResolution.Y; - float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; + float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; var lobbyBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon3" }; Elements.Add(lobbyBackground); diff --git a/DangerousD/GameCore/GUI/LoginGUI.cs b/DangerousD/GameCore/GUI/LoginGUI.cs index 5b7f972..7d5ee76 100644 --- a/DangerousD/GameCore/GUI/LoginGUI.cs +++ b/DangerousD/GameCore/GUI/LoginGUI.cs @@ -26,7 +26,7 @@ namespace DangerousD.GameCore.GUI { int screenWidth = AppManager.Instance.inGameResolution.X; int screenHeight = AppManager.Instance.inGameResolution.Y; - float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; + float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; var loginBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon2" }; Elements.Add(loginBackground); diff --git a/DangerousD/GameCore/GUI/MenuGUI.cs b/DangerousD/GameCore/GUI/MenuGUI.cs index 214e747..48f42c0 100644 --- a/DangerousD/GameCore/GUI/MenuGUI.cs +++ b/DangerousD/GameCore/GUI/MenuGUI.cs @@ -24,7 +24,7 @@ internal class MenuGUI : AbstractGui { int wigth = AppManager.Instance.inGameHUDHelperResolution.X; int height = AppManager.Instance.inGameHUDHelperResolution.Y; - float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; + float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" }; Elements.Add(menuBackground); diff --git a/DangerousD/GameCore/GUI/OptionsGUI.cs b/DangerousD/GameCore/GUI/OptionsGUI.cs index 18ccd77..53b1953 100644 --- a/DangerousD/GameCore/GUI/OptionsGUI.cs +++ b/DangerousD/GameCore/GUI/OptionsGUI.cs @@ -15,7 +15,7 @@ namespace DangerousD.GameCore.GUI { int wigth = AppManager.Instance.inGameHUDHelperResolution.X; int height = AppManager.Instance.inGameHUDHelperResolution.Y; - float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; + float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" }; //Elements.Add(menuBackground); menuBackground.LoadTexture(AppManager.Instance.Content); diff --git a/DangerousD/GameCore/GameObjects/Entities/Door.cs b/DangerousD/GameCore/GameObjects/Entities/Door.cs index cacaf22..fe18355 100644 --- a/DangerousD/GameCore/GameObjects/Entities/Door.cs +++ b/DangerousD/GameCore/GameObjects/Entities/Door.cs @@ -37,15 +37,19 @@ namespace DangerousD.GameCore.GameObjects.Entities public override void OnCollision(GameObject gameObject) { base.OnCollision(gameObject); - if (gameObject is Player) + if (this is not TeleportingDoor) { - Player player = (Player)gameObject; - if (player.isUping) + if (gameObject is Player) { - AppManager.Instance.GameManager.Remove(this); - //тут спавн лута + Player player = (Player)gameObject; + if (player.isUping) + { + AppManager.Instance.GameManager.Remove(this); + //тут спавн лута + } } } + } } } diff --git a/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs b/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs index 94e7ca6..157b410 100644 --- a/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs +++ b/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs @@ -1,4 +1,5 @@ -using DangerousD.GameCore.Graphics; +using DangerousD.GameCore.GameObjects.LivingEntities; +using DangerousD.GameCore.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -14,12 +15,15 @@ namespace DangerousD.GameCore.GameObjects.Entities { private Vector2 v; + public string name; public SilasBall(Vector2 position) : base(position) { Height = 24; Width = 24; acceleration = Vector2.Zero; - + name = "SilasHand"; + + } public SilasBall(Vector2 position, Vector2 velosity) : base(position) { @@ -28,7 +32,8 @@ namespace DangerousD.GameCore.GameObjects.Entities acceleration = Vector2.Zero; velocity = velosity; v = velosity; - + name = "SilasHand"; + } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "SilasBallMove" }, "SilasBallMove"); @@ -48,5 +53,21 @@ namespace DangerousD.GameCore.GameObjects.Entities } + public void Attack() + { + AppManager.Instance.GameManager.GetPlayer1.Death(name); + } + public override void OnCollision(GameObject gameObject) + { + base.OnCollision(gameObject); + if (gameObject is Player) + { + if (AppManager.Instance.GameManager.players[0].IsAlive) + { + Attack(); + + } + } + } } } diff --git a/DangerousD/GameCore/GameObjects/Entities/TeleportingDoor.cs b/DangerousD/GameCore/GameObjects/Entities/TeleportingDoor.cs new file mode 100644 index 0000000..558771d --- /dev/null +++ b/DangerousD/GameCore/GameObjects/Entities/TeleportingDoor.cs @@ -0,0 +1,54 @@ +using DangerousD.GameCore.GameObjects.LivingEntities; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DangerousD.GameCore.GameObjects.Entities +{ + internal class TeleportingDoor : Door + { + public Vector2 Target; + public bool IsVisible = true; + public Action action; + public TeleportingDoor(Vector2 position, Vector2 size, Rectangle sourceRectangle, Vector2 target, Action action) : base(position, size, sourceRectangle) + { + Target = target; + this.action = action; + } + public override void OnCollision(GameObject gameObject) + { + if (IsVisible) + { + if (gameObject is Player) + { + Player player = (Player)gameObject; + if (player.isUping) + { + IsVisible = false; + + } + } + } + else + { + if (gameObject is Player) + { + Player player = (Player)gameObject; + if (player.isUping) + { + player.SetPosition(Target); + if (action!=null) + { + action(); + } + + } + } + } + } + + } +} diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index 8526427..9a37c58 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -15,6 +15,7 @@ namespace DangerousD.GameCore protected Vector2 _pos; public Vector2 Pos => _pos; public int id; + public bool isChildEntity = false; public bool isIdFromHost = false; public int Width { get; set; } public int Height { get; set; } @@ -63,9 +64,7 @@ namespace DangerousD.GameCore if (AppManager.Instance.InputManager.CollisionsCheat) { spriteBatch.Draw(debugTexture, - new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, - Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), - Color.White); + new Rectangle((Rectangle.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling, (Rectangle.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling, Rectangle.Width * GraphicsComponent.scaling, Rectangle.Height * GraphicsComponent.scaling),Color.White); } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs index 0baad71..f9d2cfa 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs @@ -15,6 +15,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters private Rectangle collision; private Vector2 position; private bool isFlyRight = true; + private bool isFlyUp = true; private bool isAttacking = false; public Rectangle Collision @@ -29,6 +30,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Width = 40; Height = 40; monster_speed = 3; + velocity = new Vector2(3,-3); acceleration = Vector2.Zero; } @@ -36,27 +38,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Update(GameTime gameTime) { - if(!isAttacking) - { - Move(gameTime); - } - + Move(gameTime); + AppManager.Instance.DebugHUD.Set(name, velocity.ToString()); base.Update(gameTime); } public override void Attack() { - collision = new Rectangle((int)position.X, (int)position.Y, 40, 40); - isAttacking = true; - if(isFlyRight) + } + public override void OnCollision(GameObject gameObject) + { + if (gameObject is Player) { - AppManager.Instance.GameManager.players[0].Death(name); + if (AppManager.Instance.GameManager.players[0].IsAlive) + { + AppManager.Instance.GameManager.players[0].Death(name); + } } - else if(!isFlyRight) - { - AppManager.Instance.GameManager.players[0].Death(name); - } - + base.OnCollision(gameObject); } public override void Death() @@ -66,21 +65,55 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Move(GameTime gameTime) { - velocity.X = 0; - velocity.Y = 0; + + var getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); + var getColsVer= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ; + if (isFlyRight) + { + getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y , 42, 40)); + if(getColsHor.Count > 0) + { + isFlyRight = false; + velocity.X = -velocity.X; + } + } + else + { + getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-2, (int)Pos.Y, 42, 40)); + if (getColsHor.Count > 0) + { + isFlyRight = true; + velocity.X = -velocity.X; + } + } + if (isFlyUp) + { + + getColsVer = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X , (int)Pos.Y-3, 40, 43)); + if (getColsVer.Count > 0) + { + isFlyUp = false; + velocity.Y = -velocity.Y; + } + } + else + { + getColsVer = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 40, 43)); + if (getColsVer.Count > 0) + { + isFlyUp = true; + velocity.Y = -velocity.Y; + } + } - if(isFlyRight) - { - velocity.X += monster_speed; - velocity.Y += monster_speed; - } - else if(!isFlyRight) - { - velocity.X -= monster_speed; - velocity.Y -= monster_speed; - } + } +<<<<<<< HEAD public override void Target() +======= + + public void Target() +>>>>>>> 211eac278c07f06a177b7be1fc84dd05cbf5c449 { throw new NotImplementedException(); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs index 51a0a5f..14e58f8 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs @@ -19,7 +19,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Width = 16; Height = 16; monster_health = 2; - monster_speed = 2; + monster_speed = 1; acceleration = Vector2.Zero; } @@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Attack() { - + AppManager.Instance.GameManager.GetPlayer1.Death(name); } public override void Attack(GameTime gameTime) @@ -38,7 +38,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Death() { - throw new NotImplementedException(); + for (int i = 0; i < 3; i++) + { + Particle particle = new Particle(Pos); + } + + AppManager.Instance.GameManager.Remove(this); + } public override void Move(GameTime gameTime) @@ -71,12 +77,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { base.Update(gameTime); Move(gameTime); - if ((Pos.X + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.X || Pos.X - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.X)&&(Pos.Y + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.Y || Pos.Y - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.Y)) - { - - AppManager.Instance.GameManager.GetPlayer1.Death(name); - } + GraphicsComponent.Update(); } + public void TakeDamage() + { + monster_health--; + GraphicsComponent.StartAnimation("SilasHandMove"); + Particle particle = new Particle(Pos); + if (monster_health <= 0) + { + Death(); + } + } + public override void OnCollision(GameObject gameObject) + { + if (gameObject is Player) + { + if (AppManager.Instance.GameManager.players[0].IsAlive) + { + Attack(); + + } + } + base.OnCollision(gameObject); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs index 06a1d6e..1592efb 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs @@ -16,6 +16,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters private int attackTime = 60; private int moveTime = 360; private int currentTime = 0; + private int interval = 0; int leftBorder; int rightBorder; List hands = new List(); @@ -119,9 +120,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Update(GameTime gameTime) { base.Update(gameTime); + for (int i = 0; i < hands.Count; i++) + { + if (!AppManager.Instance.GameManager.GetAllGameObjects.Contains(hands[i])) + { + hands.RemoveAt(i); + } + } + + if (hands.Count<2) { - hands.Add(new SilasHands(new Vector2(Pos.X + 60, Pos.Y + 120))); + hands.Add(new SilasHands(new Vector2(Pos.X + 30, Pos.Y + 30))); } if (GraphicsComponent.CurrentAnimation.Id == "SilasMove") { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index cf53fd2..60e02d6 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using DangerousD.GameCore.Managers; -using DangerousD.GameCore.GameObjects; +using DangerousD.GameCore.Network; namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { @@ -63,6 +63,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } public override void Attack() + { + AppManager.Instance.GameManager.GetPlayer1.Death(name); + } + public void PlayAttackAnimation() { velocity.X = 0; isAttaking = true; @@ -72,7 +76,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { GraphicsComponent.StartAnimation("ZombieRightAttack"); } - AppManager.Instance.GameManager.players[0].Death(name); } else if (!isGoRight) { @@ -80,7 +83,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { GraphicsComponent.StartAnimation("ZombieLeftAttack"); } - AppManager.Instance.GameManager.players[0].Death(name); } } @@ -121,12 +123,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } public override void OnCollision(GameObject gameObject) { - if(gameObject is Player) + if (gameObject.id == AppManager.Instance.GameManager.GetPlayer1.id && AppManager.Instance.GameManager.GetPlayer1.IsAlive) { - if (AppManager.Instance.GameManager.players[0].IsAlive) + if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client) { Attack(); - + } + } + else if (gameObject is Player) + { + if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) + { + NetworkTask task = new NetworkTask(); + AppManager.Instance.NetworkTasks.Add(task.KillPlayer(gameObject.id, name)); } } base.OnCollision(gameObject); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs index 25e01f0..8644b77 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs @@ -18,7 +18,7 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath PlayDeath(DeathType); } - protected override GraphicsComponent GraphicsComponent { get; } = new(new List {"DeathFromZombie"}, + protected override GraphicsComponent GraphicsComponent { get; } = new(new List {"DeathFromZombie", "DeathFromSilasHand" }, "DeathFromZombie"); public GraphicsComponent Gr => GraphicsComponent; @@ -29,6 +29,10 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath { GraphicsComponent.StartAnimation("DeathFromZombie"); } + if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand") + { + GraphicsComponent.StartAnimation("DeathFromSilasHand"); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index e076bc0..fc34e25 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -87,12 +87,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { base.OnCollision(gameObject); } + public Rectangle GetShootRectangle(bool isRight) + { + if (isRight) + return new Rectangle((int)Pos.X, (int)(Pos.Y) + 10, shootLength + Width, Height / 2); + else + return new Rectangle((int)Pos.X-shootLength, (int)(Pos.Y) + 10, shootLength, Height / 2); + } public override void Draw(SpriteBatch spriteBatch) { if (isVisible) { base.Draw(spriteBatch); } + if (AppManager.Instance.InputManager.CollisionsCheat) + { + Rectangle attackRect = GetShootRectangle(isRight); + spriteBatch.Draw(debugTexture, + new Rectangle((attackRect.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling, + (attackRect.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling, + attackRect.Width * GraphicsComponent.scaling, + attackRect.Height * GraphicsComponent.scaling), Color.White); + + } } public void Death(string monsterName) { @@ -101,7 +118,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities return; } isAttacked = true; - if (monsterName == "Zombie") + if(monsterName == "Zombie") { AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => @@ -112,7 +129,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } }; } - else if (monsterName == "Spider") + else if(monsterName == "Spider") + { + AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); + deathRectangle.Gr.actionOfAnimationEnd += (a) => + { + if (a == "DeathFrom" + monsterName) + { + AppManager.Instance.ChangeGameState(GameState.Death); + } + }; + } + else if (monsterName == "SilasHand") + { + AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); + deathRectangle.Gr.actionOfAnimationEnd += (a) => + { + if (a == "DeathFrom" + monsterName) + { + AppManager.Instance.ChangeGameState(GameState.Death); + } + }; + } + else if (monsterName == "SilasBall") { AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => @@ -151,6 +190,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { Zombie targetZombie = (Zombie)targets.First(); targetZombie.TakeDamage(); + + } + targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); + if (targets.Count() > 0) + { + SilasHands targetHand = (SilasHands)targets.First(); + targetHand.TakeDamage(); } SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); } @@ -166,6 +212,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities targetZombie.TakeDamage(); } } + targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)); + if (targets.Count() > 0) + { + SilasHands targetHand = (SilasHands)targets.First(); + targetHand.TakeDamage(); + } SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); } } @@ -187,7 +239,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities FallingThroughPlatform = false; } GraphicsComponent.SetCameraPosition(Pos); - if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) + if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) { if (!isShooting) { @@ -230,7 +282,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { - if (bullets < 5) + if(bullets < 5) { if (GraphicsComponent.GetCurrentAnimation != "playerReload") { diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index 1ac6aa8..9b6a8df 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.X509Certificates; using System.Text; namespace DangerousD.GameCore.Graphics @@ -20,7 +21,7 @@ namespace DangerousD.GameCore.Graphics private List textures; private List texturesNames; private AnimationContainer currentAnimation; - static private int scaling = 4; + static public int scaling = 4; public int parentId; public AnimationContainer CurrentAnimation { diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index f9ed6fd..5bf5986 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -17,7 +17,7 @@ using System.Threading.Tasks; namespace DangerousD.GameCore { public enum MultiPlayerStatus { SinglePlayer, Host, Client } - public enum GameState { Menu, Options, Lobby, Game, Login, Death, + public enum GameState { Menu, Options, Lobby, Game, Login, Death, HUD, GameOver } public class AppManager : Game @@ -30,17 +30,16 @@ namespace DangerousD.GameCore public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer; public Point resolution; public Point inGameResolution = new Point(1920, 1080); - public Point inGameHUDHelperResolution = new Point(1920, 1080); + public Point inGameHUDHelperResolution= new Point(1920, 1080); IDrawableObject MenuGUI; IDrawableObject OptionsGUI; IDrawableObject LoginGUI; IDrawableObject LobbyGUI; IDrawableObject DeathGUI; - //IDrawableObject HUD; + IDrawableObject HUD; public DebugHUD DebugHUD; - public HUD HUD; public List NetworkTasks = new List(); - + public string currentMap; public GameManager GameManager { get; private set; } = new(); public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder(); public NetworkManager NetworkManager { get; private set; } = new NetworkManager(); @@ -63,7 +62,11 @@ namespace DangerousD.GameCore NetworkManager.GetReceivingMessages += NetworkSync; resolution = SettingsManager.Resolution; - + SetIsFullScreen(!SettingsManager.IsFullScreen); + SetIsFullScreen(SettingsManager.IsFullScreen); + _graphics.PreferredBackBufferWidth = resolution.X; + _graphics.PreferredBackBufferHeight = resolution.Y; + _graphics.IsFullScreen = false; gameState = GameState.Menu; MenuGUI = new MenuGUI(); LoginGUI = new LoginGUI(); @@ -72,8 +75,9 @@ namespace DangerousD.GameCore DeathGUI = new DeathGUI(); HUD = new HUD(); DebugHUD = new DebugHUD(); - UIManager.resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight); - UIManager.resolutionInGame = resolution; + UIManager.resolution = resolution; + UIManager.resolutionInGame = inGameResolution; + currentMap = "lvl"; } protected override void Initialize() @@ -104,7 +108,7 @@ namespace DangerousD.GameCore GameObject.debugTexture.SetData(new Color[] { new Color(1, 0,0,0.25f) }); SoundManager.LoadSounds(); SoundManager.StartAmbientSound("DoomTestSong"); - renderTarget = new RenderTarget2D(GraphicsDevice, resolution.X, resolution.Y); + renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y); } protected override void Update(GameTime gameTime) @@ -136,6 +140,7 @@ namespace DangerousD.GameCore case GameState.Game: HUD.Update(gameTime); GameManager.Update(gameTime); + break; default: break; @@ -167,6 +172,9 @@ namespace DangerousD.GameCore case GameState.Death: DeathGUI.Draw(_spriteBatch); break; + case GameState.HUD: + HUD.Draw(_spriteBatch); + break; case GameState.Game: _spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp); GameManager.Draw(_spriteBatch); @@ -200,6 +208,7 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: +<<<<<<< HEAD <<<<<<< HEAD GameManager.mapManager.LoadLevel("map"); ======= @@ -208,8 +217,10 @@ namespace DangerousD.GameCore >>>>>>> main +======= + GameManager.mapManager.LoadLevel("lvl"); +>>>>>>> 211eac278c07f06a177b7be1fc84dd05cbf5c449 GameManager.FindBorders(); - break; case GameState.Death: break; @@ -224,7 +235,12 @@ namespace DangerousD.GameCore { switch (networkTask.operation) { - case NetworkTaskOperationEnum.TakeDamage: + case NetworkTaskOperationEnum.DeleteObject: + GameObject gameObject = GameManager.GetAllGameObjects.Find(x => x.id == networkTask.objId); + if (gameObject != null) + { + GameManager.Remove(gameObject); + } break; case NetworkTaskOperationEnum.SendSound: SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos); @@ -246,6 +262,11 @@ namespace DangerousD.GameCore case NetworkTaskOperationEnum.ChangeState: if (networkTask.objId != GameManager.GetPlayer1.id) { + List gcs = new List(); + foreach (var player in GameManager.players) + { + gcs.Add(player.GetGraphicsComponent()); + } LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId); if (entity != null) { @@ -280,7 +301,13 @@ namespace DangerousD.GameCore remoteConnectedPlayer.id = networkTask.objId; remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId; break; - default: + case NetworkTaskOperationEnum.KillPlayer: + Player player1 = GameManager.players.Find(x => x.id==networkTask.objId); + player1.Death(networkTask.name); + NetworkTask task1 = new NetworkTask(); + NetworkTasks.Add(task1.DeleteObject(player1.id)); + break; + default: break; } } @@ -308,5 +335,9 @@ namespace DangerousD.GameCore _graphics.IsFullScreen = fullscrin; _graphics.ApplyChanges(); } + public void Restart(string map) + { + + } } } diff --git a/DangerousD/GameCore/Managers/SettingsManager.cs b/DangerousD/GameCore/Managers/SettingsManager.cs index b781ef1..277a146 100644 --- a/DangerousD/GameCore/Managers/SettingsManager.cs +++ b/DangerousD/GameCore/Managers/SettingsManager.cs @@ -87,6 +87,6 @@ namespace DangerousD.GameCore.Managers [JsonProperty("SoundEffectsVolume")] public float SoundEffectsVolume { get; set; } = 1; [JsonProperty("Resolution")] - public Point Resolution { get; set; } = new Point(1920,1080); + public Point Resolution { get; set; } = new Point(1366,768); } } diff --git a/DangerousD/GameCore/Network/NetworkTask.cs b/DangerousD/GameCore/Network/NetworkTask.cs index 8611d78..f9b6072 100644 --- a/DangerousD/GameCore/Network/NetworkTask.cs +++ b/DangerousD/GameCore/Network/NetworkTask.cs @@ -20,18 +20,6 @@ namespace DangerousD.GameCore.Network public Type type { get; set; } public NetworkTask() { } - /// - /// Нанести урон сущности - /// - /// - /// - public NetworkTask(int LivingEntityId, int Damage) - { - operation = NetworkTaskOperationEnum.TakeDamage; - objId = LivingEntityId; - value = Damage; - } - /// /// Проиграть звук на позиции /// @@ -49,14 +37,12 @@ namespace DangerousD.GameCore.Network /// /// /// - /// /// - public NetworkTask(Type EntityType, Vector2 EntityPosition, Vector2 EntityVelocity, int ParentId) + public NetworkTask(Type EntityType, Vector2 EntityPosition, int ParentId) { operation = NetworkTaskOperationEnum.CreateEntity; type = EntityType; position = EntityPosition; - velocity = EntityVelocity; objId = ParentId; } @@ -134,5 +120,18 @@ namespace DangerousD.GameCore.Network position = playerPosition; return this; } + public NetworkTask DeleteObject(int objectId) + { + operation = NetworkTaskOperationEnum.DeleteObject; + objId = objectId; + return this; + } + public NetworkTask KillPlayer(int playerId, string mosterName) + { + operation = NetworkTaskOperationEnum.KillPlayer; + name = mosterName; + objId = playerId; + return this; + } } } diff --git a/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs b/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs index 7fad430..5b746f5 100644 --- a/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs +++ b/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs @@ -9,6 +9,6 @@ namespace DangerousD.GameCore.Network [Serializable] public enum NetworkTaskOperationEnum { - TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer + DeleteObject, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer, KillPlayer } }