You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

124 lines
2.5 KiB

  1. using System;
  2. using System.Collections;
  3. using SUISSEngine;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace SUISS.Promo
  7. {
  8. public class SingleItemLoadingScreenController : MonoBehaviour
  9. {
  10. protected void Start()
  11. {
  12. this.Hide();
  13. }
  14. public void Initialise(string sparksocGameId, string localizedMoreGamesText)
  15. {
  16. this.moreGames.GetMoreGamesList(true, delegate(SparkSocGame[] items)
  17. {
  18. this.LoadedGames(items);
  19. }, false);
  20. this.MoreGamesText.text = localizedMoreGamesText;
  21. }
  22. public void Show(TextAnchor? preferredAnchor = null)
  23. {
  24. if (this._item != null && this._item.AppIcon != null)
  25. {
  26. this.root.SetActive(true);
  27. this.InitAnotherGameIcon(this._item);
  28. if (preferredAnchor != null)
  29. {
  30. this.thisGroup.childAlignment = preferredAnchor.Value;
  31. }
  32. else
  33. {
  34. int num = UnityEngine.Random.Range(0, 3);
  35. if (num != 0)
  36. {
  37. if (num != 1)
  38. {
  39. if (num == 2)
  40. {
  41. this.thisGroup.childAlignment = TextAnchor.LowerLeft;
  42. }
  43. }
  44. else
  45. {
  46. this.thisGroup.childAlignment = TextAnchor.MiddleLeft;
  47. }
  48. }
  49. else
  50. {
  51. this.thisGroup.childAlignment = TextAnchor.UpperLeft;
  52. }
  53. }
  54. }
  55. else
  56. {
  57. base.StartCoroutine(this.WaitForIconDownload(preferredAnchor));
  58. }
  59. }
  60. private void LoadedGames(SparkSocGame[] items)
  61. {
  62. foreach (SparkSocGame sparkSocGame in items)
  63. {
  64. if (!sparkSocGame.IsInstalled)
  65. {
  66. this.moreGames.DownloadGameIcon(sparkSocGame, delegate(SparkSocGame i)
  67. {
  68. this._item = i;
  69. });
  70. return;
  71. }
  72. }
  73. if (items.Length > 0)
  74. {
  75. this.moreGames.DownloadGameIcon(items[0], delegate(SparkSocGame i)
  76. {
  77. this._item = i;
  78. });
  79. }
  80. }
  81. private IEnumerator WaitForIconDownload(TextAnchor? preferredAnchor)
  82. {
  83. yield return this._item != null && this._item.AppIcon != null;
  84. this.Show(preferredAnchor);
  85. yield break;
  86. }
  87. private void Hide()
  88. {
  89. this.root.SetActive(false);
  90. }
  91. private void InitAnotherGameIcon(SparkSocGame item)
  92. {
  93. this.anotherGame.Init(item);
  94. }
  95. [SerializeField]
  96. protected GameObject root;
  97. [SerializeField]
  98. private RectTransform rootTransform;
  99. [SerializeField]
  100. private Text MoreGamesText;
  101. [SerializeField]
  102. private MoreGamesIcon anotherGame;
  103. [SerializeField]
  104. private VerticalLayoutGroup thisGroup;
  105. [SerializeField]
  106. protected SparkSocGames moreGames;
  107. private SparkSocGame _item;
  108. }
  109. }