예제 #1
0
        private IEnumerator produce()
        {
            while (productionTimeProgress < productionTime)
            {
                productionTimeProgress += Time.deltaTime;
                if (productionTimeProgress > productionTime)
                {
                    productionTimeProgress = productionTime;
                }

                float normalizedProductionTimeProgress = ClickerMath.Map(productionTimeProgress, 0f, productionTime, 0f, 1f);
                productionSlider.value = normalizedProductionTimeProgress;

                float timeLeft = productionTime - productionTimeProgress;
                timeLeftText.text = timeLeft.ToString("F2") + " seconds";
                if (timeLeft <= Mathf.Epsilon)
                {
                    timeLeftText.text = "";
                }

                yield return(new WaitForEndOfFrame());
            }

            //Reseting production for next call
            productionSlider.value = 0f;
            productionTimeProgress = 0f;
            productionCoroutine    = null;

            int moneyToMake = Mathf.RoundToInt((float)(productBaseIncome) * (float)(productAmount) * productMultiplier);

            MoneyManagger.GenerateProductIncome(moneyToMake);
        }
예제 #2
0
        public void IncreaseAmountOfProduct()
        {
            BigInteger cost              = productPrice * purchaseAmount;
            bool       enoughMoney       = MoneyManagger.totalMoney >= cost;
            BigInteger purchasableAmount = MoneyManagger.totalMoney / productPrice;

            if (!enoughMoney)
            {
                MoneyManagger.SubtractFromMoney(purchasableAmount);
                productAmount += purchasableAmount;
            }
            else
            {
                MoneyManagger.SubtractFromMoney(productPrice * purchaseAmount);
                productAmount += purchaseAmount;
            }

            productAmountText.text = productAmount.ToString();
        }