public void Restart() { int difference = currentScrap - startScrapAmount; difference *= -1; int index = (int)Mathf.Sign(difference); ScrapOption option = (ScrapOption)index; difference = Mathf.Abs(difference); AddOrWithdrawScrap(difference, option); }
public bool AddOrWithdrawScrap(int amount, ScrapOption option) { bool success = false; amount = Mathf.Abs(amount); if (amount > 0) { if (option == ScrapOption.Add) { if (currentScrap < maxScrap) { currentScrap += amount; if (currentScrap > maxScrap) { currentScrap = maxScrap; } success = true; } } else { if (currentScrap > 0) { currentScrap -= amount; if (currentScrap < 0) { currentScrap = 0; } success = true; } } } UpdateScrapAmount(); TowerManager.singleTM.CheckPricesSetInteractableAndNot(); return(success); }