Added Stats, damage code, stuff
This commit is contained in:
@@ -7,23 +7,56 @@ namespace DepthsBelow.Component
|
||||
{
|
||||
public class Stat : Component
|
||||
{
|
||||
protected int hp = 0;
|
||||
protected int defence = 0;
|
||||
protected int stepsTaken = 0;
|
||||
protected int distanceToTarget = 0;
|
||||
protected int panic = 0;
|
||||
protected int soldierAim = 0;
|
||||
protected int soldierAim = 100;
|
||||
protected int weaponAccuracy = 0;
|
||||
protected int weaponStrength = 0;
|
||||
protected int ammo = 0;
|
||||
protected int enemyDodge = 0;
|
||||
|
||||
protected int penaltyRange = 5;
|
||||
|
||||
public int GetAim()
|
||||
public int GetAim
|
||||
{
|
||||
return (soldierAim + weaponAccuracy);
|
||||
get { return soldierAim + weaponAccuracy; }
|
||||
set { soldierAim = value; }
|
||||
}
|
||||
|
||||
public int GetDodge()
|
||||
public int GetDodge
|
||||
{
|
||||
return enemyDodge;
|
||||
get { return enemyDodge; }
|
||||
set { enemyDodge = value; }
|
||||
}
|
||||
public int Life
|
||||
{
|
||||
get { return hp; }
|
||||
set
|
||||
{
|
||||
hp = value;
|
||||
if (hp <= 0) {
|
||||
//If you kill me, I will become stronger than you can ever imagine.
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Defence
|
||||
{
|
||||
get { return defence; }
|
||||
set { defence = value; }
|
||||
}
|
||||
public int Strength
|
||||
{
|
||||
get { return weaponStrength; }
|
||||
set { weaponStrength = value; }
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
hp = 0;
|
||||
}
|
||||
|
||||
public int Penalty(int distance)
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace DepthsBelow
|
||||
|
||||
var pfc = new PathFinder(this);
|
||||
AddComponent(pfc);
|
||||
|
||||
stat.Life = 2;
|
||||
stat.Defence = 0;
|
||||
stat.Strength = 5;
|
||||
stat.GetAim = 100;
|
||||
stat.GetDodge = 10;
|
||||
}
|
||||
|
||||
public bool Selected
|
||||
|
||||
@@ -61,6 +61,12 @@ namespace DepthsBelow
|
||||
|
||||
var pfc = new PathFinder(this);
|
||||
AddComponent(pfc);
|
||||
|
||||
stat.Life = 10;
|
||||
stat.Defence = 10;
|
||||
stat.Strength = 10;
|
||||
stat.GetAim = 100;
|
||||
stat.GetDodge = 20;
|
||||
}
|
||||
|
||||
public bool Selected
|
||||
|
||||
@@ -16,11 +16,23 @@ namespace DepthsBelow
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int baseHitChance = shooting.GetAim();
|
||||
int baseDodgeChance = dodging.GetDodge();
|
||||
int baseHitChance = shooting.GetAim;
|
||||
int baseDodgeChance = dodging.GetDodge;
|
||||
int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent<Component.Transform>().World.Position, defender.GetComponent<Component.Transform>().World.Position) / Grid.TileSize);
|
||||
int chanceToHit = baseHitChance - baseDodgeChance - basePenalty;
|
||||
return chanceToHit;
|
||||
}
|
||||
public static bool HitTest(Entity attacker, Entity defender, int chanceToHit)
|
||||
{
|
||||
Component.Stat shooting = attacker.GetComponent<Component.Stat>();
|
||||
Component.Stat dodging = defender.GetComponent<Component.Stat>();
|
||||
Random rand = new Random();
|
||||
if (rand.Next(0, 100) < chanceToHit)
|
||||
{
|
||||
dodging.Life -= shooting.Strength - dodging.Defence / 2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user