use the player statistics everywhere

This commit is contained in:
Matthias Mailänder
2013-08-10 11:42:31 +02:00
parent c98dfd0439
commit 5dcf1c755c
3 changed files with 8 additions and 7 deletions

View File

@@ -42,10 +42,12 @@ namespace OpenRA.Mods.RA.Activities
var cargo = self.Trait<Cargo>(); var cargo = self.Trait<Cargo>();
while (!cargo.IsEmpty(self)) while (!cargo.IsEmpty(self))
{ {
if (chronosphere != null) if (chronosphere != null && chronosphere.HasTrait<UpdatesPlayerStatistics>())
chronosphere.Owner.Kills++; chronosphere.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsKilled++;
var a = cargo.Unload(self); var a = cargo.Unload(self);
a.Owner.Deaths++; if (a.HasTrait<UpdatesPlayerStatistics>())
a.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsDead++;
} }
} }

View File

@@ -252,7 +252,7 @@ namespace OpenRA.Mods.RA.Missions
void UpdateDeaths() void UpdateDeaths()
{ {
var unitDeaths = allies1.Deaths + allies2.Deaths; var unitDeaths = allies1.PlayerActor.Trait<PlayerStatistics>().UnitsDead + allies2.PlayerActor.Trait<PlayerStatistics>().UnitsDead;
fewDeaths.Text = FewDeathsTemplate.F(unitDeaths, DeathsThreshold); fewDeaths.Text = FewDeathsTemplate.F(unitDeaths, DeathsThreshold);
OnObjectivesUpdated(false); OnObjectivesUpdated(false);
if (unitDeaths >= DeathsThreshold && fewDeaths.Status == ObjectiveStatus.InProgress) if (unitDeaths >= DeathsThreshold && fewDeaths.Status == ObjectiveStatus.InProgress)

View File

@@ -257,11 +257,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
power.GetText = () => powerRes.PowerDrained + "/" + powerRes.PowerProvided; power.GetText = () => powerRes.PowerDrained + "/" + powerRes.PowerProvided;
power.GetColor = () => GetPowerColor(powerRes.PowerState); power.GetColor = () => GetPowerColor(powerRes.PowerState);
template.Get<LabelWidget>("KILLS").GetText = () => player.Kills.ToString();
template.Get<LabelWidget>("DEATHS").GetText = () => player.Deaths.ToString();
var stats = player.PlayerActor.TraitOrDefault<PlayerStatistics>(); var stats = player.PlayerActor.TraitOrDefault<PlayerStatistics>();
if (stats == null) return template; if (stats == null) return template;
template.Get<LabelWidget>("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString();
template.Get<LabelWidget>("DEATHS").GetText = () => (stats.UnitsDead + stats.UnitsDead).ToString();
template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount); template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount);
return template; return template;