예제 #1
0
 public string GetCurrentRevenue()   //Get revenue multiplied by bonus multiplier
 {
     if (state.currentRevenueMultiplier == 0.0f)
     {
         return(state.currentRevenue);
     }
     BigNumber.StdBigNumber currRev = new BigNumber.StdBigNumber(state.currentRevenue);
     currRev *= (int)state.currentRevenueMultiplier;
     return(currRev.ToString());
 }
예제 #2
0
    void Invest()
    {
        if (GameManager.instance.HasEnoughMoney(info.state.currentInvestCost) && info.state.currentUnlock <= info.unlocks.Count - 1 || info.state.currentLevel == 0)
        {
            if (info.state.currentLevel < info.unlocks[info.unlocks.Count - 1].levelToUnlock)
            {
                //Add level
                info.state.currentLevel++;

                //Everytime you invest increase revenue
                BigNumber.StdBigNumber currentRev = new BigNumber.StdBigNumber(info.state.currentRevenue);
                BigNumber.StdBigNumber revToAdd   = new BigNumber.StdBigNumber(info.startingRevenue);
                currentRev += revToAdd;
                info.state.currentRevenue = currentRev.ToString();
                UpdateRevenueText();

                GameManager.instance.audioManager.PlaySound(SoundType.INVEST);

                if (info.state.currentLevel >= info.unlocks[info.state.currentUnlock].levelToUnlock && info.state.currentLevel != 0 && info.state.currentUnlock < info.unlocks.Count - 1)
                {
                    info.state.currentUnlock++;
                    //Every unlock the revenue progress Bar Time shortens by a multiplier
                    info.state.revenueProgressBarTime /= info.unlocks[info.state.currentUnlock].timeMultiplier;
                    GameManager.instance.audioManager.PlaySound(SoundType.UNLOCK);

                    //Create new UI Element for current unlock
                    currentUnlockUIElement.transform.SetParent(null, false);
                    Destroy(currentUnlockUIElement.gameObject);
                    currentUnlockUIElement = null;
                    GameManager.instance.ui.AddUnlockToUI(this);
                }
                if (info.state.currentLevel > 1)
                {
                    GameManager.instance.LoseMoney(info.state.currentInvestCost);
                }

                //also recalculate invest cost
                BigNumber.StdBigNumber startInvest = new BigNumber.StdBigNumber(info.startingInvestCost);
                BigNumber.StdBigNumber newInvest   = new BigNumber.StdBigNumber();

                //THIS CAUSED A BUG IN v1.0
                //newInvest += (int)Mathf.FloorToInt(startInvest * Mathf.Pow(info.coefficient, info.state.currentLevel));
                newInvest += (startInvest * (Mathf.FloorToInt(Mathf.Pow(info.coefficient, info.state.currentLevel) * 100))) / 100;

                info.state.currentInvestCost = newInvest.ToString();

                //Emit money particle
                GameManager.instance.ParticleAt(0, icon.transform.position);
                UpdateInvestButton();
                UpdateCurrentLevelUI();
            }
        }
    }