Merge pull request #2935 from Mailaender/superweapon-cooldown

Added durationbar indicators for iron curtain and chronoshift
This commit is contained in:
Chris Forbes
2013-04-03 01:53:40 -07:00
2 changed files with 25 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -8,6 +8,7 @@
*/
#endregion
using System.Drawing;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
@@ -18,13 +19,14 @@ namespace OpenRA.Mods.RA
public readonly bool ExplodeInstead = false;
}
public class Chronoshiftable : ITick, ISync
public class Chronoshiftable : ITick, ISync, ISelectionBar
{
// Return-to-sender logic
[Sync] CPos chronoshiftOrigin;
[Sync] int chronoshiftReturnTicks = 0;
Actor chronosphere;
bool killCargo;
int TotalTicks;
public void Tick(Actor self)
{
@@ -66,6 +68,7 @@ namespace OpenRA.Mods.RA
/// Set up return-to-sender info
chronoshiftOrigin = self.Location;
chronoshiftReturnTicks = duration;
TotalTicks = duration;
this.chronosphere = chronosphere;
this.killCargo = killCargo;
@@ -75,5 +78,13 @@ namespace OpenRA.Mods.RA
return true;
}
// Show the remaining time as a bar
public float GetValue()
{
return (float)chronoshiftReturnTicks / TotalTicks;
}
public Color GetColor() { return Color.White; }
}
}

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Drawing;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
@@ -16,9 +17,10 @@ namespace OpenRA.Mods.RA
{
class IronCurtainableInfo : TraitInfo<IronCurtainable> { }
class IronCurtainable : IDamageModifier, ITick, ISync
class IronCurtainable : IDamageModifier, ITick, ISync, ISelectionBar
{
[Sync] int RemainingTicks = 0;
int TotalTicks;
public void Tick(Actor self)
{
@@ -37,6 +39,15 @@ namespace OpenRA.Mods.RA
self.World.AddFrameEndTask(w => w.Add(new InvulnEffect(self))); // do not stack the invuln effect
RemainingTicks = duration;
TotalTicks = duration;
}
// Show the remaining time as a bar
public float GetValue()
{
return (float)RemainingTicks / TotalTicks;
}
public Color GetColor() { return Color.Red; }
}
}