Add GetEntitiesToUpdate
This commit is contained in:
parent
d0dc0c4714
commit
bba5bbb707
4 changed files with 26 additions and 2 deletions
|
@ -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.GameObjects.Entities.LivingEntities.Player;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||
{
|
||||
|
@ -21,6 +22,26 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//чекаем коллизии в листе
|
||||
public void CheckComponentCollision(LivingEntity entity)
|
||||
|
|
|
@ -12,10 +12,10 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
|||
{
|
||||
|
||||
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
|
||||
public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "player_idle_top-right_noweapon" }, "player_idle_top-right_noweapon");
|
||||
public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "-" }, "-");
|
||||
public EntittyForAnimationTests(Vector2 position) : base(position)
|
||||
{
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,50,50);
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,150,150);
|
||||
position = new Vector2(10, 10);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ public class Player : LivingEntity
|
|||
Texture2D texture;
|
||||
private float speed;
|
||||
private int health;
|
||||
|
||||
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
//InputWeaponRotation = new Vector2(0, 0);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Content\sounds\Zombie\" />
|
||||
<Folder Include="Content\Textures\AnimationTextures\Zombie\" />
|
||||
<Folder Include="Content\Textures\GUI\" />
|
||||
</ItemGroup>
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
|
|
Loading…
Add table
Reference in a new issue