minor fixes and cleaning

This commit is contained in:
SergoDobro 2024-08-17 20:12:25 +03:00
parent a2ea37f1ba
commit 96e6e37b56
6 changed files with 26 additions and 42 deletions

View file

@ -1,6 +0,0 @@
namespace ZoFo.GameCore.GameManagers.CollisionManager
{
public class CollectionComponent
{
}
}

View file

@ -13,13 +13,29 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
{
public class CollisionComponent
{
//==КОНСТРУКТОР==
//==КОНСТРУКТОР==
public CollisionComponent(GameObject gameObject)
{
this.gameObject = gameObject;
hasCollision = false;
this.isTrigger = false;
AppManager.Instance.server.collisionManager.Register(this);
}
public CollisionComponent(GameObject gameObject, bool hasCollision = false, Rectangle? collisionRectangle = null, bool isTrigger = false, Rectangle? triggerRectangle = null)
{
this.gameObject = gameObject;
hasCollision = hasCollision;
this.isTrigger = isTrigger;
if (hasCollision)
this.stopRectangle = collisionRectangle.Value;
if (isTrigger)
this.triggerRectangle = triggerRectangle.Value;
AppManager.Instance.server.collisionManager.Register(this);
}
//==ПОЛЯ==
@ -46,30 +62,8 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
public event EventHandler<CollisionComponent> OnCollision;
// methods-event
public CollisionComponent(GameObject gameObject)
{
this.gameObject = gameObject;
doesStop = false;
this.isTrigger = false;
AppManager.Instance.server.collisionManager.Register(this);
}
public CollisionComponent(GameObject gameObject, bool hasCollision = false, Rectangle? collisionRectangle = null, bool isTrigger = false, Rectangle? triggerRectangle = null)
{
this.gameObject = gameObject;
doesStop = hasCollision;
this.isTrigger = isTrigger;
if (hasCollision)
this.stopRectangle = collisionRectangle.Value;
if (isTrigger)
this.triggerRectanglee = triggerRectangle.Value;
AppManager.Instance.server.collisionManager.Register(this);
}
}
}

View file

@ -31,8 +31,10 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
//for (int i = 0; i < ObjectsWithCollisions.Count; i++)
//{
var currentRect = entity.collisionComponent.stopRectangle;//задаём РЕК
var newRect = currentRect; // задаём значение старого РЕК новому РЕК
bool flagRemovedObject = false; //флаг удаления
currentRect.X+=(int)entity.position.X;
currentRect.Y+=(int)entity.position.Y;
var newRect = currentRect; // задаём значение старого РЕК новому РЕК
var collidedX = false; // соприкосновение
@ -100,11 +102,7 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
entity.velocity = Vector2.Zero;
}
//обновление позиции объекта
public void UpdateObjectsPositions()
{
}
//обновление позиции объекта
public void UpdatePositions()
{

View file

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.ItemManager
{
class ItemInfo
public class ItemInfo
{
//поля
string tag;

View file

@ -15,7 +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;
collisionComponent.OnTriggerZone += OnInteraction;
}
private void ChangeInteraction(object sender, CollisionComponent e, bool isReady)

View file

@ -25,9 +25,7 @@ namespace ZoFo.GameCore
private ServerNetworkManager networkManager;
private int ticks = 0;
public IPEndPoint MyIp { get { return networkManager.InfoConnect; } }
public CollisionManager collisionManager;
public Server()
{
networkManager = new ServerNetworkManager();