From 7426a68c8e32a2eb21cec6bc48cb00057c76b861 Mon Sep 17 00:00:00 2001 From: SergoDobro Date: Mon, 26 Aug 2024 10:58:44 +0300 Subject: [PATCH] work in progress --- ZoFo/GameCore/Client.cs | 4 +-- .../Entities/LivingEntities/LivingEntity.cs | 4 +-- .../Entities/Particles/Particle.cs | 30 ++++++++++++++++++- ZoFo/GameCore/GameObjects/GameObject.cs | 2 +- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index ae83a7f..518ef06 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -133,11 +133,11 @@ namespace ZoFo.GameCore UpdateShaking(); for (int i = 0; i < gameObjects.Count; i++) { - gameObjects[i].UpdateAnimations(); + gameObjects[i].Update_OnClient(); } for (int i = 0; i < particles.Count; i++) { - particles[i].UpdateAnimations(); + particles[i].Update_OnClient(); } networkManager.SendData();//set to ticks diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs index 0104778..c2a0f95 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs @@ -34,9 +34,9 @@ public class LivingEntity : Entity } - public override void UpdateAnimations() + public override void Update_OnClient() { - base.UpdateAnimations(); + base.Update_OnClient(); } protected Vector2 prevPosition_forClient; public override void Draw(SpriteBatch spriteBatch) diff --git a/ZoFo/GameCore/GameObjects/Entities/Particles/Particle.cs b/ZoFo/GameCore/GameObjects/Entities/Particles/Particle.cs index 6067c7e..c641896 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Particles/Particle.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Particles/Particle.cs @@ -16,7 +16,7 @@ namespace ZoFo.GameCore.GameObjects public Particle(Vector2 position) : base(position) { - } + } } public class Explosion : Particle { @@ -33,4 +33,32 @@ namespace ZoFo.GameCore.GameObjects }; } } + public class Granade : Particle + { + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "explosion_1" }, "explosion_1"); + + public Granade(Vector2 positionTo, Vector2? positionFrom = null) : base(positionTo) + { + + graphicsComponent.ObjectDrawRectangle = new Rectangle(-30, -30, 60, 60).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 += _ => { + + Delete_OnClient(this); + + }; + } + Vector2 positionFrom; + Vector2 positionTo; + float dt = 0; + public override void Update_OnClient() + { + position.X = (1 - dt) * positionFrom.X + dt * positionTo.X; + position.Y = (1 - dt) * positionFrom.X + dt * positionTo.X; + dt += 0.05f; + + //position = + base.Update_OnClient(); + } + } } diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index ecd051d..56ce1ba 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -109,7 +109,7 @@ public abstract class GameObject /// Для клиента /// Обновление, которое вызывается у клиента, для просмотра анимаций /// - public virtual void UpdateAnimations() + public virtual void Update_OnClient() { positionDraw = (position * 0.15f + positionDraw*0.85f); graphicsComponent.ObjectDrawRectangle.X = (int)positionDraw.X; //Move To place where Updates Sets your position