diff --git a/DepthsBelow/DepthsBelow/MonsterSpawn.cs b/DepthsBelow/DepthsBelow/MonsterSpawn.cs index eb23585..1ad98df 100644 --- a/DepthsBelow/DepthsBelow/MonsterSpawn.cs +++ b/DepthsBelow/DepthsBelow/MonsterSpawn.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using Microsoft.Xna.Framework; @@ -10,7 +11,7 @@ namespace DepthsBelow { //EntityManager entityManager; - int wakingDistance = 13; + int wakingDistance = 6; List swarm; @@ -21,24 +22,28 @@ namespace DepthsBelow swarm = Swarm; } - public void Update(GameTime gameTime) + public override 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); - } - } - } + for (int index = 0; index < entityManager.Entities.Count; index++) + { + var entity = entityManager.Entities[index]; + 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; + swarm.Add(enemy); + this.Remove(); + break; + } + } + } } } } diff --git a/DepthsBelow/DepthsBelowContent/maps/Cave.Level1.tmx b/DepthsBelow/DepthsBelowContent/maps/Cave.Level1.tmx index 09c705c..6edaf63 100755 --- a/DepthsBelow/DepthsBelowContent/maps/Cave.Level1.tmx +++ b/DepthsBelow/DepthsBelowContent/maps/Cave.Level1.tmx @@ -15,7 +15,7 @@ 81,37,7,8,21,21,133,134,135,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,7,8,7,7,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,7,8,21,21,21,21,21,21,7,8,8,7,8,21,21,21,21,21,21,21,133,134,135,87,81, 81,37,7,8,21,21,21,21,21,21,21,21,21,18,18,18,18,18,18,18,18,2,2,2,18,5,8,8,89,7,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,18,18,19,20,4,4,4,4,4,4,2,7,8,8,8,8,8,8,8,8,8,7,7,8,8,24,7,8,3,4,4,20,4,18,18,133,134,135,87,81, 81,37,7,8,19,20,20,1,1,1,1,1,21,21,1,18,19,20,20,20,20,18,18,18,5,5,7,8,89,89,5,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,18,18,18,18,18,18,19,20,20,20,20,20,20,3,4,7,8,24,24,24,24,24,24,24,24,8,8,8,24,19,7,7,8,4,20,3,2,2,18,133,134,135,49,81, -81,37,7,8,7,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,7,8,8,89,89,5,4,20,4,17,17,17,17,17,17,17,1,1,1,1,1,17,17,17,1,2,3,5,5,5,5,5,6,2,3,4,7,8,8,2,3,2,18,2,2,2,23,24,2,2,2,3,18,19,23,24,24,24,24,20,18,23,7,8,4,4,4,2,18,19,2,3,2,39,81, +81,37,7,8,7,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,29,1,1,5,7,8,8,89,89,5,4,20,4,17,17,17,17,17,17,17,1,1,1,1,1,17,17,17,1,2,3,5,5,5,5,5,6,2,3,4,7,8,8,2,3,2,18,2,2,2,23,24,2,2,2,3,18,19,23,24,24,24,24,20,18,23,7,8,4,4,4,2,18,19,2,3,2,39,81, 81,37,7,8,23,24,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,17,17,5,7,8,24,89,89,21,3,4,20,4,4,4,4,5,6,22,17,17,17,17,17,17,18,1,2,3,4,5,5,5,21,5,5,2,7,7,8,8,24,2,2,18,19,18,18,18,18,18,2,2,2,2,2,18,19,20,3,4,20,20,20,19,7,8,4,2,2,2,18,19,2,2,18,39,81, 81,37,7,8,24,24,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,7,8,8,89,89,89,7,7,7,7,7,7,7,7,7,6,6,6,1,2,3,4,5,6,5,7,7,7,21,21,5,7,7,7,7,7,8,7,7,7,7,8,5,20,2,3,4,2,2,18,18,18,18,2,18,19,20,3,4,20,20,18,19,7,7,8,18,18,18,18,19,2,18,19,39,81, 81,37,23,24,23,24,1,1,1,7,7,7,7,7,7,8,7,7,7,8,1,1,1,5,7,8,24,89,89,89,23,7,23,23,23,23,23,23,7,4,22,22,4,5,6,6,6,6,6,23,23,23,24,8,21,23,23,23,7,7,7,23,23,23,23,7,7,8,4,2,2,2,18,19,20,20,20,18,19,20,3,4,20,20,4,2,19,23,7,8,2,3,4,4,2,2,18,19,39,81, @@ -220,5 +220,6 @@ +