HitChance displayed, Stats Rearranged
This commit is contained in:
@@ -33,7 +33,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
@@ -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,172 +1,172 @@
|
|||||||
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 int step
|
||||||
{
|
{
|
||||||
get { return currentStep; }
|
get { return currentStep; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
currentStep = value;
|
currentStep = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SmallEnemy(EntityManager entityManager, ref List<SmallEnemy> swarm)
|
public SmallEnemy(EntityManager entityManager, ref List<SmallEnemy> swarm)
|
||||||
: base(entityManager)
|
: base(entityManager)
|
||||||
{
|
{
|
||||||
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);
|
||||||
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 (Utility.AttackTest(this.GetComponent<Component.Stat>(), entity, Utility.CalculateHitChance(this.GetComponent<Component.Stat>(), this.Transform.World.Position, entity)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user