diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 2c64b2e..65e650c 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -35,7 +35,10 @@ namespace DepthsBelow public List Squad; public DynamicGroupManager GroupManager; public List Swarm; - public List Volley; + public List Volley; + + public List Spawn; + public static Map Map; public SmallEnemy TestMonster; @@ -78,6 +81,8 @@ namespace DepthsBelow Swarm = new List(); Volley = new List(); + Spawn = new List(); + base.Initialize(); } diff --git a/DepthsBelow/DepthsBelow/DepthsBelow.csproj b/DepthsBelow/DepthsBelow/DepthsBelow.csproj index e908eb5..6d7778e 100644 --- a/DepthsBelow/DepthsBelow/DepthsBelow.csproj +++ b/DepthsBelow/DepthsBelow/DepthsBelow.csproj @@ -122,6 +122,7 @@ + diff --git a/DepthsBelow/DepthsBelow/Entity.cs b/DepthsBelow/DepthsBelow/Entity.cs index f0fcbc9..15ac841 100644 --- a/DepthsBelow/DepthsBelow/Entity.cs +++ b/DepthsBelow/DepthsBelow/Entity.cs @@ -18,7 +18,7 @@ namespace DepthsBelow /// public Component.Transform Transform; - private EntityManager entityManager; + protected EntityManager entityManager; /// /// Shorthand to the grid transform position. diff --git a/DepthsBelow/DepthsBelow/EntityManager.cs b/DepthsBelow/DepthsBelow/EntityManager.cs index ea781da..d97959a 100755 --- a/DepthsBelow/DepthsBelow/EntityManager.cs +++ b/DepthsBelow/DepthsBelow/EntityManager.cs @@ -14,6 +14,11 @@ namespace DepthsBelow { private List entities; + public List Entities + { + get { return entities; } + } + public EntityManager() { entities = new List(); diff --git a/DepthsBelow/DepthsBelow/Map.cs b/DepthsBelow/DepthsBelow/Map.cs index 9beaeea..a5c25da 100755 --- a/DepthsBelow/DepthsBelow/Map.cs +++ b/DepthsBelow/DepthsBelow/Map.cs @@ -82,6 +82,14 @@ namespace DepthsBelow core.Squad.Add(soldier); } + if (mapObject.Type == "MonsterSpawn") + { + var enemy = new MonsterSpawn(core.EntityManager, ref core.Swarm); + var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y - Grid.TileSize); + var mapObjectGridPos = Grid.WorldToGrid(mapObjectPos); + enemy.X = mapObjectGridPos.X; + enemy.Y = mapObjectGridPos.Y; + } } } } diff --git a/DepthsBelow/DepthsBelow/MonsterSpawn.cs b/DepthsBelow/DepthsBelow/MonsterSpawn.cs new file mode 100644 index 0000000..eb23585 --- /dev/null +++ b/DepthsBelow/DepthsBelow/MonsterSpawn.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace DepthsBelow +{ + public class MonsterSpawn : Entity + { + //EntityManager entityManager; + + int wakingDistance = 13; + + List swarm; + + public MonsterSpawn(EntityManager entityManager, ref List Swarm) + : base(entityManager) + { + //this.entityManager = entityManager; + swarm = Swarm; + } + + public void Update(GameTime gameTime) + { + foreach (var entity in entityManager.Entities) + { + if (entity is Soldier) + { + Vector2 distance1 = new Vector2(this.GetComponent().Grid.Position.X, this.GetComponent().Grid.Position.Y); + Vector2 distance2 = new Vector2(entity.GetComponent().Grid.Position.X, entity.GetComponent().Grid.Position.Y); + if (Vector2.Distance(distance1, distance2) > wakingDistance) + { + var enemy = new SmallEnemy(entityManager, ref swarm); + enemy.X = this.X; + enemy.Y = this.Y; + entityManager.Add(enemy); + swarm.Add(enemy); + } + } + } + } + } +}