diff --git a/ZoFo/GameCore/GameManagers/AppManager.cs b/ZoFo/GameCore/GameManagers/AppManager.cs index 909423b..224dba2 100644 --- a/ZoFo/GameCore/GameManagers/AppManager.cs +++ b/ZoFo/GameCore/GameManagers/AppManager.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; -using DangerousD.GameCore.Graphics; +using ZoFo.GameCore.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; diff --git a/ZoFo/GameCore/GameManagers/CollisionManager/CollisionComponent.cs b/ZoFo/GameCore/GameManagers/CollisionManager/CollisionComponent.cs index 880e159..6da4619 100644 --- a/ZoFo/GameCore/GameManagers/CollisionManager/CollisionComponent.cs +++ b/ZoFo/GameCore/GameManagers/CollisionManager/CollisionComponent.cs @@ -38,11 +38,13 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager - //events + //events DoorInteraction public event EventHandler OnTriggerEnter; public event EventHandler OnTriggerZone; public event EventHandler OnTriggerExit; + public event EventHandler OnTriggerInteract; + // methods-event public void TriggerEnter(object component, Player player, EventArgs e) diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs index e42f0f4..09b0bc3 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateInteraction.cs @@ -5,6 +5,11 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; /// public class UpdateInteraction : UpdateData { + public UpdateInteraction(int id) + { + IdEntity = id; + } + public int IdEntity { get; set; } public string UpdateType { get; set; } } \ No newline at end of file diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs index a96b270..65ef2d2 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs @@ -26,7 +26,17 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates public class UpdateData { - public int IdEntity { get; set; } //Id объекта + public int IdEntity { get; set; } //Id объекта public string UpdateType { get; protected set; } //тип обновления + + public UpdateData() + { + + } + + public UpdateData(int idEntity) + { + this.IdEntity = idEntity; + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs b/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs index adafb5e..3aeded4 100644 --- a/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs +++ b/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using ZoFo.GameCore.ZoFo_graphics; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities { diff --git a/ZoFo/GameCore/GameObjects/Entities/Entity.cs b/ZoFo/GameCore/GameObjects/Entities/Entity.cs index 0c7d453..6d0397c 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Entity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Entity.cs @@ -4,7 +4,6 @@ using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ZoFo.GameCore.GameManagers.CollisionManager; -using ZoFo.GameCore.ZoFo_graphics; namespace ZoFo.GameCore.GameObjects.Entities { diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs index d31d536..bfe7113 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Collectables/Collectable.cs @@ -1,5 +1,8 @@ using Microsoft.Xna.Framework; using System; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; public class Collectable : Interactable @@ -7,4 +10,9 @@ public class Collectable : Interactable public Collectable(Vector2 position) : base(position) { } + + public override void OnInteraction(object sender, CollisionComponent e) + { + AppManager.Instance.server.AddData(new UpdateInteraction(Id)); + } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs index 711a50b..640c9c1 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Door.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; -using ZoFo.GameCore.ZoFo_graphics; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.Interactables; @@ -15,11 +16,9 @@ public class Door : Interactable graphicsComponent.OnAnimationEnd += _ => { isOpened = !isOpened; }; } - public override void OnInteraction() + public override void OnInteraction(object sender, CollisionComponent e) { - graphicsComponent.AnimationInit("DoorInteraction", isOpened); - graphicsComponent.StartAnimation(); + graphicsComponent.AnimationSelect("DoorInteraction", isOpened); + graphicsComponent.AnimationStep(); } - - } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs b/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs index 35a124f..bfe1b42 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Interactables/Interactable.cs @@ -3,7 +3,7 @@ using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers.CollisionManager; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player; -using ZoFo.GameCore.ZoFo_graphics; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.Interactables; @@ -15,6 +15,7 @@ public class Interactable : Entity { collisionComponent.OnTriggerEnter += (sender, e) => ChangeInteraction(sender, e, true); collisionComponent.OnTriggerExit += (sender, e) => ChangeInteraction(sender, e, false); + collisionComponent.OnTriggerInteract += OnInteraction; } private void ChangeInteraction(object sender, CollisionComponent e, bool isReady) @@ -22,7 +23,7 @@ public class Interactable : Entity AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady)); } - public virtual void OnInteraction() + public virtual void OnInteraction(object sender, CollisionComponent e) { } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs index 84e7d45..00a1870 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs @@ -2,9 +2,9 @@ using Microsoft.Xna.Framework.Graphics; using System; using ZoFo.GameCore.GameObjects.Entities; -using ZoFo.GameCore.ZoFo_graphics; using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities; public class LivingEntity : Entity diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index 05edc34..e8b2508 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -3,8 +3,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using ZoFo.GameCore.GameManagers; -using ZoFo.GameCore.ZoFo_graphics; using ZoFo.GameCore; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects; diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs index 51a3a4e..15ac53c 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; -using ZoFo.GameCore.ZoFo_graphics; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore.GameObjects.MapObjects { diff --git a/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs index 02f828e..51ff06c 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using System; using ZoFo.GameCore.GameManagers.CollisionManager; -using ZoFo.GameCore.ZoFo_graphics; namespace ZoFo.GameCore.GameObjects.MapObjects.StopObjects; diff --git a/ZoFo/GameCore/Graphics/AnimationBuilder.cs b/ZoFo/GameCore/Graphics/AnimationBuilder.cs index a7f6214..2ff7ac4 100644 --- a/ZoFo/GameCore/Graphics/AnimationBuilder.cs +++ b/ZoFo/GameCore/Graphics/AnimationBuilder.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.Text; using System.IO; using Newtonsoft.Json; -using Zofo.GameCore.ZoFo_grafics; -namespace DangerousD.GameCore.Graphics +namespace ZoFo.GameCore.Graphics { public class AnimationBuilder { diff --git a/ZoFo/GameCore/Graphics/AnimationContainer.cs b/ZoFo/GameCore/Graphics/AnimationContainer.cs index 36596d0..2ffc974 100644 --- a/ZoFo/GameCore/Graphics/AnimationContainer.cs +++ b/ZoFo/GameCore/Graphics/AnimationContainer.cs @@ -1,10 +1,9 @@ -using Microsoft.Xna.Framework; -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; -using System.Text; +using Microsoft.Xna.Framework; +using Newtonsoft.Json; -namespace Zofo.GameCore.ZoFo_grafics +namespace ZoFo.GameCore.Graphics { [Serializable] public class AnimationContainer diff --git a/ZoFo/GameCore/Graphics/GraphicsComponent.cs b/ZoFo/GameCore/Graphics/GraphicsComponent.cs index 0d2734f..e8f9f17 100644 --- a/ZoFo/GameCore/Graphics/GraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/GraphicsComponent.cs @@ -1,16 +1,11 @@ -using ZoFo.GameCore.GameObjects; -using ZoFo.GameCore.GameManagers; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using Zofo.GameCore.ZoFo_grafics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ZoFo.GameCore.GameManagers; -namespace ZoFo.GameCore.ZoFo_graphics +namespace ZoFo.GameCore.Graphics { public class GraphicsComponent @@ -129,7 +124,7 @@ namespace ZoFo.GameCore.ZoFo_graphics } } - public void AnimationInit(string animationId, bool reverse = false) + public void AnimationSelect(string animationId, bool reverse = false) { currentAnimation = animations.Find(x => x.Id == animationId); if (reverse) @@ -151,7 +146,7 @@ namespace ZoFo.GameCore.ZoFo_graphics animating = true; } - public void StepAnimation() + public void AnimationStep() { currentFrame += step; } diff --git a/architecture.drawio.png b/architecture.drawio.png index c83ffee..4cb9f0f 100644 Binary files a/architecture.drawio.png and b/architecture.drawio.png differ