From 77c6ec9bcac98d659d3145b5691379d0bda3e97a Mon Sep 17 00:00:00 2001 From: Timofey06 Date: Fri, 18 Aug 2023 12:53:44 +0300 Subject: [PATCH 1/8] AddBossArena --- DangerousD/Content/LastLvl.tmx | 130 ++++++++++++++++++ DangerousD/GameCore/GameObjects/GameObject.cs | 4 +- .../GameCore/Graphics/GraphicsComponent.cs | 3 +- DangerousD/GameCore/Managers/AppManager.cs | 2 +- 4 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 DangerousD/Content/LastLvl.tmx 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/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index a583904..030334a 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -62,9 +62,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/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index 5a659c8..589096d 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -5,6 +5,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 @@ -17,7 +18,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 AnimationContainer CurrentAnimation { get diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 33327c7..25dfeb2 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -205,7 +205,7 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: - GameManager.mapManager.LoadLevel("lvl"); + GameManager.mapManager.LoadLevel("LastLvl"); GameManager.FindBorders(); break; case GameState.Death: From e587ee34efd5d43681b33084abb6f4b8e037f918 Mon Sep 17 00:00:00 2001 From: Timofey06 Date: Fri, 18 Aug 2023 16:37:59 +0300 Subject: [PATCH 2/8] StartRestart --- DangerousD/GameCore/Managers/AppManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 10124d6..d871eae 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -38,7 +38,7 @@ namespace DangerousD.GameCore IDrawableObject HUD; public DebugHUD DebugHUD; 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(); @@ -74,6 +74,7 @@ namespace DangerousD.GameCore DebugHUD = new DebugHUD(); UIManager.resolution = resolution; UIManager.resolutionInGame = inGameResolution; + currentMap = "lvl"; } protected override void Initialize() @@ -204,7 +205,7 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: - GameManager.mapManager.LoadLevel("LastLvl"); + GameManager.mapManager.LoadLevel(currentMap); GameManager.FindBorders(); break; case GameState.Death: @@ -290,5 +291,9 @@ namespace DangerousD.GameCore { this.multiPlayerStatus = multiPlayerStatus; } + public void Restart(string map) + { + + } } } From eb89ae4de9eee7111ec5601358628d680303dc01 Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Fri, 18 Aug 2023 16:50:18 +0300 Subject: [PATCH 3/8] GameOver NetworkSupport --- DangerousD/GameCore/GameObjects/GameObject.cs | 1 + .../LivingEntities/Monsters/Zombie.cs | 20 +++++++++---- DangerousD/GameCore/Managers/AppManager.cs | 13 ++++++++- DangerousD/GameCore/Network/NetworkTask.cs | 29 +++++++++---------- .../Network/NetworkTaskOperationEnum.cs | 2 +- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index 8526427..60009ee 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; } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index c1737f2..c8c685c 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using DangerousD.GameCore.Managers; +using DangerousD.GameCore.Network; namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { @@ -62,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; @@ -71,7 +76,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { GraphicsComponent.StartAnimation("ZombieRightAttack"); } - AppManager.Instance.GameManager.players[0].Death(name); } else if (!isGoRight) { @@ -79,7 +83,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { GraphicsComponent.StartAnimation("ZombieLeftAttack"); } - AppManager.Instance.GameManager.players[0].Death(name); } } @@ -120,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/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 5a2cf29..12616f9 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -220,7 +220,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); @@ -276,6 +281,12 @@ namespace DangerousD.GameCore remoteConnectedPlayer.id = networkTask.objId; remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId; break; + 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; } 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 } } From b43c3a457dc6caefccd9c28e0e3a76ad4013d55d Mon Sep 17 00:00:00 2001 From: bmvolf Date: Fri, 18 Aug 2023 16:52:38 +0300 Subject: [PATCH 4/8] added up shooting --- .../Content/animations/playerShootBoomUpLeft | 1 + .../Content/animations/playerShootBoomUpRight | 24 ++++ .../LivingEntities/Monsters/CoreEnemy.cs | 4 +- .../LivingEntities/Monsters/Zombie.cs | 4 +- .../LivingEntities/Player/Player.cs | 126 ++++++++++++++---- .../GameCore/GameObjects/LivingEntity.cs | 2 + 6 files changed, 128 insertions(+), 33 deletions(-) create mode 100644 DangerousD/Content/animations/playerShootBoomUpLeft create mode 100644 DangerousD/Content/animations/playerShootBoomUpRight diff --git a/DangerousD/Content/animations/playerShootBoomUpLeft b/DangerousD/Content/animations/playerShootBoomUpLeft new file mode 100644 index 0000000..093eb3c --- /dev/null +++ b/DangerousD/Content/animations/playerShootBoomUpLeft @@ -0,0 +1 @@ +{"id":"playerShootBoomUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerShootBoomUpRight b/DangerousD/Content/animations/playerShootBoomUpRight new file mode 100644 index 0000000..3f70e03 --- /dev/null +++ b/DangerousD/Content/animations/playerShootBoomUpRight @@ -0,0 +1,24 @@ +{ + "id": "playerShootBoomUpRight", + "textureName": "playerAnimation", + "startSpriteRectangle": { + "X": 267, + "Y": 1, + "Width": 24, + "Height": 32 + }, + "frameSecond": [ + { + "Item1": 0, + "Item2": 3 + }, + { + "Item1": 1, + "Item2": 20 + } + ], + "textureFrameInterval": 1, + "framesCount": 2, + "isCycle": false, + "offset": "0, 0" +} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs index 38b1cc0..5f33df9 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs @@ -36,9 +36,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public abstract void Move(GameTime gameTime); - public void TakeDamage(int damage) + public virtual void TakeDamage() { - monster_health -= damage; + monster_health--; if (monster_health <= 0) { Death(); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 90fdfc2..dd4463b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -32,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters rightBorder = (int)position.X + 100; physicsManager = new PhysicsManager(); Random random = new Random(); + monster_health = 2; if(random.Next(0, 2) == 0) { isGoRight = true; @@ -174,10 +175,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Attack(GameTime gameTime) {} - public void TakeDamage() + public override void TakeDamage() { monster_health--; - GraphicsComponent.StartAnimation("ZombieRightAttack"); Particle particle = new Particle(Pos); if (monster_health <= 0) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index e076bc0..55e6a7b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -10,6 +10,7 @@ using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics; using DangerousD.GameCore.GameObjects.LivingEntities.Monsters; using DangerousD.GameCore.Network; +using DangerousD.GameCore.GameObjects.MapObjects; namespace DangerousD.GameCore.GameObjects.LivingEntities { @@ -65,6 +66,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { bullets++; } + if(a == "playerShootBoomUpRight" || a == "playerShootBoomUpLeft") + { + isShooting = false; + } }; } @@ -73,7 +78,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public bool IsAlive { get { return isAlive; } } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", - "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload"); + "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft", "playerShootBoomUpRight", + "playerShootBoomUpLeft"}, "playerReload"); public void Attack() { @@ -145,28 +151,45 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities bullets--; if (isRight) { - StartCicycleAnimation("playerShootRight"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) + if (!isUping) { - Zombie targetZombie = (Zombie)targets.First(); - targetZombie.TakeDamage(); - } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); - } - else - { - StartCicycleAnimation("playerShootLeft"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie)); - if (targets != null) - { - foreach (var target in targets) + StartCicycleAnimation("playerShootRight"); + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); + if (targets.Count() > 0) { - Zombie targetZombie = (Zombie)target; + Zombie targetZombie = (Zombie)targets.First(); targetZombie.TakeDamage(); } + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); + } + else + { + StartCicycleAnimation("playerShootBoomUpRight"); + Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); + bullet.ShootUpRight(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); + } + } + else if(!isRight) + { + if (!isUping) + { + StartCicycleAnimation("playerShootLeft"); + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); + if (targets.Count() > 0) + { + Zombie targetZombie = (Zombie)targets.First(); + targetZombie.TakeDamage(); + } + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); + } + else + { + StartCicycleAnimation("playerShootBoomUpLeft"); + Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); + bullet.ShootUpLeft(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); } } } @@ -230,14 +253,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { - if (bullets < 5) - { - if (GraphicsComponent.GetCurrentAnimation != "playerReload") - { - GraphicsComponent.StartAnimation("playerReload"); - } - } - else if (isRight) + if (isRight) { if (isUping) { @@ -246,6 +262,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.StartAnimation("playerShootUpRight"); } } + else if (bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } else { GraphicsComponent.StartAnimation("playerRightStay"); @@ -260,6 +283,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.StartAnimation("playerShootUpLeft"); } } + else if (bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } else { GraphicsComponent.StartAnimation("playerStayLeft"); @@ -279,13 +309,51 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities isOnGround = false; } - public class Bullet : GameObjects.LivingEntity + public class Bullet : LivingEntity { public Bullet(Vector2 position) : base(position) { + Height = 5; + Width = 5; + } + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft"}, "playerMoveLeft"); + Vector2 direction; + Vector2 maindirection; + public void ShootUpRight() + { + direction = new Vector2(1, -1); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + } + public void ShootUpLeft() + { + direction = new Vector2(-1, -1); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + } + public override void OnCollision(GameObject gameObject) + { + if (gameObject is not Player) + { + if (gameObject is CoreEnemy) + { + CoreEnemy enemy = (CoreEnemy)gameObject; + enemy.TakeDamage(); + AppManager.Instance.GameManager.Remove(this); + } + base.OnCollision(gameObject); + } + } + public override void Update(GameTime gameTime) + { + if (maindirection!=velocity) + { + AppManager.Instance.GameManager.Remove(this); + } + base.Update(gameTime); } - protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft"); - } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index 78ea17c..72d61f4 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -10,6 +10,8 @@ public abstract class LivingEntity : Entity public Vector2 velocity; public Vector2 acceleration; + public Vector2 Acceleration { get; private set; } + public LivingEntity(Vector2 position) : base(position) { acceleration = new Vector2(0, 30); From 7e300eb46dd10496bf118440a416f50c49ebfa1b Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Fri, 18 Aug 2023 17:08:35 +0300 Subject: [PATCH 5/8] Lvel1 mobs --- DangerousD/Content/Door.tsx | 2 +- DangerousD/Content/lvl.tmx | 40 ++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) 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/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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + From 91db8f92d005a96848d2ad3b17565cc50d7abd10 Mon Sep 17 00:00:00 2001 From: polten0 Date: Fri, 18 Aug 2023 17:37:48 +0300 Subject: [PATCH 6/8] AddDeathAnimations --- DangerousD/Content/animations/DeathFromGhost | 1 + DangerousD/Content/animations/DeathFromHunchman | 1 + DangerousD/Content/animations/DeathFromSilasMaster | 1 + DangerousD/Content/animations/DeathFromSlime | 1 + DangerousD/Content/animations/DeathFromSpider | 1 + DangerousD/Content/animations/DeathFromWerewolf | 1 + 6 files changed, 6 insertions(+) create mode 100644 DangerousD/Content/animations/DeathFromGhost create mode 100644 DangerousD/Content/animations/DeathFromHunchman create mode 100644 DangerousD/Content/animations/DeathFromSilasMaster create mode 100644 DangerousD/Content/animations/DeathFromSlime create mode 100644 DangerousD/Content/animations/DeathFromSpider create mode 100644 DangerousD/Content/animations/DeathFromWerewolf diff --git a/DangerousD/Content/animations/DeathFromGhost b/DangerousD/Content/animations/DeathFromGhost new file mode 100644 index 0000000..b4ef48e --- /dev/null +++ b/DangerousD/Content/animations/DeathFromGhost @@ -0,0 +1 @@ +{"id":"DeathFromGhost","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":246,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromHunchman b/DangerousD/Content/animations/DeathFromHunchman new file mode 100644 index 0000000..a00ed27 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromHunchman @@ -0,0 +1 @@ +{"id":"DeathFromHunchman","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromSilasMaster b/DangerousD/Content/animations/DeathFromSilasMaster new file mode 100644 index 0000000..3f9a76b --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSilasMaster @@ -0,0 +1 @@ +{"id":"DeathFromSilasMaster","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/animations/DeathFromSlime b/DangerousD/Content/animations/DeathFromSlime new file mode 100644 index 0000000..5a692f6 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSlime @@ -0,0 +1 @@ +{"id":"DeathFromSlime","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":50,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromSpider b/DangerousD/Content/animations/DeathFromSpider new file mode 100644 index 0000000..98a08a5 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSpider @@ -0,0 +1 @@ +{"id":"DeathFromSpider","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":148,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromWerewolf b/DangerousD/Content/animations/DeathFromWerewolf new file mode 100644 index 0000000..8f0b150 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromWerewolf @@ -0,0 +1 @@ +{"id":"DeathFromWerewolf","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":197,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} From a47f73d52380ce83db1ed5f96da606f5535211f3 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:38:59 +0300 Subject: [PATCH 7/8] fix texture names --- DangerousD/Content/Content.mgcb | 8 ++++---- DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} | Bin .../{SmokeAnimation2.png => smokeAnimation2.png} | Bin 3 files changed, 4 insertions(+), 4 deletions(-) rename DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} (100%) rename DangerousD/Content/{SmokeAnimation2.png => smokeAnimation2.png} (100%) diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index ea7bb60..b3ce6cc 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -140,7 +140,7 @@ /processorParam:TextureFormat=Color /build:menuFon.jpg -#begin MenuFon2.jpg +#begin menuFon2.jpg /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -150,7 +150,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:MenuFon2.jpg +/build:menuFon2.jpg #begin menuFon3.jpg /importer:TextureImporter @@ -255,7 +255,7 @@ /processorParam:Quality=Best /build:sounds/shotgun_shot.mp3 -#begin SmokeAnimation2.png +#begin smokeAnimation2.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -265,7 +265,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:SmokeAnimation2.png +/build:smokeAnimation2.png #begin textboxbackground1-1.png /importer:TextureImporter diff --git a/DangerousD/Content/MenuFon2.jpg b/DangerousD/Content/menuFon2.jpg similarity index 100% rename from DangerousD/Content/MenuFon2.jpg rename to DangerousD/Content/menuFon2.jpg diff --git a/DangerousD/Content/SmokeAnimation2.png b/DangerousD/Content/smokeAnimation2.png similarity index 100% rename from DangerousD/Content/SmokeAnimation2.png rename to DangerousD/Content/smokeAnimation2.png From 4386e9db8b21bbca3eb93ad7923ae3efe69e8214 Mon Sep 17 00:00:00 2001 From: Timofey06 Date: Fri, 18 Aug 2023 17:48:08 +0300 Subject: [PATCH 8/8] RestartAdded --- DangerousD/GameCore/GUI/DeathGUI.cs | 2 +- .../LivingEntities/Player/AnimationRectangle.cs | 17 +++++++++-------- DangerousD/GameCore/Managers/AppManager.cs | 6 ++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/DangerousD/GameCore/GUI/DeathGUI.cs b/DangerousD/GameCore/GUI/DeathGUI.cs index 31bff02..ce73850 100644 --- a/DangerousD/GameCore/GUI/DeathGUI.cs +++ b/DangerousD/GameCore/GUI/DeathGUI.cs @@ -23,7 +23,7 @@ internal class DeathGUI : AbstractGui Elements.Add(butMenu); butMenu.LeftButtonPressed += () => { - AppManager.Instance.ChangeGameState(GameState.Menu); + AppManager.Instance.Restart("lvl"); }; foreach (var item in Elements) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs index 8644b77..e199e4d 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs @@ -25,14 +25,15 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath private void PlayDeath(string deathName) { - if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie") - { - GraphicsComponent.StartAnimation("DeathFromZombie"); - } - if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand") - { - GraphicsComponent.StartAnimation("DeathFromSilasHand"); - } + //if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie") + //{ + // GraphicsComponent.StartAnimation("DeathFromZombie"); + //} + //if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand") + //{ + // GraphicsComponent.StartAnimation("DeathFromSilasHand"); + //} + GraphicsComponent.StartAnimation(deathName); } } diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index aedb493..06c6f79 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -208,7 +208,7 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: - GameManager.mapManager.LoadLevel("lvl"); + GameManager.mapManager.LoadLevel(currentMap); GameManager.FindBorders(); break; case GameState.Death: @@ -326,7 +326,9 @@ namespace DangerousD.GameCore } public void Restart(string map) { - + GameManager = new(); + ChangeGameState(GameState.Menu); + currentMap = map; } } }