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);
|
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Index == clientId);
|
||||||
if (client != null)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case "TeamChat":
|
case "TeamChat":
|
||||||
@@ -34,12 +39,15 @@ namespace OpenRA.Network
|
|||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
|
var player = Game.world.players.Values.FirstOrDefault(p => p.Index == client.Index);
|
||||||
|
|
||||||
var isAlly = (world.GameHasStarted) ?
|
var isAlly = (world.GameHasStarted) ?
|
||||||
player != null && Game.world.LocalPlayer != null && player.Stances[Game.world.LocalPlayer] == Stance.Ally :
|
player != null && Game.world.LocalPlayer != null && player.Stances[Game.world.LocalPlayer] == Stance.Ally :
|
||||||
client == Game.LocalClient || (client.Team == Game.LocalClient.Team && client.Team != 0);
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public enum PowerState { Normal, Low, Critical };
|
public enum PowerState { Normal, Low, Critical };
|
||||||
|
public enum WinState { Won, Lost, Undefined };
|
||||||
|
|
||||||
public class Player
|
public class Player
|
||||||
{
|
{
|
||||||
public Actor PlayerActor;
|
public Actor PlayerActor;
|
||||||
public int Kills;
|
public int Kills;
|
||||||
public int Deaths;
|
public int Deaths;
|
||||||
|
public WinState WinState = WinState.Undefined;
|
||||||
|
|
||||||
public readonly string Palette;
|
public readonly string Palette;
|
||||||
public readonly Color Color;
|
public readonly Color Color;
|
||||||
|
|||||||
@@ -154,6 +154,6 @@ namespace OpenRA.Traits
|
|||||||
public interface IRenderOverlay { void Render(); }
|
public interface IRenderOverlay { void Render(); }
|
||||||
public interface INotifyIdle { void Idle(Actor self); }
|
public interface INotifyIdle { void Idle(Actor self); }
|
||||||
|
|
||||||
public interface IVictoryConditions { bool HasLost { get; } bool HasWon { get; } }
|
public interface IVictoryConditions { }
|
||||||
public interface IBlocksBullets { }
|
public interface IBlocksBullets { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
class ChatDisplayWidget : Widget
|
class ChatDisplayWidget : Widget
|
||||||
{
|
{
|
||||||
const int logLength = 10;
|
const int logLength = 9;
|
||||||
public string Notification = "";
|
public string Notification = "";
|
||||||
public bool DrawBackground = true;
|
public bool DrawBackground = true;
|
||||||
|
|
||||||
|
|||||||
@@ -62,26 +62,14 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
|
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
|
||||||
postgameBG.IsVisible = () =>
|
postgameBG.IsVisible = () =>
|
||||||
{
|
{
|
||||||
var conds = Game.world.Queries.WithTrait<IVictoryConditions>()
|
return Game.world.LocalPlayer.WinState != WinState.Undefined;
|
||||||
.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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
postgameText.GetText = () =>
|
postgameText.GetText = () =>
|
||||||
{
|
{
|
||||||
var lost = Game.world.Queries.WithTrait<IVictoryConditions>()
|
var state = Game.world.LocalPlayer.WinState;
|
||||||
.Where(c => c.Actor.Owner == Game.world.LocalPlayer)
|
return (state == WinState.Undefined)? "" :
|
||||||
.Any(c => c.Trait.HasLost);
|
((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
|
||||||
|
|
||||||
return (lost) ? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
bool AreMutualAllies(Player a, Player b) { return a.Stances[b] == Stance.Ally && b.Stances[a] == Stance.Ally; }
|
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
|
class ConquestVictoryConditions : ITick, IVictoryConditions, IResolveOrder
|
||||||
{
|
{
|
||||||
public bool HasLost { get; private set; }
|
|
||||||
public bool HasWon { get; private set; }
|
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
|
||||||
|
|
||||||
var hasAnything = self.World.Queries.OwnedBy[self.Owner]
|
var hasAnything = self.World.Queries.OwnedBy[self.Owner]
|
||||||
.WithTrait<MustBeDestroyed>().Any();
|
.WithTrait<MustBeDestroyed>().Any();
|
||||||
|
|
||||||
var hasLost = !hasAnything && !self.Owner.NonCombatant;
|
if (!hasAnything && !self.Owner.NonCombatant)
|
||||||
|
|
||||||
if (hasLost && !HasLost)
|
|
||||||
Surrender(self);
|
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)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
@@ -41,12 +42,24 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
void Surrender(Actor self)
|
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));
|
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
||||||
foreach (var a in self.World.Queries.OwnedBy[self.Owner])
|
foreach (var a in self.World.Queries.OwnedBy[self.Owner])
|
||||||
a.InflictDamage(a, a.Health, null);
|
a.InflictDamage(a, a.Health, null);
|
||||||
|
|
||||||
self.Owner.Shroud.Disabled = true;
|
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