Merge pull request #8 from progtime-net/Collision

Collision merged 1 merge conflict fix
This commit is contained in:
SergoDobro 2024-08-16 00:36:28 +03:00 committed by GitHub
commit 80b7d88099
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 17 deletions

View file

@ -1,8 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZoFo", "ZoFo\ZoFo.csproj", "{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}"
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZoFo", "ZoFo\ZoFo.csproj", "{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonogameLibrary", "MonogameLibrary\MonogameLibrary.csproj", "{D6272E15-AD49-468A-BE0F-D812E8697FAC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonogameLibrary", "MonogameLibrary\MonogameLibrary.csproj", "{40880E68-4B3A-417B-A39B-95DE46AA2E7E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -14,9 +17,12 @@ Global
{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}.Release|Any CPU.Build.0 = Release|Any CPU
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Release|Any CPU.Build.0 = Release|Any CPU
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -5,11 +5,15 @@ using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameObjects;
namespace ZoFo.GameCore.GameManagers.CollisionManager
{
public class CollisionComponent
{
{
//поля
public Rectangle Bounds { get; set; }
//остановлен ли перс
bool doesStop;
Rectangle stopRectangle;
@ -21,6 +25,11 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
//delegate
public delegate void EventHandler(object sender, EventArgs e);
public CollisionComponent(int x, int y, int width, int height)
{
Bounds = new Rectangle(x, y, width, height);
}
//events
public event EventHandler<CollisionComponent> OnTriggerEnter;
@ -28,17 +37,17 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
public event EventHandler<CollisionComponent> OnTriggerExit;
// methods-event
public void TriggerEnter(object component, ///<Player player>,
public void TriggerEnter(object component, Player player,
EventArgs e)
{
}
public void TriggerZone(object component,///<Player player>,
public void TriggerZone(object component,Player player,
EventArgs e)
{
}
public void TriggerExit(object component,///<Player player>,
public void TriggerExit(object component,Player player,
EventArgs e)
{

View file

@ -5,6 +5,10 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameManagers.CollisionManager;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.GameManagers.MapManager.MapElements;
namespace ZoFo.GameCore.GameManagers.CollisionManager
{
@ -13,20 +17,40 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
public List<CollisionComponent> CollisionComponent;
public List<CollisionComponent> TriggerComponent;
public static bool CheckComponentCollision(List<CollisionComponent> collisionComponents, CollisionComponent component)
{
foreach (var collisionComponent in collisionComponents)
{
if (component.Bounds.IntersectsWith(collisionComponent.Bounds))
{
return true;
}
}
return false;
}
public void UpdateComponentCollision(List<CollisionComponent> collisionComponents)
{
}
public void UpdatePositions()
{
}
public void GetObjectInArea(Rectangle area)
{
//public void GetObjectInArea(Rectangle area)
//{
}
//}
public void Register(Rectangle rectangle)
{
//public void Register(Rectangle rectangle)
//{
}
//}
}

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>