/* have action separate for testing */ public void GetCoin(PlayerScript player) { // perform adjustment. Removing too many coins will remove all coins. var coinAdjust = coinsInBundle; if (coinsInBundle < 0) { coinAdjust = Math.Max(coinAdjust, -player.coins); } player.AdjustCoins(coinAdjust); }