Merge branch 'master' of github.com:sippeangelo/DepthsBelow
Conflicts: DepthsBelow/DepthsBelow/KeyboardInput.cs DepthsBelow/DepthsBelow/SmallEnemy.cs
This commit is contained in:
@@ -32,7 +32,7 @@ namespace DepthsBelow
|
|||||||
public Camera Camera;
|
public Camera Camera;
|
||||||
public Interface Interface;
|
public Interface Interface;
|
||||||
|
|
||||||
public static MouseInput MouseInput;
|
public/* static*/ MouseInput MouseInput;
|
||||||
public static KeyboardInput KeyboardInput;
|
public static KeyboardInput KeyboardInput;
|
||||||
public List<Soldier> Squad;
|
public List<Soldier> Squad;
|
||||||
public DynamicGroupManager GroupManager;
|
public DynamicGroupManager GroupManager;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,327 +1,328 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using Microsoft.Xna.Framework.Media;
|
using Microsoft.Xna.Framework.Media;
|
||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
public class KeyboardInput
|
public class KeyboardInput
|
||||||
{
|
{
|
||||||
Core core;
|
Core core;
|
||||||
private KeyboardState lastKeyboardState;
|
private KeyboardState lastKeyboardState;
|
||||||
|
|
||||||
int checkerSpeed = 2;
|
int checkerSpeed = 2;
|
||||||
|
|
||||||
int bulletCost = 5;
|
int bulletCost = 5;
|
||||||
int rocketCost = 10;
|
int rocketCost = 10;
|
||||||
|
|
||||||
public KeyboardInput(Core core)
|
public KeyboardInput(Core core)
|
||||||
{
|
{
|
||||||
this.core = core;
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public List<List<Soldier>> GetGroups(List<Soldier> soldiers)
|
/*public List<List<Soldier>> GetGroups(List<Soldier> soldiers)
|
||||||
{
|
{
|
||||||
var ungrouped = soldiers.ToList();
|
var ungrouped = soldiers.ToList();
|
||||||
var groups = new List<List<Soldier>>();
|
var groups = new List<List<Soldier>>();
|
||||||
|
|
||||||
for (int index = 0; index < soldiers.Count; index++)
|
for (int index = 0; index < soldiers.Count; index++)
|
||||||
{
|
{
|
||||||
var checkingSoldier = soldiers[index];
|
var checkingSoldier = soldiers[index];
|
||||||
var group = new List<Soldier>();
|
var group = new List<Soldier>();
|
||||||
|
|
||||||
for (int i = 0; i < soldiers.Count; i++)
|
for (int i = 0; i < soldiers.Count; i++)
|
||||||
{
|
{
|
||||||
var soldier = soldiers[i];
|
var soldier = soldiers[i];
|
||||||
if (ungrouped.Contains(soldier))
|
if (ungrouped.Contains(soldier))
|
||||||
{
|
{
|
||||||
float distance = Vector2.Distance(checkingSoldier.Transform.World + checkingSoldier.Transform.World.Origin,
|
float distance = Vector2.Distance(checkingSoldier.Transform.World + checkingSoldier.Transform.World.Origin,
|
||||||
soldier.Transform.World + soldier.Transform.World.Origin);
|
soldier.Transform.World + soldier.Transform.World.Origin);
|
||||||
if (distance <= ((float) Grid.TileSize * 1f))
|
if (distance <= ((float) Grid.TileSize * 1f))
|
||||||
{
|
{
|
||||||
ungrouped.Remove(soldier);
|
ungrouped.Remove(soldier);
|
||||||
group.Add(soldier);
|
group.Add(soldier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group.Count > 0)
|
if (group.Count > 0)
|
||||||
groups.Add(group);
|
groups.Add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Get a list of dynamic soldier groups
|
// Get a list of dynamic soldier groups
|
||||||
public List<List<Soldier>> GetGroups(List<Soldier> soldiers, float maxRange)
|
public List<List<Soldier>> GetGroups(List<Soldier> soldiers, float maxRange)
|
||||||
{
|
{
|
||||||
var alreadyGrouped = new List<Soldier>();
|
var alreadyGrouped = new List<Soldier>();
|
||||||
var groups = new List<List<Soldier>>();
|
var groups = new List<List<Soldier>>();
|
||||||
|
|
||||||
for (int index = 0; index < soldiers.Count; index++)
|
for (int index = 0; index < soldiers.Count; index++)
|
||||||
{
|
{
|
||||||
var soldier = soldiers[index];
|
var soldier = soldiers[index];
|
||||||
|
|
||||||
if (!alreadyGrouped.Contains(soldier))
|
if (!alreadyGrouped.Contains(soldier))
|
||||||
{
|
{
|
||||||
var group = new List<Soldier>();
|
var group = new List<Soldier>();
|
||||||
GetNearChain(ref group, soldiers, soldier, maxRange);
|
GetNearChain(ref group, soldiers, soldier, maxRange);
|
||||||
alreadyGrouped.AddRange(group);
|
alreadyGrouped.AddRange(group);
|
||||||
|
|
||||||
if (group.Count > 0)
|
if (group.Count > 0)
|
||||||
groups.Add(group);
|
groups.Add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all soldiers who are close to each other in a chain
|
// Get all soldiers who are close to each other in a chain
|
||||||
public void GetNearChain(ref List<Soldier> group, List<Soldier> soldiers, Soldier soldier, float maxRange)
|
public void GetNearChain(ref List<Soldier> group, List<Soldier> soldiers, Soldier soldier, float maxRange)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < soldiers.Count; index++)
|
for (int index = 0; index < soldiers.Count; index++)
|
||||||
{
|
{
|
||||||
var nearSoldier = soldiers[index];
|
var nearSoldier = soldiers[index];
|
||||||
|
|
||||||
if (!group.Contains(nearSoldier))
|
if (!group.Contains(nearSoldier))
|
||||||
{
|
{
|
||||||
float distance = Vector2.Distance(nearSoldier.Transform.World + nearSoldier.Transform.World.Origin,
|
float distance = Vector2.Distance(nearSoldier.Transform.World + nearSoldier.Transform.World.Origin,
|
||||||
soldier.Transform.World + soldier.Transform.World.Origin);
|
soldier.Transform.World + soldier.Transform.World.Origin);
|
||||||
if (distance <= maxRange)
|
if (distance <= maxRange)
|
||||||
{
|
{
|
||||||
group.Add(nearSoldier);
|
group.Add(nearSoldier);
|
||||||
GetNearChain(ref group, soldiers, nearSoldier, maxRange);
|
GetNearChain(ref group, soldiers, nearSoldier, maxRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamicGroupManager groupManager;
|
private DynamicGroupManager groupManager;
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
KeyboardState ks = Keyboard.GetState();
|
KeyboardState ks = Keyboard.GetState();
|
||||||
|
|
||||||
// Brightness
|
// Brightness
|
||||||
if (ks.IsKeyUp(Keys.Up) && lastKeyboardState.IsKeyDown(Keys.Up))
|
if (ks.IsKeyUp(Keys.Up) && lastKeyboardState.IsKeyDown(Keys.Up))
|
||||||
core.Brightness = (int)MathHelper.Clamp(core.Brightness + 5, 0, 254);
|
core.Brightness = (int)MathHelper.Clamp(core.Brightness + 5, 0, 254);
|
||||||
if (ks.IsKeyUp(Keys.Down) && lastKeyboardState.IsKeyDown(Keys.Down))
|
if (ks.IsKeyUp(Keys.Down) && lastKeyboardState.IsKeyDown(Keys.Down))
|
||||||
core.Brightness = (int)MathHelper.Clamp(core.Brightness - 5, 0, 254);
|
core.Brightness = (int)MathHelper.Clamp(core.Brightness - 5, 0, 254);
|
||||||
|
|
||||||
// Debug test: grouping
|
// Debug test: grouping
|
||||||
if (ks.IsKeyUp(Keys.K) && lastKeyboardState.IsKeyDown(Keys.K))
|
if (ks.IsKeyUp(Keys.K) && lastKeyboardState.IsKeyDown(Keys.K))
|
||||||
{
|
{
|
||||||
if (groupManager == null)
|
if (groupManager == null)
|
||||||
groupManager = new DynamicGroupManager(core.Squad.Cast<Entity>().ToList(), Grid.TileSize * 1.5f);
|
groupManager = new DynamicGroupManager(core.Squad.Cast<Entity>().ToList(), Grid.TileSize * 1.5f);
|
||||||
groupManager.UpdateGroups();
|
groupManager.UpdateGroups();
|
||||||
//var groups = GetGroups(core.Squad, (float)Grid.TileSize * 1.5f);
|
//var groups = GetGroups(core.Squad, (float)Grid.TileSize * 1.5f);
|
||||||
var groups = groupManager.Groups;
|
var groups = groupManager.Groups;
|
||||||
foreach (var group in groups)
|
foreach (var group in groups)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Group #" + groups.IndexOf(group) + " Panic: " + group.Panic);
|
Debug.WriteLine("Group #" + groups.IndexOf(group) + " Panic: " + group.Panic);
|
||||||
foreach (var entity in group.Entities)
|
foreach (var entity in group.Entities)
|
||||||
{
|
{
|
||||||
var soldier = (Soldier)entity;
|
var soldier = (Soldier)entity;
|
||||||
Debug.WriteLine(soldier.Name + " " + soldier.GetHashCode());
|
Debug.WriteLine(soldier.Name + " " + soldier.GetHashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next turn
|
// Next turn
|
||||||
if (ks.IsKeyDown(Keys.Enter) && lastKeyboardState.IsKeyUp(Keys.Enter))
|
if (ks.IsKeyDown(Keys.Enter) && lastKeyboardState.IsKeyUp(Keys.Enter))
|
||||||
{
|
{
|
||||||
if (core.TurnManager.CurrentTurn == core.TurnManager["Player"])
|
if (core.TurnManager.CurrentTurn == core.TurnManager["Player"])
|
||||||
{
|
{
|
||||||
foreach (var unit in core.Squad)
|
foreach (var unit in core.Squad)
|
||||||
{
|
{
|
||||||
unit.AP = unit.MaxActionPoints;
|
unit.AP = unit.MaxActionPoints;
|
||||||
unit.Fired = false;
|
unit.Fired = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.TurnManager.EndTurn();
|
core.TurnManager.EndTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.TurnManager.CurrentTurn == core.TurnManager["Computer"])
|
if (core.TurnManager.CurrentTurn == core.TurnManager["Computer"])
|
||||||
{
|
{
|
||||||
foreach (var enemy in core.Swarm)
|
foreach (var enemy in core.Swarm)
|
||||||
{
|
{
|
||||||
enemy.step = 0;
|
enemy.step = 0;
|
||||||
Point target = Point.Zero;
|
enemy.AttackedThisTurn = false;
|
||||||
float distance = 7000;
|
Point target = Point.Zero;
|
||||||
foreach (var unit in core.Squad)
|
float distance = 7000;
|
||||||
{
|
foreach (var unit in core.Squad)
|
||||||
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
|
{
|
||||||
Vector2 monster = new Vector2(enemy.Transform.Grid.X, enemy.Transform.Grid.Y);
|
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
|
||||||
|
Vector2 monster = new Vector2(enemy.Transform.Grid.X, enemy.Transform.Grid.Y);
|
||||||
float newDistance = Vector2.Distance(soldier, monster);
|
|
||||||
|
float newDistance = Vector2.Distance(soldier, monster);
|
||||||
if (newDistance < distance)
|
|
||||||
{
|
if (newDistance < distance)
|
||||||
target = unit.Transform.Grid;
|
{
|
||||||
distance = newDistance;
|
target = unit.Transform.Grid;
|
||||||
}
|
distance = newDistance;
|
||||||
}
|
}
|
||||||
enemy.GetComponent<Component.PathFinder>().Goal = target;
|
}
|
||||||
distance = 7000;
|
enemy.GetComponent<Component.PathFinder>().Goal = target;
|
||||||
|
distance = 7000;
|
||||||
}
|
|
||||||
|
}
|
||||||
core.TestMonster.step = 0;
|
|
||||||
Point testTarget = Point.Zero;
|
core.TestMonster.step = 0;
|
||||||
float testDistance = 7000;
|
Point testTarget = Point.Zero;
|
||||||
foreach (var unit in core.Squad)
|
float testDistance = 7000;
|
||||||
{
|
foreach (var unit in core.Squad)
|
||||||
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
|
{
|
||||||
Vector2 monster = new Vector2(core.TestMonster.Transform.Grid.X, core.TestMonster.Transform.Grid.Y);
|
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
|
||||||
|
Vector2 monster = new Vector2(core.TestMonster.Transform.Grid.X, core.TestMonster.Transform.Grid.Y);
|
||||||
float newDistance = Vector2.Distance(soldier, monster);
|
|
||||||
|
float newDistance = Vector2.Distance(soldier, monster);
|
||||||
if (newDistance < testDistance)
|
|
||||||
{
|
if (newDistance < testDistance)
|
||||||
testTarget = unit.Transform.Grid;
|
{
|
||||||
testDistance = newDistance;
|
testTarget = unit.Transform.Grid;
|
||||||
}
|
testDistance = newDistance;
|
||||||
}
|
}
|
||||||
core.TestMonster.GetComponent<Component.PathFinder>().Goal = testTarget;
|
}
|
||||||
testDistance = 7000;
|
core.TestMonster.GetComponent<Component.PathFinder>().Goal = testTarget;
|
||||||
|
testDistance = 7000;
|
||||||
core.TurnManager.EndTurn();
|
|
||||||
}
|
core.TurnManager.EndTurn();
|
||||||
}
|
}
|
||||||
if (ks.IsKeyDown(Keys.A))
|
|
||||||
{
|
|
||||||
/*foreach (var unit in core.Swarm)
|
|
||||||
{
|
|
||||||
unit.X = 200;
|
|
||||||
unit.Y = 200;
|
|
||||||
}*/
|
|
||||||
core.TestMonster.X = 12;
|
|
||||||
core.TestMonster.Y = 4;
|
|
||||||
}
|
}
|
||||||
if (ks.IsKeyUp(Keys.O) && lastKeyboardState.IsKeyDown(Keys.O))
|
if (ks.IsKeyDown(Keys.A))
|
||||||
{
|
{
|
||||||
EntityManager.GetEntities<Door>()[0].Toggle();
|
/*foreach (var unit in core.Swarm)
|
||||||
}
|
{
|
||||||
if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.R))
|
unit.X = 200;
|
||||||
{
|
unit.Y = 200;
|
||||||
foreach (var soldier in core.Squad)
|
}*/
|
||||||
{
|
core.TestMonster.X = 12;
|
||||||
if (soldier.Selected == true && soldier.Fired == false)
|
core.TestMonster.Y = 4;
|
||||||
{
|
}
|
||||||
bool enoughActionPoints = true;
|
if (ks.IsKeyUp(Keys.O) && lastKeyboardState.IsKeyDown(Keys.O))
|
||||||
int cost = 0;
|
{
|
||||||
string type = "";
|
EntityManager.GetEntities<Door>()[0].Toggle();
|
||||||
if (ks.IsKeyDown(Keys.S))
|
}
|
||||||
{
|
if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.R))
|
||||||
cost = bulletCost;
|
{
|
||||||
type = "bullet";
|
foreach (var soldier in core.Squad)
|
||||||
}
|
{
|
||||||
else if (ks.IsKeyDown(Keys.R))
|
if (soldier.Selected == true && soldier.Fired == false)
|
||||||
{
|
{
|
||||||
cost = rocketCost;
|
bool enoughActionPoints = true;
|
||||||
type = "Rocket";
|
int cost = 0;
|
||||||
}
|
string type = "";
|
||||||
if (soldier.AP >= cost)
|
if (ks.IsKeyDown(Keys.S))
|
||||||
{
|
{
|
||||||
core.Volley.Add(new Shot(soldier.GetComponent<Component.Stat>(), type));
|
cost = bulletCost;
|
||||||
soldier.AP -= cost;
|
type = "bullet";
|
||||||
soldier.Fired = true;
|
}
|
||||||
}
|
else if (ks.IsKeyDown(Keys.R))
|
||||||
else
|
{
|
||||||
{
|
cost = rocketCost;
|
||||||
enoughActionPoints = false;
|
type = "Rocket";
|
||||||
}
|
}
|
||||||
if (enoughActionPoints == true)
|
if (soldier.AP >= cost)
|
||||||
{
|
{
|
||||||
foreach (var shot in core.Volley)
|
core.Volley.Add(new Shot(soldier.GetComponent<Component.Stat>(), type));
|
||||||
{
|
soldier.AP -= cost;
|
||||||
if (shot.select == false)
|
soldier.Fired = true;
|
||||||
{
|
}
|
||||||
shot.select = true;
|
else
|
||||||
shot.X = soldier.X;
|
{
|
||||||
shot.Y = soldier.Y;
|
enoughActionPoints = false;
|
||||||
//shot.Transform.World.X += Grid.TileSize / 2;
|
}
|
||||||
//shot.Transform.World.Y += Grid.TileSize / 2;
|
if (enoughActionPoints == true)
|
||||||
}
|
{
|
||||||
if (shot.direction == Vector2.Zero)
|
foreach (var shot in core.Volley)
|
||||||
{
|
{
|
||||||
double directionX = Math.Cos(soldier.Transform.World.Rotation);
|
if (shot.select == false)
|
||||||
double directionY = Math.Sin(soldier.Transform.World.Rotation);
|
{
|
||||||
shot.direction = new Vector2((float)directionX, (float)directionY);
|
shot.select = true;
|
||||||
shot.Transform.World.Rotation = soldier.Transform.World.Rotation;
|
shot.X = soldier.X;
|
||||||
Vector2 yo = soldier.Transform.World.Position;
|
shot.Y = soldier.Y;
|
||||||
shot.Stat.Remember = yo;
|
//shot.Transform.World.X += Grid.TileSize / 2;
|
||||||
}
|
//shot.Transform.World.Y += Grid.TileSize / 2;
|
||||||
}
|
}
|
||||||
}
|
if (shot.direction == Vector2.Zero)
|
||||||
}
|
{
|
||||||
}
|
double directionX = Math.Cos(soldier.Transform.World.Rotation);
|
||||||
}
|
double directionY = Math.Sin(soldier.Transform.World.Rotation);
|
||||||
if (ks.IsKeyDown(Keys.C))
|
shot.direction = new Vector2((float)directionX, (float)directionY);
|
||||||
{
|
shot.Transform.World.Rotation = soldier.Transform.World.Rotation;
|
||||||
foreach (var soldier in core.Squad)
|
Vector2 yo = soldier.Transform.World.Position;
|
||||||
{
|
shot.Stat.Remember = yo;
|
||||||
if (soldier.Selected == true && soldier.Fired == false)
|
}
|
||||||
{
|
}
|
||||||
Point checker = Point.Zero;
|
}
|
||||||
double directionX = Math.Cos(soldier.GetComponent<Component.Transform>().World.Rotation);
|
}
|
||||||
double directionY = Math.Sin(soldier.GetComponent<Component.Transform>().World.Rotation);
|
}
|
||||||
Vector2 direction = new Vector2((int)directionX, (int)directionY);
|
}
|
||||||
int range = 120;
|
if (ks.IsKeyDown(Keys.C))
|
||||||
int current = 0;
|
{
|
||||||
bool hit = false;
|
foreach (var soldier in core.Squad)
|
||||||
checker = new Point((int)soldier.Transform.World.Origin.X, (int)soldier.Transform.World.Origin.Y);
|
{
|
||||||
do
|
if (soldier.Selected == true && soldier.Fired == false)
|
||||||
{
|
{
|
||||||
checker.X += (int)direction.X * checkerSpeed;
|
Point checker = Point.Zero;
|
||||||
checker.Y += (int)direction.Y * checkerSpeed;
|
double directionX = Math.Cos(soldier.GetComponent<Component.Transform>().World.Rotation);
|
||||||
foreach (var creature in core.Swarm)
|
double directionY = Math.Sin(soldier.GetComponent<Component.Transform>().World.Rotation);
|
||||||
{
|
Vector2 direction = new Vector2((int)directionX, (int)directionY);
|
||||||
if (creature.GetComponent<Component.Collision>().Rectangle.Contains(checker))
|
int range = 120;
|
||||||
{
|
int current = 0;
|
||||||
hit = true;
|
bool hit = false;
|
||||||
}
|
checker = new Point((int)soldier.Transform.World.Origin.X, (int)soldier.Transform.World.Origin.Y);
|
||||||
}
|
do
|
||||||
if (core.TestMonster.GetComponent<Component.Collision>().Rectangle.Contains(checker))
|
{
|
||||||
{
|
checker.X += (int)direction.X * checkerSpeed;
|
||||||
|
checker.Y += (int)direction.Y * checkerSpeed;
|
||||||
}
|
foreach (var creature in core.Swarm)
|
||||||
current++;
|
{
|
||||||
} while (hit == false && current < range);
|
if (creature.GetComponent<Component.Collision>().Rectangle.Contains(checker))
|
||||||
current = 0;
|
{
|
||||||
if (soldier.Selected == true && soldier.Fired == false && hit == true)
|
hit = true;
|
||||||
{
|
}
|
||||||
core.Volley.Add(new Shot(soldier.GetComponent<Component.Stat>(), "Bullet"));
|
}
|
||||||
soldier.Fired = true;
|
if (core.TestMonster.GetComponent<Component.Collision>().Rectangle.Contains(checker))
|
||||||
foreach (var shot in core.Volley)
|
{
|
||||||
{
|
|
||||||
if (shot.select == false)
|
}
|
||||||
{
|
current++;
|
||||||
shot.select = true;
|
} while (hit == false && current < range);
|
||||||
shot.X = soldier.X;
|
current = 0;
|
||||||
shot.Y = soldier.Y;
|
if (soldier.Selected == true && soldier.Fired == false && hit == true)
|
||||||
//shot.Transform.World.X += Grid.TileSize / 2;
|
{
|
||||||
//shot.Transform.World.Y += Grid.TileSize / 2;
|
core.Volley.Add(new Shot(soldier.GetComponent<Component.Stat>(), "Bullet"));
|
||||||
}
|
soldier.Fired = true;
|
||||||
if (shot.direction == Vector2.Zero)
|
foreach (var shot in core.Volley)
|
||||||
{
|
{
|
||||||
shot.direction = new Vector2((float)directionX, (float)directionY);
|
if (shot.select == false)
|
||||||
shot.Transform.World.Rotation = soldier.Transform.World.Rotation;
|
{
|
||||||
}
|
shot.select = true;
|
||||||
}
|
shot.X = soldier.X;
|
||||||
}
|
shot.Y = soldier.Y;
|
||||||
hit = false;
|
//shot.Transform.World.X += Grid.TileSize / 2;
|
||||||
}
|
//shot.Transform.World.Y += Grid.TileSize / 2;
|
||||||
}
|
}
|
||||||
}
|
if (shot.direction == Vector2.Zero)
|
||||||
|
{
|
||||||
lastKeyboardState = ks;
|
shot.direction = new Vector2((float)directionX, (float)directionY);
|
||||||
}
|
shot.Transform.World.Rotation = soldier.Transform.World.Rotation;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastKeyboardState = ks;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,8 @@ namespace DepthsBelow
|
|||||||
{
|
{
|
||||||
//EntityManager entityManager;
|
//EntityManager entityManager;
|
||||||
|
|
||||||
int wakingDistance = 6;
|
int wakingDistance = 7;
|
||||||
|
int sleepingDistance = 6;
|
||||||
|
|
||||||
List<SmallEnemy> swarm;
|
List<SmallEnemy> swarm;
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ namespace DepthsBelow
|
|||||||
this.GetComponent<Component.Transform>().Grid.Position.Y);
|
this.GetComponent<Component.Transform>().Grid.Position.Y);
|
||||||
Vector2 distance2 = new Vector2(entity.GetComponent<Component.Transform>().Grid.Position.X,
|
Vector2 distance2 = new Vector2(entity.GetComponent<Component.Transform>().Grid.Position.X,
|
||||||
entity.GetComponent<Component.Transform>().Grid.Position.Y);
|
entity.GetComponent<Component.Transform>().Grid.Position.Y);
|
||||||
if (Vector2.Distance(distance1, distance2) < wakingDistance)
|
if (Vector2.Distance(distance1, distance2) < wakingDistance/* && Vector2.Distance(distance1, distance2) > sleepingDistance*/)
|
||||||
{
|
{
|
||||||
var enemy = new SmallEnemy(ref swarm);
|
var enemy = new SmallEnemy(ref swarm);
|
||||||
enemy.X = this.X;
|
enemy.X = this.X;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace DepthsBelow
|
|||||||
MouseState lastMouseState;
|
MouseState lastMouseState;
|
||||||
Rectangle selectionRectangle;
|
Rectangle selectionRectangle;
|
||||||
Texture2D selectionTexture;
|
Texture2D selectionTexture;
|
||||||
Rectangle gridRectangle;
|
public Rectangle gridRectangle;
|
||||||
Texture2D gridTexture;
|
Texture2D gridTexture;
|
||||||
|
|
||||||
Vector2 directionStart;
|
Vector2 directionStart;
|
||||||
|
|||||||
@@ -1,173 +1,179 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using DepthsBelow.Component;
|
using DepthsBelow.Component;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
public class SmallEnemy : Entity
|
public class SmallEnemy : Entity
|
||||||
{
|
{
|
||||||
public static Texture2D Texture;
|
public static Texture2D Texture;
|
||||||
public Color Color;
|
public Color Color;
|
||||||
public static Point Origin;
|
public static Point Origin;
|
||||||
private bool _selected; //I guess as in "currently doing something"
|
private bool _selected; //I guess as in "currently doing something"
|
||||||
|
|
||||||
public List<SmallEnemy> Swarm;
|
public List<SmallEnemy> Swarm;
|
||||||
|
|
||||||
private PathFinder.Node nextNode;
|
private PathFinder.Node nextNode;
|
||||||
|
|
||||||
public int numberOfSteps = 5;
|
public int numberOfSteps = 5;
|
||||||
public int currentStep = 0;
|
public int currentStep = 0;
|
||||||
|
|
||||||
public int step
|
public bool AttackedThisTurn = false;
|
||||||
{
|
|
||||||
get { return currentStep; }
|
public int step
|
||||||
set
|
{
|
||||||
{
|
get { return currentStep; }
|
||||||
currentStep = value;
|
set
|
||||||
}
|
{
|
||||||
}
|
currentStep = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SmallEnemy(ref List<SmallEnemy> swarm)
|
public SmallEnemy(ref List<SmallEnemy> swarm)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
if (Texture == null)
|
if (Texture == null)
|
||||||
LoadContent();
|
LoadContent();
|
||||||
|
|
||||||
this.Swarm = swarm;
|
this.Swarm = swarm;
|
||||||
|
|
||||||
Transform.World.Origin = new Vector2(20, 16);
|
Transform.World.Origin = new Vector2(20, 16);
|
||||||
|
|
||||||
this.Color = Color.White;
|
this.Color = Color.White;
|
||||||
var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
|
var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
|
||||||
AddComponent(rc);
|
AddComponent(rc);
|
||||||
|
|
||||||
var cc = new Collision(this, 32, 32);
|
var cc = new Collision(this, 32, 32);
|
||||||
cc.Solid = true;
|
cc.Solid = true;
|
||||||
AddComponent(cc);
|
AddComponent(cc);
|
||||||
|
|
||||||
var pfc = new PathFinder(this);
|
var pfc = new PathFinder(this);
|
||||||
AddComponent(pfc);
|
AddComponent(pfc);
|
||||||
|
|
||||||
var stat = new Component.Stat(this)
|
var stat = new Component.Stat(this)
|
||||||
{
|
{
|
||||||
Life = 2,
|
Life = 50,
|
||||||
Defence = 2,
|
Defence = 25,
|
||||||
Strength = 5000,
|
Strength = 26,
|
||||||
GetAim = 100,
|
GetAim = 100,
|
||||||
GetDodge = 50
|
GetDodge = 50
|
||||||
};
|
};
|
||||||
AddComponent(stat);
|
AddComponent(stat);
|
||||||
}
|
}
|
||||||
public override void Remove()
|
public override void Remove()
|
||||||
{
|
{
|
||||||
Swarm.Remove(this);
|
Swarm.Remove(this);
|
||||||
|
|
||||||
base.Remove();
|
base.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Selected
|
public bool Selected
|
||||||
{
|
{
|
||||||
get { return _selected; }
|
get { return _selected; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_selected = value;
|
_selected = value;
|
||||||
GetComponent<SpriteRenderer>().Color = (value) ? Color.Blue : this.Color;
|
GetComponent<SpriteRenderer>().Color = (value) ? Color.Blue : this.Color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadContent()
|
public static void LoadContent()
|
||||||
{
|
{
|
||||||
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Monster");
|
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Monster");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
|
||||||
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
|
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
|
||||||
|
|
||||||
if (nextNode == null)
|
if (nextNode == null)
|
||||||
nextNode = GetComponent<PathFinder>().Next();
|
nextNode = GetComponent<PathFinder>().Next();
|
||||||
|
|
||||||
if (nextNode != null)
|
if (nextNode != null)
|
||||||
{
|
{
|
||||||
List<Point> soldierCollisions = new List<Point>();
|
List<Point> soldierCollisions = new List<Point>();
|
||||||
|
|
||||||
// Collision with moving units
|
// Collision with moving units
|
||||||
foreach (var body in Swarm)
|
foreach (var body in Swarm)
|
||||||
{
|
{
|
||||||
if (body != this)
|
if (body != this)
|
||||||
{
|
{
|
||||||
if (body.Transform.Grid == nextNode.Position)
|
if (body.Transform.Grid == nextNode.Position)
|
||||||
{
|
{
|
||||||
soldierCollisions.Add(body.Transform.Grid);
|
soldierCollisions.Add(body.Transform.Grid);
|
||||||
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
|
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
|
||||||
nextNode = GetComponent<PathFinder>().Next();
|
nextNode = GetComponent<PathFinder>().Next();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextNode != null)
|
if (nextNode != null)
|
||||||
{
|
{
|
||||||
var nodeWorldPos = Grid.GridToWorld(nextNode.Position);
|
var nodeWorldPos = Grid.GridToWorld(nextNode.Position);
|
||||||
// HACK: Make this work properly with other speeds...
|
// HACK: Make this work properly with other speeds...
|
||||||
float speed = 4f;
|
float speed = 4f;
|
||||||
if (Transform.World.X < nodeWorldPos.X)
|
if (Transform.World.X < nodeWorldPos.X)
|
||||||
{
|
{
|
||||||
Transform.World.X += speed;
|
Transform.World.X += speed;
|
||||||
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(0);
|
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(0);
|
||||||
}
|
}
|
||||||
if (Transform.World.X > nodeWorldPos.X)
|
if (Transform.World.X > nodeWorldPos.X)
|
||||||
{
|
{
|
||||||
Transform.World.X -= speed;
|
Transform.World.X -= speed;
|
||||||
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(180);
|
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(180);
|
||||||
}
|
}
|
||||||
if (Transform.World.Y < nodeWorldPos.Y)
|
if (Transform.World.Y < nodeWorldPos.Y)
|
||||||
{
|
{
|
||||||
Transform.World.Y += speed;
|
Transform.World.Y += speed;
|
||||||
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(90);
|
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(90);
|
||||||
}
|
}
|
||||||
if (Transform.World.Y > nodeWorldPos.Y)
|
if (Transform.World.Y > nodeWorldPos.Y)
|
||||||
{
|
{
|
||||||
Transform.World.Y -= speed;
|
Transform.World.Y -= speed;
|
||||||
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(270);
|
GetComponent<Component.Transform>().World.Rotation = MathHelper.ToRadians(270);
|
||||||
}
|
}
|
||||||
if (Transform.World == nodeWorldPos)
|
if (Transform.World == nodeWorldPos)
|
||||||
{
|
{
|
||||||
if (currentStep < numberOfSteps)
|
if (currentStep < numberOfSteps)
|
||||||
{
|
{
|
||||||
currentStep++;
|
currentStep++;
|
||||||
//lastLastNode = lastNode;
|
//lastLastNode = lastNode;
|
||||||
//lastNode = nextNode;
|
//lastNode = nextNode;
|
||||||
nextNode = GetComponent<PathFinder>().Next();
|
nextNode = GetComponent<PathFinder>().Next();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
GetComponent<PathFinder>().Stop();
|
GetComponent<PathFinder>().Stop();
|
||||||
}
|
}
|
||||||
foreach (var entity in EntityManager.Entities)
|
foreach (var entity in EntityManager.Entities)
|
||||||
{
|
{
|
||||||
if (entity is Soldier)
|
if (entity is Soldier)
|
||||||
{
|
{
|
||||||
if (entity.GetComponent<Component.Collision>().Rectangle.Intersects(this.GetComponent<Component.Collision>().Rectangle))
|
if (entity.GetComponent<Component.Collision>().Rectangle.Intersects(this.GetComponent<Component.Collision>().Rectangle))
|
||||||
{
|
{
|
||||||
if (Utility.AttackTest(this.GetComponent<Component.Stat>(), entity, Utility.CalculateHitChance(this.GetComponent<Component.Stat>(), this.Transform.World.Position, entity)))
|
if (AttackedThisTurn == false)
|
||||||
{
|
{
|
||||||
break;
|
if (Utility.AttackTest(this.GetComponent<Component.Stat>(), entity, Utility.CalculateHitChance(this.GetComponent<Component.Stat>(), this.Transform.World.Position, entity)))
|
||||||
}
|
{
|
||||||
}
|
AttackedThisTurn = true;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -78,8 +78,8 @@ namespace DepthsBelow
|
|||||||
{
|
{
|
||||||
MaxHP = 100,
|
MaxHP = 100,
|
||||||
MaxPanic = 100,
|
MaxPanic = 100,
|
||||||
//Life = 10,
|
Life = 100,
|
||||||
Defence = 10,
|
Defence = 25,
|
||||||
Strength = 50,
|
Strength = 50,
|
||||||
GetAim = 40,
|
GetAim = 40,
|
||||||
GetDodge = 20
|
GetDodge = 20
|
||||||
|
|||||||
@@ -1,38 +1,45 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.0" orientation="orthogonal" width="100" height="100" tilewidth="32" tileheight="32">
|
<map version="1.0" orientation="orthogonal" width="100" height="100" tilewidth="32" tileheight="32">
|
||||||
<tileset firstgid="1" name="Aztek" tilewidth="32" tileheight="32">
|
<tileset firstgid="1" name="Aztek" tilewidth="32" tileheight="32">
|
||||||
<image source="tilesets/aztek.png" width="480" height="693"/>
|
<image source="tilesets/aztek.png" width="480" height="693"/>
|
||||||
</tileset>
|
</tileset>
|
||||||
<tileset firstgid="316" name="Collision" tilewidth="32" tileheight="32">
|
<tileset firstgid="316" name="Collision" tilewidth="32" tileheight="32">
|
||||||
<image source="tilesets/collision.png" width="32" height="32"/>
|
<image source="tilesets/collision.png" width="32" height="32"/>
|
||||||
</tileset>
|
</tileset>
|
||||||
<layer name="Floor" width="100" height="100">
|
<layer name="Floor" width="100" height="100">
|
||||||
<data encoding="base64" compression="zlib">
|
<data encoding="base64" compression="zlib">
|
||||||
eJzt1sEJgEAMAMED++/ZCsTzYVxhBtJA9pGsBQAA0HVsDHP0aNjpoMccPZr0aNGjS4MWPVr0aHjya2n1Pj2a7nauxyw9WvRouerhjnxDjxY9WvRocc9b9GjRo0WPFj1a9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4M9ODsMCBQ==
|
eJzt1sEJgEAMAMED++/ZCsTzYVxhBtJA9pGsBQAA0HVsDHP0aNjpoMccPZr0aNGjS4MWPVr0aHjya2n1Pj2a7nauxyw9WvRouerhjnxDjxY9WvRocc9b9GjRo0WPFj1a9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4M9ODsMCBQ==
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<layer name="Tile Layer 1" width="100" height="100">
|
<layer name="Tile Layer 1" width="100" height="100">
|
||||||
<data encoding="base64" compression="zlib">
|
<data encoding="base64" compression="zlib">
|
||||||
eJzt2MlOwzAQBmA/Ajvc2OEGYr0BLcuN7f2fhqlUS1GqNCfHQfk+6ZeqxAdLk2TGTQkAAMg2IpuRrTXZjuzU2uDEHEaOIsdrchI5rbS/KVk8+w+Rx551N5Hb8tuZvMWz/x756FmnHsN4iexHDnrWqccwviMXkcuedeoxnKfIc1p9V3Yje8vrs8i8xuYm6DPylVbflbPI+fL6Ir9VdjdtV5Hr5W/fqHrymbA5+95F7pPzYQ35TNicfV8jb8n5sIbc07v6eU6+71tWVu7p6/p5s9+rxzD6+nm+rx7D6KpHu9/nXq+vl9VVj3a/z71eXy+rqx7N602+W2Wpx7h01aM9D+dZeJb8r1VSVz3a83CehX+S/7VKMu+Oi3qMi3qMi3qMi3oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPDf/QHD8yhT
|
eJzt2MlOwzAQBmA/Ajvc2OEGYr0BLcuN7f2fhqlUS1GqNCfHQfk+6ZeqxAdLk2TGTQkAAMg2IpuRrTXZjuzU2uDEHEaOIsdrchI5rbS/KVk8+w+Rx551N5Hb8tuZvMWz/x756FmnHsN4iexHDnrWqccwviMXkcuedeoxnKfIc1p9V3Yje8vrs8i8xuYm6DPylVbflbPI+fL6Ir9VdjdtV5Hr5W/fqHrymbA5+95F7pPzYQ35TNicfV8jb8n5sIbc07v6eU6+71tWVu7p6/p5s9+rxzD6+nm+rx7D6KpHu9/nXq+vl9VVj3a/z71eXy+rqx7N602+W2Wpx7h01aM9D+dZeJb8r1VSVz3a83CehX+S/7VKMu+Oi3qMi3qMi3qMi3oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPDf/QHD8yhT
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<layer name="Tile Layer 2" width="100" height="100">
|
<layer name="Tile Layer 2" width="100" height="100">
|
||||||
<data encoding="base64" compression="zlib">
|
<data encoding="base64" compression="zlib">
|
||||||
eJzt0bEJgEAQRNHrx6tAq/BswP6rcCODC0Qw2BXeg58PTGsAAADwbERH9ghu/qjFH7X4AwAAgLfWaMseAQB8skQ9ewQAv7JPkeucAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAai5YqQYl
|
eJzt0bEJgEAQRNHrx6tAq/BswP6rcCODC0Qw2BXeg58PTGsAAADwbERH9ghu/qjFH7X4AwAAgLfWaMseAQB8skQ9ewQAv7JPkeucAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAai5YqQYl
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup name="Object Layer 1" width="100" height="100" visible="0">
|
<objectgroup name="Object Layer 1" width="100" height="100" visible="0">
|
||||||
<object type="SquadStart" gid="4" x="352" y="352"/>
|
<object type="SquadStart" gid="4" x="352" y="352"/>
|
||||||
<object type="SquadStart" gid="4" x="416" y="352"/>
|
<object type="SquadStart" gid="4" x="416" y="352"/>
|
||||||
<object type="SquadStart" gid="4" x="352" y="384"/>
|
<object type="SquadStart" gid="4" x="352" y="384"/>
|
||||||
<object type="SquadStart" gid="4" x="384" y="384"/>
|
<object type="SquadStart" gid="4" x="384" y="384"/>
|
||||||
<object type="SquadStart" gid="4" x="384" y="352"/>
|
<object type="SquadStart" gid="4" x="384" y="352"/>
|
||||||
<object type="MonsterSpawn" gid="5" x="544" y="480"/>
|
<object type="MonsterSpawn" gid="5" x="544" y="480"/>
|
||||||
<object type="MonsterSpawn" gid="5" x="768" y="608"/>
|
<object type="MonsterSpawn" gid="5" x="768" y="608"/>
|
||||||
</objectgroup>
|
<object type="MonsterSpawn" gid="5" x="768" y="576"/>
|
||||||
<layer name="Collision" width="100" height="100">
|
<object type="MonsterSpawn" gid="5" x="672" y="288"/>
|
||||||
<data encoding="base64" compression="zlib">
|
<object type="MonsterSpawn" gid="5" x="704" y="832"/>
|
||||||
eJzt1rENAyEQAMF3X+6/LpdgeA5pgxnpUoJbCXgeAJj1/dwd9ujRokeLHi0ne9Rknh4tJ7vTY54eLe6rFj1advfpz3vX7R7s0aNlcpd6nLvdQ5M9E/fVv7NYp0eLHi0nPVbPZJ0eLXq06NFy+z1njx49erTo0aJHix49K+/6m+EdPVr06LFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoO4HZimKNQ==
|
<object type="MonsterSpawn" gid="5" x="864" y="832"/>
|
||||||
</data>
|
<object type="MonsterSpawn" gid="5" x="576" y="896"/>
|
||||||
</layer>
|
<object type="MonsterSpawn" gid="5" x="448" y="576"/>
|
||||||
</map>
|
<object type="MonsterSpawn" gid="5" x="560" y="670"/>
|
||||||
|
</objectgroup>
|
||||||
|
<layer name="Collision" width="100" height="100">
|
||||||
|
<data encoding="base64" compression="zlib">
|
||||||
|
eJzt1rENAyEQAMF3X+6/LpdgeA5pgxnpUoJbCXgeAJj1/dwd9ujRokeLHi0ne9Rknh4tJ7vTY54eLe6rFj1advfpz3vX7R7s0aNlcpd6nLvdQ5M9E/fVv7NYp0eLHi0nPVbPZJ0eLXq06NFy+z1njx49erTo0aJHix49K+/6m+EdPVr06LFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoO4HZimKNQ==
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
</map>
|
||||||
|
|||||||
Reference in New Issue
Block a user