Improvements to VictoryConditions, and Dead = Chat to all

This commit is contained in:
alzeih
2010-07-21 20:20:12 +12:00
parent d69267f71c
commit 8e2d422054
6 changed files with 43 additions and 32 deletions

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Widgets
{
class ChatDisplayWidget : Widget
{
const int logLength = 10;
const int logLength = 9;
public string Notification = "";
public bool DrawBackground = true;

View File

@@ -62,26 +62,14 @@ namespace OpenRA.Widgets.Delegates
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
postgameBG.IsVisible = () =>
{
var conds = Game.world.Queries.WithTrait<IVictoryConditions>()
.Where(c => !c.Actor.Owner.NonCombatant);
if (Game.world.LocalPlayer != null && conds.Count() > 1)
{
if (conds.Any(c => c.Actor.Owner == Game.world.LocalPlayer && c.Trait.HasLost)
|| conds.All(c => AreMutualAllies(c.Actor.Owner, Game.world.LocalPlayer) || c.Trait.HasLost))
return true;
}
return false;
return Game.world.LocalPlayer.WinState != WinState.Undefined;
};
postgameText.GetText = () =>
{
var lost = Game.world.Queries.WithTrait<IVictoryConditions>()
.Where(c => c.Actor.Owner == Game.world.LocalPlayer)
.Any(c => c.Trait.HasLost);
return (lost) ? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS";
var state = Game.world.LocalPlayer.WinState;
return (state == WinState.Undefined)? "" :
((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
};
}
bool AreMutualAllies(Player a, Player b) { return a.Stances[b] == Stance.Ally && b.Stances[a] == Stance.Ally; }