Monster test spawn added to map

This commit is contained in:
Simon Holmberg
2012-10-22 02:30:07 +02:00
parent 35bcd8d9cc
commit 5f44eb257b
2 changed files with 25 additions and 19 deletions
+23 -18
View File
@@ -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<SmallEnemy> 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<Component.Transform>().Grid.Position.X, this.GetComponent<Component.Transform>().Grid.Position.Y);
Vector2 distance2 = new Vector2(entity.GetComponent<Component.Transform>().Grid.Position.X, entity.GetComponent<Component.Transform>().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<Component.Transform>().Grid.Position.X,
this.GetComponent<Component.Transform>().Grid.Position.Y);
Vector2 distance2 = new Vector2(entity.GetComponent<Component.Transform>().Grid.Position.X,
entity.GetComponent<Component.Transform>().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;
}
}
}
}
}
}
@@ -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 @@
<object name="Spawn4" type="SquadStart" gid="143" x="224" y="160"/>
<object name="Spawn3" type="SquadStart" gid="143" x="256" y="288"/>
<object name="Spawn5" type="SquadStart" gid="143" x="224" y="224"/>
<object name="Spawn1" type="MonsterSpawn" gid="29" x="672" y="256"/>
</objectgroup>
</map>