您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

85 行
2.1 KiB

  1. using System;
  2. using SUISS.Core;
  3. using SUISS.Promo;
  4. using SUISSEngine;
  5. using UnityEngine;
  6. public class PromoPopupState : PopupBaseState
  7. {
  8. private void OnDestroy()
  9. {
  10. if (SingletonMonobehaviour<SparkSocGamesPopupScheduler>.IsAvailable)
  11. {
  12. SingletonMonobehaviour<SparkSocGamesPopupScheduler>.Instance.ShowPromoPopup -= this.TryShowPromoPopup;
  13. }
  14. }
  15. public override void Init()
  16. {
  17. base.Init();
  18. this.PreloadPromo();
  19. if (SingletonMonobehaviour<SparkSocGamesPopupScheduler>.IsAvailable)
  20. {
  21. SparkSocGamesPopupScheduler instance = SingletonMonobehaviour<SparkSocGamesPopupScheduler>.Instance;
  22. instance.TimeBetweenPromoPopup = TimeSpan.FromHours(1.0);
  23. instance.ShowPromoPopup += this.TryShowPromoPopup;
  24. }
  25. }
  26. public override void Enter(State oldState, bool openView)
  27. {
  28. base.Enter(oldState, openView);
  29. ((PromoPopupView)this.View).SetSparkSocGame(this._game);
  30. }
  31. public override void ClosePopup(Action callback, bool animate, bool synchronous)
  32. {
  33. base.ClosePopup(callback, animate, synchronous);
  34. this.PreloadPromo();
  35. }
  36. public void OpenPromoInStore()
  37. {
  38. if (this._game != null)
  39. {
  40. this._game.OpenInAppStore();
  41. }
  42. }
  43. private void TryShowPromoPopup()
  44. {
  45. if (this.IsPreloaded && Time.timeSinceLevelLoad > 60f && SingletonMonobehaviour<WorldMap>.IsAvailable && !SingletonMonobehaviour<WorldMap>.Instance.IsVisible && SingletonMonobehaviour<CIGGameState>.IsAvailable && SingletonMonobehaviour<CIGGameState>.Instance.Level >= 8)
  46. {
  47. SingletonMonobehaviour<PopupManager>.Instance.RequestPopup<PromoPopupState>(null);
  48. if (SingletonMonobehaviour<SparkSocGamesPopupScheduler>.IsAvailable)
  49. {
  50. SingletonMonobehaviour<SparkSocGamesPopupScheduler>.Instance.DidShowPromo();
  51. this._ssGames.DidShowPromo(this._game);
  52. }
  53. }
  54. }
  55. private void PreloadPromo()
  56. {
  57. this._game = null;
  58. this._ssGames.GetPromoItem(delegate(SparkSocGame promoGame)
  59. {
  60. this._game = promoGame;
  61. });
  62. }
  63. private bool IsPreloaded
  64. {
  65. get
  66. {
  67. return this._game != null;
  68. }
  69. }
  70. [SerializeField]
  71. private SparkSocGames _ssGames;
  72. private SparkSocGame _game;
  73. }