Merge pull request #35 from progtime-net/Interactable

Interactable
This commit is contained in:
Andrey 2024-08-17 01:14:17 +03:00 committed by GitHub
commit c4f34a6d8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 113 additions and 10 deletions

View file

@ -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)
{

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateAnimation : UpdateData //хранит новую анимации
/// <summary>
/// Хранит новое сосотяние анимации
/// </summary>
public class UpdateAnimation : UpdateData
{
public UpdateAnimation() { UpdateType = "UpdateAnimation"; }
}

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateEntityHealth : UpdateData//хранит новое хп entity
/// <summary>
/// Обнивляет хп сущности
/// </summary>
public class UpdateEntityHealth : UpdateData
{
public UpdateEntityHealth() { UpdateType = "UpdateEntityHealth"; }
}

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateGameEnded : UpdateData //хранит полученый лут и уведомляет о конце игры
/// <summary>
/// Хранит полученый лут и уведомляет о конце игры
/// </summary>
public class UpdateGameEnded : UpdateData
{
public UpdateGameEnded() { UpdateType = "UpdateGameEnded"; }
}

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateGameObjectCreated : UpdateData //Хранит объект, который только отправили
/// <summary>
/// Хранит объект, который только отправили
/// </summary>
public class UpdateGameObjectCreated : UpdateData
{
public UpdateGameObjectCreated() { UpdateType = "UpdateGameObjectCreated"; }
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
/// <summary>
/// Хранит объект, который надо удлить
/// </summary>
public class UpdateGameObjectDeleted : UpdateData
{
public UpdateGameObjectDeleted() { UpdateType = "UpdateGameObjectDeleted"; }
}
}

View file

@ -0,0 +1,10 @@
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
/// <summary>
/// При попытке взаимодействия с объектом
/// </summary>
public class UpdateInteraction : UpdateData
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}

View file

@ -0,0 +1,14 @@
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
/// <summary>
/// При изменении возможности повзаимодействовать с объектом
/// </summary>
/// <param name="idEntity"></param>
/// <param name="isReady"></param>
public class UpdateInteractionReady(int idEntity, bool isReady)
: UpdateData
{
public int IdEntity { get; set; } = idEntity;
public string UpdateType { get; set; }
public bool IsReady { get; set; } = isReady;
}

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateLoot : UpdateData //Хранит лут
/// <summary>
/// Хранит лут
/// </summary>
public class UpdateLoot : UpdateData
{
public UpdateLoot() { UpdateType = "UpdateLoot"; }
}

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdatePlayerParametrs : UpdateData //Хранит хп, радиацию
/// <summary>
/// Хранит хп, радиацию
/// </summary>
public class UpdatePlayerParametrs : UpdateData
{
public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; }
}

View file

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdatePosition : UpdateData //Хранит новую позицию
/// <summary>
/// Хранит новую позицию
/// </summary>
public class UpdatePosition : UpdateData
{
public UpdatePosition() { UpdateType = "UpdatePosition"; }
}

View file

@ -11,6 +11,9 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
/// <summary>
/// При создании тайла
/// </summary>
public class UpdateTileCreated : UpdateData
{
public UpdateTileCreated() { UpdateType = "UpdateTileCreated"; }

View file

@ -14,12 +14,15 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates
[JsonDerivedType(typeof(UpdateEntityHealth))]
[JsonDerivedType(typeof(UpdateGameEnded))]
[JsonDerivedType(typeof(UpdateGameObjectCreated))]
[JsonDerivedType(typeof(UpdateGameObjectDeleted))]
[JsonDerivedType(typeof(UpdateLoot))]
[JsonDerivedType(typeof(UpdatePlayerParametrs))]
[JsonDerivedType(typeof(UpdatePosition))]
[JsonDerivedType(typeof(UpdateTileCreated))]
[JsonDerivedType(typeof(UpdateInput))]
[JsonDerivedType(typeof(UpdatePlayerExit))]
[JsonDerivedType(typeof(UpdateInteractionReady))]
[JsonDerivedType(typeof(UpdateInteraction))]
public class UpdateData
{

View file

@ -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)
{

View file

@ -0,0 +1,8 @@
namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
public class Door
{
public bool isOpened;
}

View file

@ -0,0 +1,26 @@
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 UpdateInteractionReady((sender as Player).Id, isReady));
}
public void OnInteraction()
{
}
}

View file

@ -12,7 +12,6 @@ public abstract class GameObject
{
public Vector2 position;
private Server server;
public Vector2 rotation; //вектор направления объекта
public abstract GraphicsComponent graphicsComponent { get; }