From ddb39f2074fe40d182a0bd5ca21bd0e4cc37c326 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 27 Jan 2010 22:24:47 +1300 Subject: [PATCH] changed displaycash behavior --- OpenRa.Game/Player.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 5bc3d9a6a5..fc31c09936 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -120,7 +120,8 @@ namespace OpenRa return true; } - const int displayCashDeltaPerFrame = 50; + const float displayCashFracPerFrame = .07f; + const int displayCashDeltaPerFrame = 37; public void Tick() { @@ -129,17 +130,18 @@ namespace OpenRa Shroud.Tick( World ); var totalMoney = Cash + Ore; + var diff = Math.Abs(totalMoney - DisplayCash); + var move = Math.Min(Math.Max((int)(diff * displayCashFracPerFrame), + displayCashDeltaPerFrame), diff); if (DisplayCash < totalMoney) { - DisplayCash += Math.Min(displayCashDeltaPerFrame, - totalMoney - DisplayCash); + DisplayCash += move; Sound.PlayToPlayer(this, "cashup1.aud"); } else if (DisplayCash > totalMoney) { - DisplayCash -= Math.Min(displayCashDeltaPerFrame, - DisplayCash - totalMoney); + DisplayCash -= move; Sound.PlayToPlayer(this, "cashdn1.aud"); } }