changed displaycash behavior

This commit is contained in:
Chris Forbes
2010-01-27 22:24:47 +13:00
parent 19fadc3e0a
commit ddb39f2074

View File

@@ -120,7 +120,8 @@ namespace OpenRa
return true; return true;
} }
const int displayCashDeltaPerFrame = 50; const float displayCashFracPerFrame = .07f;
const int displayCashDeltaPerFrame = 37;
public void Tick() public void Tick()
{ {
@@ -129,17 +130,18 @@ namespace OpenRa
Shroud.Tick( World ); Shroud.Tick( World );
var totalMoney = Cash + Ore; var totalMoney = Cash + Ore;
var diff = Math.Abs(totalMoney - DisplayCash);
var move = Math.Min(Math.Max((int)(diff * displayCashFracPerFrame),
displayCashDeltaPerFrame), diff);
if (DisplayCash < totalMoney) if (DisplayCash < totalMoney)
{ {
DisplayCash += Math.Min(displayCashDeltaPerFrame, DisplayCash += move;
totalMoney - DisplayCash);
Sound.PlayToPlayer(this, "cashup1.aud"); Sound.PlayToPlayer(this, "cashup1.aud");
} }
else if (DisplayCash > totalMoney) else if (DisplayCash > totalMoney)
{ {
DisplayCash -= Math.Min(displayCashDeltaPerFrame, DisplayCash -= move;
DisplayCash - totalMoney);
Sound.PlayToPlayer(this, "cashdn1.aud"); Sound.PlayToPlayer(this, "cashdn1.aud");
} }
} }