選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

155 行
4.2 KiB

  1. using System;
  2. using CIG;
  3. using CIG.Extensions;
  4. using CIG.Translation;
  5. using CIGEnums;
  6. using SUISS.Core;
  7. using Tweening;
  8. using UnityEngine;
  9. using UnityEngine.UI;
  10. public class DailyRewardPopupView : PopupBaseView
  11. {
  12. protected void OnDestroy()
  13. {
  14. this._valueCounterDisplay.FinishedTweeningEvent -= this.OnTodayItemCountDownFinished;
  15. }
  16. public void UpdateView(DailyRewardsManager.Streak streak, int currentIndex)
  17. {
  18. this.ClearItems();
  19. this._collectButton.interactable = true;
  20. this._dailyRewardItems = new DailyRewardItem[streak.TotalDays];
  21. int i = 0;
  22. int num = this._dailyRewardItems.Length;
  23. while (i < num)
  24. {
  25. DailyRewardItem dailyRewardItem = UnityEngine.Object.Instantiate<DailyRewardItem>(this._dailyRewardItemPrefab, this._dailyRewardItemsHolder);
  26. this._dailyRewardItems[i] = dailyRewardItem;
  27. DailyReward dailyReward = streak.GetDailyReward(i);
  28. dailyRewardItem.Display(dailyReward, i, currentIndex);
  29. if (i == currentIndex)
  30. {
  31. this._todaysReward = dailyReward;
  32. ILocalizedString localizedString = Localization.Integer(this._todaysReward.Value);
  33. if (this._todaysReward.Currency == "LevelUp")
  34. {
  35. localizedString = Localization.Format(Localization.Key("iap.title.levels$n"), new ILocalizedString[]
  36. {
  37. localizedString
  38. });
  39. this._todayRewardValueText.gameObject.SetActive(true);
  40. this._todayRewardValueText.LocalizedString = dailyRewardItem.GetCurrentValueDisplay();
  41. }
  42. else
  43. {
  44. this._todayRewardValueText.gameObject.SetActive(false);
  45. }
  46. this._todayValueText.LocalizedString = localizedString;
  47. this._todayRewardDisplayImage.sprite = dailyRewardItem.GetCurrencyDisplaySprite();
  48. this._todayRewardIcon.sprite = SingletonMonobehaviour<UISpriteAssetCollection>.Instance.GetAsset(this._todaysReward.Currency);
  49. }
  50. i++;
  51. }
  52. }
  53. public void Init(object _rewardCurrencySourceObject)
  54. {
  55. this._rewardCurrencyAnimationSource.Init(_rewardCurrencySourceObject);
  56. }
  57. public void Deinit()
  58. {
  59. this._rewardCurrencyAnimationSource.Deinit();
  60. }
  61. public override void Close()
  62. {
  63. this.ClearItems();
  64. base.Close();
  65. }
  66. public void OnCollectClicked()
  67. {
  68. if (this._collectButton.interactable)
  69. {
  70. this._collectButton.interactable = false;
  71. if (this._todaysReward != null && this._todaysReward.Currency != "LevelUp")
  72. {
  73. this._valueCounterDisplay.FinishedTweeningEvent += this.OnTodayItemCountDownFinished;
  74. this._valueCounterDisplay.PlayValueCounter(this._todaysReward.Value, 0m);
  75. }
  76. else
  77. {
  78. this.OnTodayItemCountDownFinished();
  79. }
  80. SingletonMonobehaviour<CIGAudioManager>.Instance.PlayClip(Clip.Victory);
  81. }
  82. }
  83. private void ClosePopup()
  84. {
  85. base.PopupState.ClosePopup();
  86. }
  87. private void ClearItems()
  88. {
  89. if (this._dailyRewardItems != null)
  90. {
  91. int i = 0;
  92. int num = this._dailyRewardItems.Length;
  93. while (i < num)
  94. {
  95. UnityEngine.Object.Destroy(this._dailyRewardItems[i].gameObject);
  96. i++;
  97. }
  98. }
  99. this._dailyRewardItems = null;
  100. }
  101. private void OnTodayItemCountDownFinished()
  102. {
  103. this._valueCounterDisplay.FinishedTweeningEvent -= this.OnTodayItemCountDownFinished;
  104. ((DailyRewardPopupState)this.State).Collect();
  105. this._rewardIconClaimedTweener.Play();
  106. this.Invoke(new Action(base.PopupState.ClosePopup), 1f, false);
  107. }
  108. [Header("Today Reward")]
  109. [SerializeField]
  110. private LocalizedText _todayValueText;
  111. [SerializeField]
  112. private Image _todayRewardIcon;
  113. [SerializeField]
  114. private LocalizedText _todayRewardValueText;
  115. [SerializeField]
  116. private Image _todayRewardDisplayImage;
  117. [SerializeField]
  118. private ValueCounterDisplay _valueCounterDisplay;
  119. [SerializeField]
  120. private CurrencyAnimationSource _rewardCurrencyAnimationSource;
  121. [SerializeField]
  122. private Tweener _rewardIconClaimedTweener;
  123. [Header("Day Reward Items")]
  124. [SerializeField]
  125. private DailyRewardItem _dailyRewardItemPrefab;
  126. [SerializeField]
  127. private RectTransform _dailyRewardItemsHolder;
  128. [Header("Lower Section")]
  129. [SerializeField]
  130. private Button _collectButton;
  131. private DailyRewardItem[] _dailyRewardItems = new DailyRewardItem[0];
  132. private DailyReward _todaysReward;
  133. }