Parabomb crates. Multiple can be collected and queued. Support uncharged powers (0 charge time) with appropriate tooltip.

This commit is contained in:
Paul Chote
2010-12-05 23:32:29 +13:00
parent d1850e8b4b
commit c7500084df
3 changed files with 38 additions and 32 deletions

View File

@@ -10,32 +10,30 @@
using System.Linq;
using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA.Mods.RA.Crates
{
class SupportPowerCrateActionInfo : CrateActionInfo
{
public readonly string Power = null;
public readonly string Proxy = null;
public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.self, this); }
}
class SupportPowerCrateAction : CrateAction
{
SupportPowerCrateActionInfo Info;
public SupportPowerCrateAction(Actor self, SupportPowerCrateActionInfo info)
: base(self, info) { }
: base(self, info) { Info = info; }
// The free unit crate requires same race, and the actor to be at least ITeleportable.
// We want neither of these properties for crate power proxies.
public override void Activate(Actor collector)
{
throw new System.NotImplementedException();
// shit and broken. if you have a single-use and a multi-use version of the same
// support power, this only works by order-coincidence. that's stupid.
//var p = collector.Owner.PlayerActor.TraitsImplementing<SupportPower>()
// .FirstOrDefault(sp => sp.GetType().Name == (info as SupportPowerCrateActionInfo).Power);
//if (p != null) p.Give(1);
//base.Activate(collector);
collector.World.AddFrameEndTask(w => w.CreateActor(Info.Proxy, new TypeDictionary
{
new OwnerInit( collector.Owner )
}));
}
}
}

View File

@@ -103,7 +103,9 @@ namespace OpenRA.Mods.RA.Widgets
var pos = drawPos.ToInt2();
var tl = new int2(pos.X-3,pos.Y-3);
var m = new int2(pos.X+64+3,pos.Y+48+3);
var br = tl + new int2(64+3+20,60);
var br = tl + new int2(64+3+20,40);
if (sp.TotalTime > 0)
br += new int2(0,20);
if (sp.Info.LongDesc != null)
br += Game.Renderer.RegularFont.Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
@@ -122,9 +124,12 @@ namespace OpenRA.Mods.RA.Widgets
pos += new int2(77, 5);
Game.Renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);
pos += new int2(0,20);
Game.Renderer.BoldFont.DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
Game.Renderer.BoldFont.DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
if (sp.TotalTime > 0)
{
pos += new int2(0,20);
Game.Renderer.BoldFont.DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
Game.Renderer.BoldFont.DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
}
if (sp.Info.LongDesc != null)
{
@@ -136,7 +141,7 @@ namespace OpenRA.Mods.RA.Widgets
WidgetUtils.DrawSHP(image, drawPos, wr);
clock.PlayFetchIndex("idle",
() => (sp.TotalTime - sp.RemainingTime)
() => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
clock.Tick();