This commit is contained in:
Chris Forbes
2010-04-13 20:43:11 +12:00
parent 9e11932ade
commit 6cf4692023

View File

@@ -9,31 +9,22 @@ namespace OpenRA.Widgets
{ {
class PostGameWidget : Widget class PostGameWidget : Widget
{ {
string text;
public override void Draw(World world) public override void Draw(World world)
{ {
base.Draw(world); base.Draw(world);
if (world.LocalPlayer == null) text = null; if (world.LocalPlayer == null) return;
else if (world.players.Count > 2) /* more than just us + neutral */ if (world.players.Count > 2) /* more than just us + neutral */
{ {
var conds = world.Queries.WithTrait<IVictoryConditions>() var conds = world.Queries.WithTrait<IVictoryConditions>()
.Where(c => c.Actor.Owner != world.NeutralPlayer); .Where(c => c.Actor.Owner != world.NeutralPlayer);
if (conds.Any(c => c.Actor.Owner == world.LocalPlayer && c.Trait.HasLost)) if (conds.Any(c => c.Actor.Owner == world.LocalPlayer && c.Trait.HasLost))
text = "YOU ARE DEFEATED"; DrawText("YOU ARE DEFEATED");
else if (conds.All(c => c.Actor.Owner == world.LocalPlayer || c.Trait.HasLost)) else if (conds.All(c => c.Actor.Owner == world.LocalPlayer || c.Trait.HasLost))
text = "YOU ARE VICTORIOUS"; DrawText("YOU ARE VICTORIOUS");
else
text = null;
} }
else
text = null;
if (text != null)
DrawText(text);
} }
void DrawText(string s) void DrawText(string s)