diff --git a/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs b/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs index 96c9cbc..0438b33 100644 --- a/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs +++ b/ZoFo/GameCore/GameManagers/CollisionManager/CollisionManager.cs @@ -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 EntitiesWithMovements; public List ObjectsWithTriggers; + public List GetEntitiesToUpdate(Player player) + { + float ViewDistance = 500; + + List EntitiesInPlayerArea = new List(); + + 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) diff --git a/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs b/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs index fb545a1..0cfc826 100644 --- a/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs +++ b/ZoFo/GameCore/GameObjects/Entities/EntittyForAnimationTests.cs @@ -12,10 +12,10 @@ namespace ZoFo.GameCore.GameObjects.Entities { //public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List { "тут пишите название анимации" }, "сдублируйте " + - public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List { "player_idle_top-right_noweapon" }, "player_idle_top-right_noweapon"); + public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List { "-" }, "-"); 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); } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index 20bbe18..927b3e9 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -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); diff --git a/ZoFo/ZoFo.csproj b/ZoFo/ZoFo.csproj index c3a2b36..18329ae 100644 --- a/ZoFo/ZoFo.csproj +++ b/ZoFo/ZoFo.csproj @@ -33,6 +33,7 @@ +