Assembly-CSharp\DailyManager.cs Assembly-CSharp\DailyManager.cs
using System; using System;
using TBE.Localization; using TBE.Localization;
   
public class DailyManager public class DailyManager
{ {
   private DailyManager()    private DailyManager()
   {    {
       this.lastDaily = 0;        this.lastDaily = 0;
       this.firstDailyAdded = false;        this.firstDailyAdded = false;
       this.canShowDaily = true;        this.canShowDaily = true;
   }    }
   
   public static DailyManager Instance    public static DailyManager Instance
   {    {
       get        get
       {        {
           if (DailyManager.instance == null)            if (DailyManager.instance == null)
           {            {
               DailyManager.instance = new DailyManager();                DailyManager.instance = new DailyManager();
           }            }
           return DailyManager.instance;            return DailyManager.instance;
       }        }
   }    }
   
   private void SaveLastDaily()    private void SaveLastDaily()
   {    {
       if (this.lastDaily > 19)        if (this.lastDaily > 19)
       {        {
           PlayerPrefsController.SetInt("LastDaily", 0);            PlayerPrefsController.SetInt("LastDaily", 0);
       }        }
       else        else
       {        {
           PlayerPrefsController.SetInt("LastDaily", this.lastDaily);            PlayerPrefsController.SetInt("LastDaily", this.lastDaily);
       }        }
   }    }
   
   private void LoadLastDaily()    private void LoadLastDaily()
   {    {
       this.lastDaily = PlayerPrefsController.GetInt("LastDaily", this.lastDaily);        this.lastDaily = PlayerPrefsController.GetInt("LastDaily", this.lastDaily);
   }    }
   
   private void SaveLastDailyTime()    private void SaveLastDailyTime()
   {    {
       DateTime dateTime = PlayfabManager.Instance.ServerTime.Add(new TimeSpan(-12, 0, 0));        DateTime dateTime = PlayfabManager.Instance.ServerTime.Add(new TimeSpan(-12, 0, 0));
       this.lastDailyTime = dateTime;        this.lastDailyTime = dateTime;
       PlayerPrefsController.SetString("LastDailyTime", dateTime.ToString());        PlayerPrefsController.SetString("LastDailyTime", dateTime.ToString());
   }    }
   
   private void LoadLastDailyTime()    private void LoadLastDailyTime()
   {    {
       string @string = PlayerPrefsController.GetString("LastDailyTime", string.Empty);        string @string = PlayerPrefsController.GetString("LastDailyTime", string.Empty);
       if (string.IsNullOrEmpty(@string))        if (string.IsNullOrEmpty(@string))
       {        {
           this.lastDailyTime = PlayfabManager.Instance.ServerTime - new TimeSpan(7, 0, 0, 0);            this.lastDailyTime = PlayfabManager.Instance.ServerTime - new TimeSpan(7, 0, 0, 0);
       }        }
       else        else
       {        {
           this.lastDailyTime = DateTime.Parse(@string);            this.lastDailyTime = DateTime.Parse(@string);
       }        }
   }    }
   
   public void Init()    public void Init()
   {    {
       DailyContainer.Instance.Load();        DailyContainer.Instance.Load();
       this.LoadLastDaily();        this.LoadLastDaily();
   }    }
   
   public int GetLastDaily()    public int GetLastDaily()
   {    {
       return this.lastDaily;        return this.lastDaily;
   }    }
   
   public int GetActiveDaily()    public int GetActiveDaily()
   {    {
       this.LoadLastDailyTime();        this.LoadLastDailyTime();
       if (PlayfabManager.Instance.ServerTime.Add(new TimeSpan(-12, 0, 0)).Date > this.lastDailyTime.Date)        if (PlayfabManager.Instance.ServerTime.Add(new TimeSpan(-12, 0, 0)).Date > this.lastDailyTime.Date)
       {        {
           return this.lastDaily + 1;            return this.lastDaily + 1;
       }        }
.        return 0;        return this.lastDaily;
   }    }
   
   public bool NewDaily()    public bool NewDaily()
   {    {
       return this.GetActiveDaily() != 0;        return this.GetActiveDaily() != 0;
   }    }
   
   public bool CanCollectDaily()    public bool CanCollectDaily()
   {    {
.        return PlayfabManager.Instance.ServerTime.Add(new TimeSpan(-12, 0, 0)).Date > this.lastDailyTime.Date;        return true;
   }    }
   
   public void CollectDaily()    public void CollectDaily()
   {    {
       if (this.CanCollectDaily())        if (this.CanCollectDaily())
       {        {
.            this.lastDaily++;             if (PlayfabManager.Instance.ServerTime.Add(new TimeSpan(12, 0, 0)).Date > this.lastDailyTime.Date) 
             { 
                 this.lastDaily++; 
             } 
           this.SaveLastDaily();            this.SaveLastDaily();
           this.SaveLastDailyTime();            this.SaveLastDailyTime();
           this.AddReward();            this.AddReward();
       }        }
   }    }
   
   private void AddCards(int count, BoxType type)    private void AddCards(int count, BoxType type)
   {    {
       for (int i = 0; i < count; i++)        for (int i = 0; i < count; i++)
       {        {
           BoxManager.Instance.AddCardsToAlbums(BoxManager.Instance.RandCardsFromBox(type));            BoxManager.Instance.AddCardsToAlbums(BoxManager.Instance.RandCardsFromBox(type));
       }        }
   }    }
   
   private void AddReward()    private void AddReward()
   {    {
       DailyRewardType rewardType = DailyContainer.Instance.GetRewardType(this.lastDaily);        DailyRewardType rewardType = DailyContainer.Instance.GetRewardType(this.lastDaily);
       float reward = DailyContainer.Instance.GetReward(this.lastDaily);        float reward = DailyContainer.Instance.GetReward(this.lastDaily);
       switch (rewardType)        switch (rewardType)
       {        {
       case DailyRewardType.FirstSoft:        case DailyRewardType.FirstSoft:
       {        {
           PlayerAmountController.Instance.forceUpdate = true;            PlayerAmountController.Instance.forceUpdate = true;
           BigNumber left;            BigNumber left;
           if (OpponentsController.Instance.opponents[0].opponent.type == OpponentType.Boss)            if (OpponentsController.Instance.opponents[0].opponent.type == OpponentType.Boss)
           {            {
               left = global::GameManager.RewardForOpponent(StagesManager.GetLastDefeatedOpponent());                left = global::GameManager.RewardForOpponent(StagesManager.GetLastDefeatedOpponent());
           }            }
           else            else
           {            {
               left = global::GameManager.RewardForOpponent(OpponentsController.Instance.opponents[0].opponent);                left = global::GameManager.RewardForOpponent(OpponentsController.Instance.opponents[0].opponent);
           }            }
           left *= reward;            left *= reward;
           PlayerAmountController.Instance.SoftAmount += left.FloorRoundedValue();            PlayerAmountController.Instance.SoftAmount += left.FloorRoundedValue();
           break;            break;
       }        }
       case DailyRewardType.Hard:        case DailyRewardType.Hard:
           PlayerAmountController.Instance.PremiumAmount += (double)reward;            PlayerAmountController.Instance.PremiumAmount += (double)reward;
           break;            break;
       case DailyRewardType.CardPack1:        case DailyRewardType.CardPack1:
           GameController.Instance.RotateCarsds(BoxType.Iron, true);            GameController.Instance.RotateCarsds(BoxType.Iron, true);
           break;            break;
       case DailyRewardType.RandomBlueprint:        case DailyRewardType.RandomBlueprint:
           for (int i = 0; i < (int)reward; i++)            for (int i = 0; i < (int)reward; i++)
           {            {
               CarBlueprintsController.Instance.RandomBlueprintReward();                CarBlueprintsController.Instance.RandomBlueprintReward();
           }            }
           break;            break;
       case DailyRewardType.CardPack2:        case DailyRewardType.CardPack2:
           GameController.Instance.RotateCarsds(BoxType.Steel, true);            GameController.Instance.RotateCarsds(BoxType.Steel, true);
           break;            break;
       case DailyRewardType.CardPack3:        case DailyRewardType.CardPack3:
           GameController.Instance.RotateCarsds(BoxType.Golden, true);            GameController.Instance.RotateCarsds(BoxType.Golden, true);
           break;            break;
       case DailyRewardType.CardPack4:        case DailyRewardType.CardPack4:
           GameController.Instance.RotateCarsds(BoxType.Diamond, true);            GameController.Instance.RotateCarsds(BoxType.Diamond, true);
           break;            break;
       }        }
   }    }
   
   public void SetNotification()    public void SetNotification()
   {    {
       DateTime date = PlayfabManager.Instance.ServerTime;        DateTime date = PlayfabManager.Instance.ServerTime;
       string text = LocalizationManager.GetText("notifications_daily");        string text = LocalizationManager.GetText("notifications_daily");
       string text2 = LocalizationManager.GetText("notifications_title_daily");        string text2 = LocalizationManager.GetText("notifications_title_daily");
       if (date.TimeOfDay <= new TimeSpan(12, 0, 0))        if (date.TimeOfDay <= new TimeSpan(12, 0, 0))
       {        {
           if (date.TimeOfDay >= new TimeSpan(11, 30, 0))            if (date.TimeOfDay >= new TimeSpan(11, 30, 0))
           {            {
               date = PlayfabManager.Instance.ServerTime.AddMinutes(30.0);                date = PlayfabManager.Instance.ServerTime.AddMinutes(30.0);
               NotificationManager.Instance.CreateNotification(date, text2, text, 2);                NotificationManager.Instance.CreateNotification(date, text2, text, 2);
           }            }
           else            else
           {            {
               date = date.Date + new TimeSpan(12, 0, 0);                date = date.Date + new TimeSpan(12, 0, 0);
               NotificationManager.Instance.CreateNotification(date, text2, text, 2);                NotificationManager.Instance.CreateNotification(date, text2, text, 2);
           }            }
       }        }
       else if (this.CanCollectDaily())        else if (this.CanCollectDaily())
       {        {
           date = PlayfabManager.Instance.ServerTime.AddMinutes(30.0);            date = PlayfabManager.Instance.ServerTime.AddMinutes(30.0);
           NotificationManager.Instance.CreateNotification(date, text2, text, 2);            NotificationManager.Instance.CreateNotification(date, text2, text, 2);
       }        }
       date = date.Date + new TimeSpan(1, 12, 0, 0);        date = date.Date + new TimeSpan(1, 12, 0, 0);
       NotificationManager.Instance.CreateNotification(date, text2, text, 2);        NotificationManager.Instance.CreateNotification(date, text2, text, 2);
   }    }
   
   private static DailyManager instance;    private static DailyManager instance;
   
   private const string lastDailyTimeLabel = "LastDailyTime";    private const string lastDailyTimeLabel = "LastDailyTime";
   
   private DateTime lastDailyTime;    private DateTime lastDailyTime;
   
   private const string lastDailyLabel = "LastDaily";    private const string lastDailyLabel = "LastDaily";
   
   private int lastDaily;    private int lastDaily;
   
   private bool firstDailyAdded;    private bool firstDailyAdded;
   
   private const string notifId = "notifications_daily";    private const string notifId = "notifications_daily";
   
   private const string NotifTitleId = "notifications_title_daily";    private const string NotifTitleId = "notifications_title_daily";
   
   public bool canShowDaily;    public bool canShowDaily;
} }