hacked victory conditions
This commit is contained in:
@@ -47,7 +47,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public ITexture PaletteTexture;
|
public ITexture PaletteTexture;
|
||||||
|
|
||||||
public readonly SpriteFont RegularFont, BoldFont;
|
public readonly SpriteFont RegularFont, BoldFont, TitleFont;
|
||||||
|
|
||||||
public Size Resolution { get { return device.WindowSize; } }
|
public Size Resolution { get { return device.WindowSize; } }
|
||||||
|
|
||||||
@@ -64,11 +64,9 @@ namespace OpenRA.Graphics
|
|||||||
RgbaSpriteRenderer = new SpriteRenderer( this, RgbaSpriteShader );
|
RgbaSpriteRenderer = new SpriteRenderer( this, RgbaSpriteShader );
|
||||||
WorldSpriteRenderer = new SpriteRenderer( this, WorldSpriteShader );
|
WorldSpriteRenderer = new SpriteRenderer( this, WorldSpriteShader );
|
||||||
|
|
||||||
// RegularFont = device.CreateFont( "FreeSans.ttf" );
|
|
||||||
// BoldFont = device.CreateFont( "FreeSansBold.ttf" );
|
|
||||||
|
|
||||||
RegularFont = new SpriteFont(this, "FreeSans.ttf", 14);
|
RegularFont = new SpriteFont(this, "FreeSans.ttf", 14);
|
||||||
BoldFont = new SpriteFont(this, "FreeSansBold.ttf", 14);
|
BoldFont = new SpriteFont(this, "FreeSansBold.ttf", 14);
|
||||||
|
TitleFont = new SpriteFont(this, "titles.ttf", 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool windowed, bool vsync )
|
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool windowed, bool vsync )
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||||
<Compile Include="Traits\AI\EmitInfantryOnSell.cs" />
|
<Compile Include="Traits\AI\EmitInfantryOnSell.cs" />
|
||||||
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
|
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
|
||||||
|
<Compile Include="Traits\Player\VictoryConditions.cs" />
|
||||||
<Compile Include="Traits\Render\HiddenUnderFog.cs" />
|
<Compile Include="Traits\Render\HiddenUnderFog.cs" />
|
||||||
<Compile Include="Traits\Render\RenderFlare.cs" />
|
<Compile Include="Traits\Render\RenderFlare.cs" />
|
||||||
<Compile Include="Traits\World\Shroud.cs" />
|
<Compile Include="Traits\World\Shroud.cs" />
|
||||||
@@ -90,6 +91,7 @@
|
|||||||
<Compile Include="Widgets\Delegates\MainMenuButtonsDelegate.cs" />
|
<Compile Include="Widgets\Delegates\MainMenuButtonsDelegate.cs" />
|
||||||
<Compile Include="Widgets\Delegates\ServerBrowserDelegate.cs" />
|
<Compile Include="Widgets\Delegates\ServerBrowserDelegate.cs" />
|
||||||
<Compile Include="Widgets\Delegates\SettingsMenuDelegate.cs" />
|
<Compile Include="Widgets\Delegates\SettingsMenuDelegate.cs" />
|
||||||
|
<Compile Include="Widgets\PostGameWidget.cs" />
|
||||||
<Compile Include="Widgets\WidgetUtils.cs" />
|
<Compile Include="Widgets\WidgetUtils.cs" />
|
||||||
<Compile Include="Combat.cs" />
|
<Compile Include="Combat.cs" />
|
||||||
<Compile Include="Effects\Corpse.cs" />
|
<Compile Include="Effects\Corpse.cs" />
|
||||||
|
|||||||
40
OpenRA.Game/Traits/Player/VictoryConditions.cs
Normal file
40
OpenRA.Game/Traits/Player/VictoryConditions.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRA.Traits
|
||||||
|
{
|
||||||
|
class VictoryConditionsInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly string[] ShortGameUnits = { "mcv" };
|
||||||
|
public object Create(Actor self) { return new VictoryConditions( self ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IVictoryConditions { bool HasLost { get; } bool HasWon { get; } }
|
||||||
|
|
||||||
|
class VictoryConditions : ITick, IVictoryConditions
|
||||||
|
{
|
||||||
|
public bool HasLost { get; private set; }
|
||||||
|
public bool HasWon { get; private set; }
|
||||||
|
|
||||||
|
public VictoryConditions(Actor self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick(Actor self)
|
||||||
|
{
|
||||||
|
var info = self.Info.Traits.Get<VictoryConditionsInfo>();
|
||||||
|
var hasAnyBuildings = self.World.Queries.OwnedBy[self.Owner]
|
||||||
|
.WithTrait<Building>().Any();
|
||||||
|
var hasAnyShortGameUnits = self.World.Queries.OwnedBy[self.Owner]
|
||||||
|
.Any(a => info.ShortGameUnits.Contains(a.Info.Name));
|
||||||
|
|
||||||
|
var hasLost = !(hasAnyBuildings || hasAnyShortGameUnits);
|
||||||
|
if (hasLost && !HasLost)
|
||||||
|
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
||||||
|
|
||||||
|
HasLost = hasLost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
OpenRA.Game/Widgets/PostGameWidget.cs
Normal file
56
OpenRA.Game/Widgets/PostGameWidget.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace OpenRA.Widgets
|
||||||
|
{
|
||||||
|
class PostGameWidget : Widget
|
||||||
|
{
|
||||||
|
string text;
|
||||||
|
|
||||||
|
public override void Draw(World world)
|
||||||
|
{
|
||||||
|
base.Draw(world);
|
||||||
|
|
||||||
|
if (world.LocalPlayer == null) text = null;
|
||||||
|
|
||||||
|
else if (world.players.Count > 2) /* more than just us + neutral */
|
||||||
|
{
|
||||||
|
var conds = world.Queries.WithTrait<IVictoryConditions>()
|
||||||
|
.Where(c => c.Actor.Owner != world.NeutralPlayer);
|
||||||
|
|
||||||
|
if (conds.Any(c => c.Actor.Owner == world.LocalPlayer && c.Trait.HasLost))
|
||||||
|
text = "YOU ARE DEFEATED";
|
||||||
|
else if (conds.All(c => c.Actor.Owner == world.LocalPlayer || c.Trait.HasLost))
|
||||||
|
text = "YOU ARE VICTORIOUS";
|
||||||
|
else
|
||||||
|
text = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
text = null;
|
||||||
|
|
||||||
|
if (text != null)
|
||||||
|
DrawText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawText(string s)
|
||||||
|
{
|
||||||
|
var size = Game.chrome.renderer.TitleFont.Measure(s);
|
||||||
|
|
||||||
|
WidgetUtils.DrawPanel("dialog4", new Rectangle(
|
||||||
|
(Game.viewport.Width - size.X - 40) / 2,
|
||||||
|
(Game.viewport.Height - size.Y - 10) / 2,
|
||||||
|
size.X + 40,
|
||||||
|
size.Y + 13), null);
|
||||||
|
|
||||||
|
Game.chrome.renderer.TitleFont.DrawText(s,
|
||||||
|
new float2((Game.viewport.Width - size.X) / 2,
|
||||||
|
(Game.viewport.Height - size.Y) / 2 - .2f * size.Y), Color.White);
|
||||||
|
|
||||||
|
Game.chrome.renderer.RgbaSpriteRenderer.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
Container:
|
Container:
|
||||||
ClickThrough:true
|
ClickThrough:true
|
||||||
Children:
|
Children:
|
||||||
|
PostGame@POSTGAME_TEXT:
|
||||||
|
Id:POSTGAME_TEXT
|
||||||
|
X:0
|
||||||
|
Y:0
|
||||||
|
Width: WINDOW_RIGHT
|
||||||
|
Height: WINDOW_BOTTOM
|
||||||
|
ClickThrough: true
|
||||||
|
Visible: true
|
||||||
Background@MAINMENU_BG:
|
Background@MAINMENU_BG:
|
||||||
Id:MAINMENU_BG
|
Id:MAINMENU_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ Player:
|
|||||||
OneShot: yes
|
OneShot: yes
|
||||||
UnitType: badr.bomber
|
UnitType: badr.bomber
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
|
VictoryConditions:
|
||||||
|
ShortGameUnits: mcv
|
||||||
|
|
||||||
|
|
||||||
World:
|
World:
|
||||||
|
|||||||
BIN
titles.ttf
Normal file
BIN
titles.ttf
Normal file
Binary file not shown.
Reference in New Issue
Block a user