Add Interatable class
This commit is contained in:
parent
2ec1b3b268
commit
b0f9bbdeec
5 changed files with 42 additions and 2 deletions
|
@ -17,7 +17,10 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
|||
public List<CollisionComponent> CollisionComponent;
|
||||
public List<CollisionComponent> TriggerComponent;
|
||||
|
||||
|
||||
public void RegisterComponent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static bool CheckComponentCollision(List<CollisionComponent> collisionComponents, CollisionComponent component)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||
|
||||
public class UpdateInteraction : IUpdateData // при попытке взаимодействия с объектом
|
||||
{
|
||||
public int IdEntity { get; set; }
|
||||
public string UpdateType { get; set; }
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||
|
||||
public class UpdateInteractionAvailable(int idEntity, bool isReady)
|
||||
: IUpdateData // при изменении возможности повзаимодействовать с объектом
|
||||
{
|
||||
public int IdEntity { get; set; } = idEntity;
|
||||
public string UpdateType { get; set; }
|
||||
public bool IsReady { get; set; } = isReady;
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
using System;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
||||
public class Collectable : Entity
|
||||
public class Collectable : Interactable
|
||||
{
|
||||
public Collectable(Vector2 position) : base(position)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
|
||||
|
||||
public class Interactable : Entity
|
||||
{
|
||||
public Interactable(Vector2 position) : base(position)
|
||||
{
|
||||
collisionComponent.OnTriggerEnter += (sender, e) => ChangeInteraction(sender, e, true);
|
||||
collisionComponent.OnTriggerExit += (sender, e) => ChangeInteraction(sender, e, false);
|
||||
}
|
||||
|
||||
private void ChangeInteraction(object sender, CollisionComponent e, bool isReady)
|
||||
{
|
||||
AppManager.Instance.server.AddData(new UpdateInteractionAvailable((sender as Player).Id, isReady));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue