Merge pull request #91 from progtime-net/Collision

Add GetEntitiesToUpdate
This commit is contained in:
SergoDobro 2024-08-20 14:10:02 +03:00 committed by GitHub
commit fe0a420aeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 4 deletions

View file

@ -10,6 +10,7 @@ using Microsoft.Xna.Framework;
using ZoFo.GameCore.GameManagers.MapManager.MapElements;
using ZoFo.GameCore.GameObjects.Entities;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.Graphics;
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
@ -24,8 +25,27 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
public List<CollisionComponent> ObjectsWithCollisions;
public List<CollisionComponent> EntitiesWithMovements;
public List<CollisionComponent> ObjectsWithTriggers;
public List<CollisionComponent> GetEntitiesToUpdate(Player player)
{
float ViewDistance = 500;
List<CollisionComponent> EntitiesInPlayerArea = new List<CollisionComponent>();
Rectangle ViewArea = new Rectangle((int)(player.position.X), (int)(player.position.Y),
(int)(ViewDistance), (int)(ViewDistance));
for (int i = 0; i < ObjectsWithCollisions.Count; i++)
{
if (ViewArea.Contains((float)ObjectsWithCollisions[i].gameObject.position.X, (float)ObjectsWithCollisions[i].gameObject.position.Y));
{
EntitiesInPlayerArea.Add(ObjectsWithCollisions[i]);
}
}
return EntitiesInPlayerArea;
}
//чекаем коллизии в листе
/// <summary>

View file

@ -12,6 +12,7 @@ namespace ZoFo.GameCore.GameObjects
{
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_idle" }, "zombie_idle");
@ -19,6 +20,7 @@ namespace ZoFo.GameCore.GameObjects
public EntittyForAnimationTests(Vector2 position) : base(position)
{
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*20, 16 * 20);
position = new Vector2(10, 10);
}

View file

@ -15,7 +15,7 @@ using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.GameObjects;
public class Player : LivingEntity
{
{
public Vector2 InputWeaponRotation { get; set; }
public Vector2 InputPlayerRotation { get; set; }
@ -36,7 +36,7 @@ public class Player : LivingEntity
/// <summary>
/// Факт того, что плеер в этом апдейте пытается стрелять
/// </summary>
public bool IsTryingToShoot { get; set; }
public bool IsTryingToShoot { get; set; }
public Player(Vector2 position) : base(position)
{
lootData = new LootData();

View file

@ -35,8 +35,8 @@
<ProjectReference Include="..\MonogameLibrary\MonogameLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Content\sounds\Zombie\" />
<Folder Include="Content\Textures\Animations\PlayerAFK\" />
<Folder Include="Content\sounds\Zombie\" />
<Folder Include="Content\Textures\Animations\PlayerAFK\" />
<Folder Include="Content\Textures\GUI\" />
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">