Improve the stability of CountdownTimer
This commit is contained in:
@@ -401,7 +401,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
void StartReinforcementsTimer()
|
void StartReinforcementsTimer()
|
||||||
{
|
{
|
||||||
Sound.Play("timergo1.aud");
|
Sound.Play("timergo1.aud");
|
||||||
reinforcementsTimer = new CountdownTimer(ReinforcementsTicks, ReinforcementsTimerExpired);
|
reinforcementsTimer = new CountdownTimer(ReinforcementsTicks, ReinforcementsTimerExpired, true);
|
||||||
reinforcementsTimerWidget = new CountdownTimerWidget(reinforcementsTimer, "Reinforcements arrive in", new float2(Game.viewport.Width * 0.1f, Game.viewport.Height * 0.8f));
|
reinforcementsTimerWidget = new CountdownTimerWidget(reinforcementsTimer, "Reinforcements arrive in", new float2(Game.viewport.Width * 0.1f, Game.viewport.Height * 0.8f));
|
||||||
Ui.Root.AddChild(reinforcementsTimerWidget);
|
Ui.Root.AddChild(reinforcementsTimerWidget);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,30 +18,33 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
{
|
{
|
||||||
public int TicksLeft { get; set; }
|
public int TicksLeft { get; set; }
|
||||||
|
|
||||||
public Action<CountdownTimer> OnExpired { get; set; }
|
public event Action<CountdownTimer> OnExpired = t => { };
|
||||||
public Action<CountdownTimer> OnOneMinuteRemaining { get; set; }
|
public event Action<CountdownTimer> OnOneMinuteRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnTwoMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnTwoMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnThreeMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnThreeMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnFourMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnFourMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnFiveMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnFiveMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnTenMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnTenMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnTwentyMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnTwentyMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnThirtyMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnThirtyMinutesRemaining = t => { };
|
||||||
public Action<CountdownTimer> OnFortyMinutesRemaining { get; set; }
|
public event Action<CountdownTimer> OnFortyMinutesRemaining = t => { };
|
||||||
|
|
||||||
public CountdownTimer(int ticksLeft, Action<CountdownTimer> onExpired)
|
public CountdownTimer(int ticksLeft, Action<CountdownTimer> onExpired, bool withNotifications)
|
||||||
{
|
{
|
||||||
TicksLeft = ticksLeft;
|
TicksLeft = ticksLeft;
|
||||||
OnExpired = onExpired;
|
OnExpired += onExpired;
|
||||||
OnOneMinuteRemaining = t => Sound.Play("1minr.aud");
|
if (withNotifications)
|
||||||
OnTwoMinutesRemaining = t => Sound.Play("2minr.aud");
|
{
|
||||||
OnThreeMinutesRemaining = t => Sound.Play("3minr.aud");
|
OnOneMinuteRemaining += t => Sound.Play("1minr.aud");
|
||||||
OnFourMinutesRemaining = t => Sound.Play("4minr.aud");
|
OnTwoMinutesRemaining += t => Sound.Play("2minr.aud");
|
||||||
OnFiveMinutesRemaining = t => Sound.Play("5minr.aud");
|
OnThreeMinutesRemaining += t => Sound.Play("3minr.aud");
|
||||||
OnTenMinutesRemaining = t => Sound.Play("10minr.aud");
|
OnFourMinutesRemaining += t => Sound.Play("4minr.aud");
|
||||||
OnTwentyMinutesRemaining = t => Sound.Play("20minr.aud");
|
OnFiveMinutesRemaining += t => Sound.Play("5minr.aud");
|
||||||
OnThirtyMinutesRemaining = t => Sound.Play("30minr.aud");
|
OnTenMinutesRemaining += t => Sound.Play("10minr.aud");
|
||||||
OnFortyMinutesRemaining = t => Sound.Play("40minr.aud");
|
OnTwentyMinutesRemaining += t => Sound.Play("20minr.aud");
|
||||||
|
OnThirtyMinutesRemaining += t => Sound.Play("30minr.aud");
|
||||||
|
OnFortyMinutesRemaining += t => Sound.Play("40minr.aud");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
|
|||||||
Reference in New Issue
Block a user