Add more things to the Combat tab
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
@@ -22,6 +23,14 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
World world;
|
||||
Player player;
|
||||
public double MapControl;
|
||||
public int OrderCount;
|
||||
public int KillsCost;
|
||||
public int DeathsCost;
|
||||
public int UnitsKilled;
|
||||
public int UnitsDead;
|
||||
public int BuildingsKilled;
|
||||
public int BuildingsDead;
|
||||
|
||||
public PlayerStatistics(Actor self)
|
||||
{
|
||||
@@ -29,8 +38,6 @@ namespace OpenRA.Mods.RA
|
||||
player = self.Owner;
|
||||
}
|
||||
|
||||
public double MapControl;
|
||||
|
||||
void UpdateMapControl()
|
||||
{
|
||||
var total = (double)world.Map.Bounds.Width * world.Map.Bounds.Height;
|
||||
@@ -49,8 +56,6 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
public int OrderCount;
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
switch (order.OrderString)
|
||||
@@ -73,4 +78,31 @@ namespace OpenRA.Mods.RA
|
||||
OrderCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdatesPlayerStatisticsInfo : TraitInfo<UpdatesPlayerStatistics> { }
|
||||
|
||||
public class UpdatesPlayerStatistics : INotifyKilled
|
||||
{
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
var defenderStats = self.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
if (self.HasTrait<Building>())
|
||||
{
|
||||
attackerStats.BuildingsKilled++;
|
||||
defenderStats.BuildingsDead++;
|
||||
}
|
||||
if (self.HasTrait<IMove>())
|
||||
{
|
||||
attackerStats.UnitsKilled++;
|
||||
defenderStats.UnitsDead++;
|
||||
}
|
||||
if (self.HasTrait<Valued>())
|
||||
{
|
||||
var cost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
attackerStats.KillsCost += cost;
|
||||
defenderStats.DeathsCost += cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
var stats = player.PlayerActor.Trait<PlayerStatistics>();
|
||||
template.Get<LabelWidget>("CONTROL").GetText = () => MapControl(stats.MapControl);
|
||||
template.Get<LabelWidget>("KILLS_COST").GetText = () => "$" + stats.KillsCost.ToString();
|
||||
template.Get<LabelWidget>("DEATHS_COST").GetText = () => "$" + stats.DeathsCost.ToString();
|
||||
template.Get<LabelWidget>("UNITS_KILLED").GetText = () => stats.UnitsKilled.ToString();
|
||||
template.Get<LabelWidget>("UNITS_DEAD").GetText = () => stats.UnitsDead.ToString();
|
||||
template.Get<LabelWidget>("BUILDINGS_KILLED").GetText = () => stats.BuildingsKilled.ToString();
|
||||
template.Get<LabelWidget>("BUILDINGS_DEAD").GetText = () => stats.BuildingsDead.ToString();
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ Container@OBSERVER_ROOT:
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Earned/min
|
||||
Label@POWER_HEADER
|
||||
Label@POWER_HEADER:
|
||||
X:425
|
||||
Y:40
|
||||
Width:80
|
||||
@@ -503,28 +503,28 @@ Container@OBSERVER_ROOT:
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Earned/min
|
||||
Label@ASSETS_HEADER
|
||||
Label@ASSETS_HEADER:
|
||||
X:425
|
||||
Y:40
|
||||
Width:60
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Assets
|
||||
Label@EARNED_HEADER
|
||||
Label@EARNED_HEADER:
|
||||
X:505
|
||||
Y:40
|
||||
Width:60
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Earned
|
||||
Label@SPENT_HEADER
|
||||
Label@SPENT_HEADER:
|
||||
X:585
|
||||
Y:40
|
||||
Width:60
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Spent
|
||||
Label@HARVESTERS_HEADER
|
||||
Label@HARVESTERS_HEADER:
|
||||
X:665
|
||||
Y:40
|
||||
Width:60
|
||||
@@ -545,7 +545,7 @@ Container@OBSERVER_ROOT:
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Player
|
||||
Label@PRODUCTION_HEADER
|
||||
Label@PRODUCTION_HEADER:
|
||||
X:245
|
||||
Y:40
|
||||
Width:320
|
||||
@@ -579,6 +579,52 @@ Container@OBSERVER_ROOT:
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Control
|
||||
Label@KILLS_COST_HEADER:
|
||||
X:325
|
||||
Y:40
|
||||
Width:60
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Kills
|
||||
Label@DEATHS_COST_HEADER:
|
||||
X:405
|
||||
Y:40
|
||||
Width:60
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Deaths
|
||||
Label@UNITS_KILLED_HEADER:
|
||||
X:505
|
||||
Y:40
|
||||
Width:40
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Units Killed
|
||||
Align:Right
|
||||
Label@UNITS_DEAD_HEADER:
|
||||
X:605
|
||||
Y:40
|
||||
Width:40
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Units Dead
|
||||
Align:Right
|
||||
Label@BUILDINGS_KILLED_HEADER:
|
||||
X:725
|
||||
Y:40
|
||||
Width:40
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Bld Destroyed
|
||||
Align:Right
|
||||
Label@BUILDINGS_DEAD_HEADER:
|
||||
X:825
|
||||
Y:40
|
||||
Width:40
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Bld Lost
|
||||
Align:Right
|
||||
ScrollPanel@PLAYER_STATS_PANEL:
|
||||
X:25
|
||||
Y:70
|
||||
@@ -748,11 +794,45 @@ Container@OBSERVER_ROOT:
|
||||
Width:160
|
||||
Height:PARENT_BOTTOM
|
||||
Font:Bold
|
||||
Label@CONTROL
|
||||
Label@CONTROL:
|
||||
X:215
|
||||
Y:0
|
||||
Width:60
|
||||
Height:PARENT_BOTTOM
|
||||
Label@KILLS_COST:
|
||||
X:295
|
||||
Y:0
|
||||
Width:60
|
||||
Height:PARENT_BOTTOM
|
||||
Label@DEATHS_COST:
|
||||
X:375
|
||||
Y:0
|
||||
Width:60
|
||||
Height:PARENT_BOTTOM
|
||||
Label@UNITS_KILLED:
|
||||
X:475
|
||||
Y:0
|
||||
Width:40
|
||||
Height:PARENT_BOTTOM
|
||||
Align:Right
|
||||
Label@UNITS_DEAD:
|
||||
X:575
|
||||
Y:0
|
||||
Width:40
|
||||
Height:PARENT_BOTTOM
|
||||
Align:Right
|
||||
Label@BUILDINGS_KILLED:
|
||||
X:695
|
||||
Y:0
|
||||
Width:40
|
||||
Height:PARENT_BOTTOM
|
||||
Align:Right
|
||||
Label@BUILDINGS_DEAD:
|
||||
X:795
|
||||
Y:0
|
||||
Width:40
|
||||
Height:PARENT_BOTTOM
|
||||
Align:Right
|
||||
Background@FMVPLAYER:
|
||||
Width:WINDOW_RIGHT
|
||||
Height:WINDOW_BOTTOM
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
GpsDot:
|
||||
String:Vehicle
|
||||
WithSmoke:
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^Tank:
|
||||
AppearsOnRadar:
|
||||
@@ -67,6 +68,7 @@
|
||||
GpsDot:
|
||||
String:Vehicle
|
||||
WithSmoke:
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^Infantry:
|
||||
AppearsOnRadar:
|
||||
@@ -114,6 +116,7 @@
|
||||
RepairableNear:
|
||||
Buildings: hosp
|
||||
CloseEnough: 1
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^Ship:
|
||||
AppearsOnRadar:
|
||||
@@ -141,6 +144,7 @@
|
||||
GpsDot:
|
||||
String:Ship
|
||||
WithSmoke:
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^Plane:
|
||||
AppearsOnRadar:
|
||||
@@ -169,6 +173,7 @@
|
||||
GivesBounty:
|
||||
GpsDot:
|
||||
String:Plane
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^Helicopter:
|
||||
Inherits: ^Plane
|
||||
@@ -210,6 +215,7 @@
|
||||
Sellable:
|
||||
AcceptsSupplies:
|
||||
GivesBounty:
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^Wall:
|
||||
AppearsOnRadar:
|
||||
@@ -242,6 +248,7 @@
|
||||
ProximityCaptor:
|
||||
Types:Wall
|
||||
Sellable:
|
||||
UpdatesPlayerStatistics:
|
||||
|
||||
^TechBuilding:
|
||||
Inherits: ^Building
|
||||
|
||||
Reference in New Issue
Block a user