Example #1
0
 //Load all scriptableObjects from resources folder and Load their runtime states from the binary files
 private void LoadBusinessInfoAndSetupUI()
 {
     earnedOffline = new StdBigNumber(0);
     System.TimeSpan t = CapitalistTools.TimeTools.TimeSpentOffline();
     Object[]        b = Resources.LoadAll("Businesses/", typeof(BusinessInfo));
     if (b.Length > 0)
     {
         foreach (Object o in b) //For all businesses
         {
             BusinessInfo info = o as BusinessInfo;
             info.state = CapitalistTools.States.LoadBusinessState(info.name);
             if (info.state == null)
             {
                 info.Reset();
             }
             //if business is owned, calculate how much money earned while being offline
             if (info.state.currentTime > 0.0f && info.state.isOwned)
             {
                 int   timesLooped = 0;
                 float newTime     = 0.0f;
                 info.state.currentTime += (float)t.TotalSeconds;
                 if (info.state.hasManager)
                 {
                     newTime     = info.state.currentTime % info.state.revenueProgressBarTime;
                     timesLooped = (int)(info.state.currentTime / info.state.revenueProgressBarTime);
                 }
                 else if (info.state.hasManager == false)
                 {
                     if (info.state.currentTime > info.state.revenueProgressBarTime - 0.1f)
                     {
                         timesLooped = 1;
                         newTime     = 0.0f;
                     }
                     else
                     {
                         newTime = info.state.currentTime;
                     }
                 }
                 info.state.currentTime = newTime;
                 StdBigNumber earn = new StdBigNumber(info.GetCurrentRevenue());
                 earn          *= timesLooped;
                 earnedOffline += earn;
             }
             ui.AddBusinessToUI(info);
         }
     }
     money += earnedOffline;         //Add total offline earnings from all businesses
     ui.SortBusinessesByCost();      //Sort businesses by cost so the cheapest shows up at top (in UI panel)
 }
Example #2
0
    //Update specific Ui element
    public void UpdateRevenueText()
    {
        string currRev = info.GetCurrentRevenue();

        revenueMoneyText.text = CapitalistTools.MoneyTools.GetFormatedMoneyText(new BigNumber.StdBigNumber(currRev)) + " " + CapitalistTools.MoneyTools.GetScaleName(currRev);
    }