Red Alert CashTicks

Three options for cash ticks:
Extreme: current behavoir (every cash countdown tick is heard)
Normal: RedAlert countdown style (only one cash countdown tick every ~1 or 2 seconds)
Disabled: No cash tickdown or tickup is heard.

Thanks to Tirili for hints on the settings system.
This commit is contained in:
Remco van der Zon
2012-05-05 11:27:03 +02:00
committed by Chris Forbes
parent 6291c8396b
commit 6c96a106e7
4 changed files with 76 additions and 6 deletions

View File

@@ -10,6 +10,7 @@
using System;
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -62,6 +63,8 @@ namespace OpenRA.Traits
{
readonly Player Owner;
int AdviceInterval;
int tickermod = 0;
public PlayerResources(Actor self, PlayerResourcesInfo info)
{
@@ -134,7 +137,8 @@ namespace OpenRA.Traits
public void Tick(Actor self)
{
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
tickermod = (tickermod + 1) % 3;
OreCapacity = self.World.ActorsWithTrait<IStoreOre>()
.Where(a => a.Actor.Owner == Owner)
.Sum(a => a.Trait.Capacity);
@@ -158,12 +162,12 @@ namespace OpenRA.Traits
if (DisplayCash < Cash)
{
DisplayCash += move;
Sound.PlayToPlayer(self.Owner, eva.CashTickUp);
playCashTickUp(self);
}
else if (DisplayCash > Cash)
{
DisplayCash -= move;
Sound.PlayToPlayer(self.Owner, eva.CashTickDown);
playCashTickDown(self);
}
diff = Math.Abs(Ore - DisplayOre);
@@ -173,13 +177,35 @@ namespace OpenRA.Traits
if (DisplayOre < Ore)
{
DisplayOre += move;
Sound.PlayToPlayer(self.Owner, eva.CashTickUp);
playCashTickUp(self);
}
else if (DisplayOre > Ore)
{
DisplayOre -= move;
playCashTickDown(self);
}
}
public void playCashTickUp(Actor self)
{
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
if (Game.Settings.Sound.SoundCashTickType != SoundCashTicks.Disabled)
{
Sound.PlayToPlayer(self.Owner, eva.CashTickUp);
}
}
public void playCashTickDown(Actor self)
{
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
if (
Game.Settings.Sound.SoundCashTickType == SoundCashTicks.Extreme ||
(Game.Settings.Sound.SoundCashTickType == SoundCashTicks.Normal && tickermod == 0)
) {
Sound.PlayToPlayer(self.Owner, eva.CashTickDown);
}
}
}
}