Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. private ulong CalculateBonus()
  2.     {
  3.         ulong result = 0;
  4.         // "Доход в минуту"
  5.         ulong sum = 0;
  6.         var coffeeFactory = FindObjectOfType<CoffeeFactory>();
  7.         foreach (var machine in coffeeFactory.coffeeMachines)
  8.         {
  9.             if (machine.Value.state == Assets.Scripts.Model.CoffeeMachineState.Opened)
  10.             {
  11.                 sum += 5 * (ulong)machine.Value.Revenue * (ulong)(((float)(machine.Value.coffeeMachine.conveyorLevel + 99) / 100) * ((float)(machine.Value.coffeeMachine.productionLevel + 99) / 100));
  12.             }
  13.         }
  14.         long ticks = DateTime.Now.Ticks - GameController.Instance.LastPlay.Ticks;
  15.         var timeSpan = new TimeSpan(ticks);
  16.         // Время оффлайн
  17.         var time = Mathf.Clamp(Mathf.Sqrt((float)timeSpan.TotalMinutes), 1, 60 * 24);
  18.         result += (ulong)time * sum;
  19.         if (GameController.Instance.RevenueBoostEnd > GameController.Instance.LastPlay)
  20.         {
  21.             ticks = GameController.Instance.RevenueBoostEnd.Ticks - GameController.Instance.LastPlay.Ticks;
  22.             timeSpan = new TimeSpan(ticks);
  23.             time = (float)timeSpan.TotalMinutes;
  24.             result += (ulong)time * sum;
  25.         }
  26.         if (GameController.Instance.ProductionBoostEnd > GameController.Instance.LastPlay)
  27.         {
  28.             ticks = GameController.Instance.ProductionBoostEnd.Ticks - GameController.Instance.LastPlay.Ticks;
  29.             timeSpan = new TimeSpan(ticks);
  30.             time = (float)timeSpan.TotalMinutes;
  31.             result += (ulong)time * sum;
  32.         }
  33.         return result;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement