Shooting calculation displayed, needs work
This commit is contained in:
@@ -23,7 +23,7 @@ namespace DepthsBelow.Component
|
||||
public int GetAim
|
||||
{
|
||||
get { return soldierAim + weaponAccuracy; }
|
||||
set { soldierAim = value; }
|
||||
set { weaponAccuracy = value; }
|
||||
}
|
||||
|
||||
public int GetDodge
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace DepthsBelow
|
||||
{
|
||||
if (soldier.Selected == true && soldier.Fired == false)
|
||||
{
|
||||
core.Volley.Add(new Shot(core.EntityManager));
|
||||
core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent<Component.Stat>()));
|
||||
soldier.Fired = true;
|
||||
foreach (var shot in core.Volley)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ namespace DepthsBelow
|
||||
current = 0;
|
||||
if (soldier.Selected == true && soldier.Fired == false && hit == true)
|
||||
{
|
||||
core.Volley.Add(new Shot(core.EntityManager));
|
||||
core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent<Component.Stat>()));
|
||||
soldier.Fired = true;
|
||||
foreach (var shot in core.Volley)
|
||||
{
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace DepthsBelow
|
||||
readjust = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Calculating chance to hit if holding cursor over enemy
|
||||
foreach (var unit in core.Squad)
|
||||
{
|
||||
@@ -127,12 +128,12 @@ namespace DepthsBelow
|
||||
{
|
||||
if (gridRectangle.Intersects(enemy.GetComponent<Component.Collision>().Rectangle))
|
||||
{
|
||||
Utility.CalculateHitChance(unit, enemy);
|
||||
}
|
||||
Console.WriteLine(Utility.CalculateHitChance(unit, enemy));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the mouse is released
|
||||
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,14 @@ namespace DepthsBelow
|
||||
public Color Color;
|
||||
public static Point Origin;
|
||||
|
||||
Stat soldierStat;
|
||||
|
||||
public Stat Stat
|
||||
{
|
||||
get { return soldierStat; }
|
||||
set { soldierStat = value; }
|
||||
}
|
||||
|
||||
private bool _selected = false; //I guess as in "currently doing something"
|
||||
|
||||
public bool select
|
||||
@@ -29,7 +37,7 @@ namespace DepthsBelow
|
||||
|
||||
public Vector2 direction = Vector2.Zero;
|
||||
|
||||
public Shot(EntityManager entityManager)
|
||||
public Shot(EntityManager entityManager, Stat _soldierStat)
|
||||
: base(entityManager)
|
||||
{
|
||||
if (Texture == null)
|
||||
@@ -37,6 +45,8 @@ namespace DepthsBelow
|
||||
|
||||
Transform.World.Origin = new Vector2(16, 16);
|
||||
|
||||
Stat = _soldierStat;
|
||||
|
||||
this.Color = Color.White;
|
||||
var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
|
||||
AddComponent(rc);
|
||||
|
||||
@@ -29,7 +29,9 @@ namespace DepthsBelow
|
||||
}
|
||||
int baseHitChance = shooting.GetAim;
|
||||
int baseDodgeChance = dodging.GetDodge;
|
||||
int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent<Transform>().World.Position, defender.GetComponent<Transform>().World.Position) / Grid.TileSize);
|
||||
int distance = (int)Vector2.Distance(attacker.GetComponent<Transform>().World.Position, defender.GetComponent<Transform>().World.Position);
|
||||
int basePenalty = shooting.Penalty(distance / (Grid.TileSize / 2));
|
||||
Console.WriteLine("Penalty = " + basePenalty);
|
||||
int chanceToHit = baseHitChance - baseDodgeChance - basePenalty;
|
||||
//Console.WriteLine(chanceToHit);
|
||||
return chanceToHit;
|
||||
|
||||
Reference in New Issue
Block a user