Fix health bar colors. Todo: Merge DamageState & ExtendedDamageState
This commit is contained in:
@@ -23,10 +23,6 @@ namespace OpenRA.Traits
|
|||||||
public readonly int HP = 0;
|
public readonly int HP = 0;
|
||||||
public readonly int InitialHP = 0;
|
public readonly int InitialHP = 0;
|
||||||
public readonly ArmorType Armor = ArmorType.none;
|
public readonly ArmorType Armor = ArmorType.none;
|
||||||
|
|
||||||
public readonly float ConditionRed = 0.25f;
|
|
||||||
public readonly float ConditionYellow = 0.5f;
|
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new Health(init, this); }
|
public virtual object Create(ActorInitializer init) { return new Health(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,16 +49,6 @@ namespace OpenRA.Traits
|
|||||||
public bool IsDead { get { return hp <= 0; } }
|
public bool IsDead { get { return hp <= 0; } }
|
||||||
public bool RemoveOnDeath = true;
|
public bool RemoveOnDeath = true;
|
||||||
|
|
||||||
public Color HealthColor
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return (hp < Info.ConditionRed) ? Color.Red
|
|
||||||
: (hp < Info.ConditionYellow) ? Color.Yellow
|
|
||||||
: Color.LimeGreen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DamageState DamageState
|
public DamageState DamageState
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -70,7 +56,7 @@ namespace OpenRA.Traits
|
|||||||
if (hp <= 0)
|
if (hp <= 0)
|
||||||
return DamageState.Dead;
|
return DamageState.Dead;
|
||||||
|
|
||||||
if (hp < MaxHP * Info.ConditionYellow)
|
if (hp < MaxHP * 0.5f)
|
||||||
return DamageState.Half;
|
return DamageState.Half;
|
||||||
|
|
||||||
return DamageState.Normal;
|
return DamageState.Normal;
|
||||||
@@ -84,13 +70,13 @@ namespace OpenRA.Traits
|
|||||||
if (hp <= 0)
|
if (hp <= 0)
|
||||||
return ExtendedDamageState.Dead;
|
return ExtendedDamageState.Dead;
|
||||||
|
|
||||||
if (hp < MaxHP * Info.ConditionRed)
|
if (hp < MaxHP * 0.25f)
|
||||||
return ExtendedDamageState.Quarter;
|
return ExtendedDamageState.Quarter;
|
||||||
|
|
||||||
if (hp < MaxHP * Info.ConditionYellow)
|
if (hp < MaxHP * 0.5f)
|
||||||
return ExtendedDamageState.Half;
|
return ExtendedDamageState.Half;
|
||||||
|
|
||||||
if (hp < MaxHP * 0.75)
|
if (hp < MaxHP * 0.75f)
|
||||||
return ExtendedDamageState.ThreeQuarter;
|
return ExtendedDamageState.ThreeQuarter;
|
||||||
|
|
||||||
return ExtendedDamageState.Normal;
|
return ExtendedDamageState.Normal;
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ namespace OpenRA.Traits
|
|||||||
Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c);
|
Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c);
|
||||||
Game.Renderer.LineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c);
|
Game.Renderer.LineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c);
|
||||||
|
|
||||||
var healthColor = health.HealthColor;
|
var healthColor = (health.ExtendedDamageState == ExtendedDamageState.Quarter) ? Color.Red :
|
||||||
|
(health.ExtendedDamageState == ExtendedDamageState.Half) ? Color.Yellow : Color.LimeGreen;
|
||||||
|
|
||||||
var healthColor2 = Color.FromArgb(
|
var healthColor2 = Color.FromArgb(
|
||||||
255,
|
255,
|
||||||
healthColor.R / 2,
|
healthColor.R / 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user