MonsterSpawn added, reacts to a distance...
Have not tested, I think I failed, I don't think I should transfer around lists like that... But I didn't make the things static at least..!
This commit is contained in:
@@ -35,7 +35,10 @@ namespace DepthsBelow
|
||||
public List<Soldier> Squad;
|
||||
public DynamicGroupManager GroupManager;
|
||||
public List<SmallEnemy> Swarm;
|
||||
public List<Shot> Volley;
|
||||
public List<Shot> Volley;
|
||||
|
||||
public List<MonsterSpawn> Spawn;
|
||||
|
||||
public static Map Map;
|
||||
|
||||
public SmallEnemy TestMonster;
|
||||
@@ -78,6 +81,8 @@ namespace DepthsBelow
|
||||
Swarm = new List<SmallEnemy>();
|
||||
Volley = new List<Shot>();
|
||||
|
||||
Spawn = new List<MonsterSpawn>();
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Camera.cs" />
|
||||
<Compile Include="DynamicGroupManager.cs" />
|
||||
<Compile Include="MonsterSpawn.cs" />
|
||||
<Compile Include="TurnManager.cs" />
|
||||
<Compile Include="CustomExtensions.cs" />
|
||||
<Compile Include="EntityManager.cs" />
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace DepthsBelow
|
||||
/// </summary>
|
||||
public Component.Transform Transform;
|
||||
|
||||
private EntityManager entityManager;
|
||||
protected EntityManager entityManager;
|
||||
|
||||
/// <summary>
|
||||
/// Shorthand to the grid transform position.
|
||||
|
||||
@@ -14,6 +14,11 @@ namespace DepthsBelow
|
||||
{
|
||||
private List<Entity> entities;
|
||||
|
||||
public List<Entity> Entities
|
||||
{
|
||||
get { return entities; }
|
||||
}
|
||||
|
||||
public EntityManager()
|
||||
{
|
||||
entities = new List<Entity>();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SmallEnemy> swarm;
|
||||
|
||||
public MonsterSpawn(EntityManager entityManager, ref List<SmallEnemy> 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<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user