Improvements to VictoryConditions, and Dead = Chat to all
This commit is contained in:
@@ -24,8 +24,13 @@ namespace OpenRA.Network
|
||||
{
|
||||
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Index == clientId);
|
||||
if (client != null)
|
||||
Game.AddChatLine(client.Color1,
|
||||
client.Name, order.TargetString);
|
||||
{
|
||||
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
|
||||
if (player.WinState == WinState.Lost)
|
||||
Game.AddChatLine(client.Color1, client.Name + " (Dead)", order.TargetString);
|
||||
else
|
||||
Game.AddChatLine(client.Color1, client.Name, order.TargetString);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "TeamChat":
|
||||
@@ -34,12 +39,15 @@ namespace OpenRA.Network
|
||||
if (client != null)
|
||||
{
|
||||
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
|
||||
|
||||
var isAlly = (world.GameHasStarted) ?
|
||||
player != null && Game.world.LocalPlayer != null && player.Stances[Game.world.LocalPlayer] == Stance.Ally :
|
||||
client == Game.LocalClient || (client.Team == Game.LocalClient.Team && client.Team != 0);
|
||||
|
||||
if (isAlly)
|
||||
if (isAlly && player.WinState != WinState.Lost)
|
||||
Game.AddChatLine(client.Color1, client.Name + " (Team)", order.TargetString);
|
||||
else if (player.WinState == WinState.Lost)
|
||||
Game.AddChatLine(client.Color1, client.Name + " (Dead)", order.TargetString);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,14 @@ using OpenRA.Traits;
|
||||
namespace OpenRA
|
||||
{
|
||||
public enum PowerState { Normal, Low, Critical };
|
||||
public enum WinState { Won, Lost, Undefined };
|
||||
|
||||
public class Player
|
||||
{
|
||||
public Actor PlayerActor;
|
||||
public int Kills;
|
||||
public int Deaths;
|
||||
public WinState WinState = WinState.Undefined;
|
||||
|
||||
public readonly string Palette;
|
||||
public readonly Color Color;
|
||||
|
||||
@@ -154,6 +154,6 @@ namespace OpenRA.Traits
|
||||
public interface IRenderOverlay { void Render(); }
|
||||
public interface INotifyIdle { void Idle(Actor self); }
|
||||
|
||||
public interface IVictoryConditions { bool HasLost { get; } bool HasWon { get; } }
|
||||
public interface IVictoryConditions { }
|
||||
public interface IBlocksBullets { }
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -17,20 +17,21 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class ConquestVictoryConditions : ITick, IVictoryConditions, IResolveOrder
|
||||
{
|
||||
public bool HasLost { get; private set; }
|
||||
public bool HasWon { get; private set; }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
|
||||
|
||||
var hasAnything = self.World.Queries.OwnedBy[self.Owner]
|
||||
.WithTrait<MustBeDestroyed>().Any();
|
||||
|
||||
var hasLost = !hasAnything && !self.Owner.NonCombatant;
|
||||
|
||||
if (hasLost && !HasLost)
|
||||
if (!hasAnything && !self.Owner.NonCombatant)
|
||||
Surrender(self);
|
||||
|
||||
HasLost = hasLost;
|
||||
var others = self.World.players.Where( p => !p.Value.NonCombatant && p.Value != self.Owner && p.Value.Stances[self.Owner] != Stance.Ally );
|
||||
if (others.Count() == 0) return;
|
||||
|
||||
if(others.All(p => p.Value.WinState == WinState.Lost))
|
||||
Win(self);
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
@@ -41,12 +42,24 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
void Surrender(Actor self)
|
||||
{
|
||||
if (self.Owner.WinState == WinState.Lost) return;
|
||||
self.Owner.WinState = WinState.Lost;
|
||||
|
||||
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
||||
foreach (var a in self.World.Queries.OwnedBy[self.Owner])
|
||||
a.InflictDamage(a, a.Health, null);
|
||||
|
||||
self.Owner.Shroud.Disabled = true;
|
||||
HasLost = true;
|
||||
|
||||
}
|
||||
|
||||
void Win(Actor self)
|
||||
{
|
||||
if (self.Owner.WinState == WinState.Won) return;
|
||||
self.Owner.WinState = WinState.Won;
|
||||
|
||||
Game.Debug("{0} is victorious.".F(self.Owner.PlayerName));
|
||||
self.Owner.Shroud.Disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user