AdditionalScenario.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections;
  3. using MaidStatus;
  4. using UnityEngine;
  5. using wf;
  6. public class AdditionalScenario : MonoBehaviour
  7. {
  8. public void Init(string label)
  9. {
  10. this.m_MyPanel = base.GetComponent<UIPanel>();
  11. this.m_JumpLabel = label;
  12. base.StartCoroutine(this.Fade(true));
  13. ScenarioData[] addedScenario = GameMain.Instance.ScenarioSelectMgr.AddedScenario;
  14. if (addedScenario.Length <= 0)
  15. {
  16. Debug.Log("昨日から追加されたシナリオはもうありません");
  17. UnityEngine.Object.Destroy(base.gameObject);
  18. return;
  19. }
  20. this.m_FewVer.SetActive(false);
  21. this.m_ManyVer.SetActive(false);
  22. int num = 0;
  23. foreach (ScenarioData scenarioData in addedScenario)
  24. {
  25. if (!scenarioData.IsFixedMaid)
  26. {
  27. if (scenarioData.EventMaidCount > 0)
  28. {
  29. foreach (Maid maid in scenarioData.GetEventMaidList())
  30. {
  31. num++;
  32. }
  33. }
  34. else
  35. {
  36. num++;
  37. }
  38. }
  39. else if (!string.IsNullOrEmpty(scenarioData.Notification))
  40. {
  41. num++;
  42. }
  43. else if (scenarioData.EventMaidCount == 1)
  44. {
  45. if (scenarioData.GetEventMaid(0).status.heroineType == HeroineType.Sub)
  46. {
  47. num++;
  48. }
  49. else
  50. {
  51. num++;
  52. }
  53. }
  54. else
  55. {
  56. num++;
  57. }
  58. }
  59. GameObject gameObject = (num <= this.m_ManyModeCount) ? this.m_FewVer : this.m_ManyVer;
  60. gameObject.SetActive(true);
  61. this.m_UIScroll = gameObject.transform.Find("Contents").GetComponent<UIScrollView>();
  62. this.m_UIGrid = gameObject.transform.Find("Contents/Grid").GetComponent<UIGrid>();
  63. Action<string, string> action = delegate(string title, string chara)
  64. {
  65. GameObject gameObject2 = Utility.CreatePrefab(this.m_UIGrid.gameObject, "SceneScenarioSelect/Prefab/Additional", true);
  66. gameObject2.transform.Find("Title").GetComponent<UILabel>().text = title;
  67. gameObject2.transform.Find("Chara").GetComponent<UILabel>().text = chara;
  68. };
  69. foreach (ScenarioData scenarioData2 in addedScenario)
  70. {
  71. if (!scenarioData2.IsFixedMaid)
  72. {
  73. if (scenarioData2.EventMaidCount > 0)
  74. {
  75. foreach (Maid maid2 in scenarioData2.GetEventMaidList())
  76. {
  77. if (string.IsNullOrEmpty(scenarioData2.Notification))
  78. {
  79. action(scenarioData2.NotLineTitle, (!maid2.status.isFirstNameCall) ? maid2.status.lastName : maid2.status.firstName);
  80. }
  81. else
  82. {
  83. action(scenarioData2.NotLineTitle, scenarioData2.Notification);
  84. }
  85. }
  86. }
  87. else
  88. {
  89. action(scenarioData2.NotLineTitle, scenarioData2.Notification);
  90. }
  91. }
  92. else if (!string.IsNullOrEmpty(scenarioData2.Notification))
  93. {
  94. action(scenarioData2.NotLineTitle, scenarioData2.Notification);
  95. }
  96. else if (scenarioData2.EventMaidCount == 1)
  97. {
  98. if (scenarioData2.GetEventMaid(0).status.heroineType == HeroineType.Sub)
  99. {
  100. action(scenarioData2.NotLineTitle, "NPC");
  101. }
  102. else
  103. {
  104. action(scenarioData2.NotLineTitle, GameMain.Instance.ScenarioSelectMgr.GetConvertPersonal(scenarioData2.GetEventMaid(0)));
  105. }
  106. }
  107. else
  108. {
  109. action(scenarioData2.NotLineTitle, this.m_IdolNotice);
  110. }
  111. }
  112. if (this.m_UIGrid)
  113. {
  114. this.m_UIGrid.repositionNow = true;
  115. }
  116. if (this.m_UIScroll)
  117. {
  118. this.m_UIScroll.ResetPosition();
  119. }
  120. EventDelegate.Add(this.m_MyButton.onClick, new EventDelegate.Callback(this.FadeOut));
  121. }
  122. private void FadeOut()
  123. {
  124. if (this.m_MyPanel.alpha > 0.9f)
  125. {
  126. base.StartCoroutine(this.Fade(false));
  127. }
  128. }
  129. private IEnumerator Fade(bool is_fadein)
  130. {
  131. float timer = 0f;
  132. for (;;)
  133. {
  134. float rate = Mathf.Sin(Mathf.Clamp01(timer / this.m_FadeTime) * 90f * 0.0174532924f);
  135. if (!is_fadein)
  136. {
  137. rate = 1f - rate;
  138. }
  139. this.m_MyPanel.alpha = rate;
  140. timer += Time.deltaTime;
  141. if (timer >= this.m_FadeTime)
  142. {
  143. break;
  144. }
  145. yield return null;
  146. }
  147. if (!is_fadein)
  148. {
  149. UnityEngine.Object.Destroy(base.gameObject);
  150. if (!string.IsNullOrEmpty(this.m_JumpLabel))
  151. {
  152. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_JumpLabel);
  153. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  154. }
  155. }
  156. yield break;
  157. yield break;
  158. }
  159. [SerializeField]
  160. private float m_FadeTime = 0.5f;
  161. [SerializeField]
  162. private UIButton m_MyButton;
  163. [SerializeField]
  164. private GameObject m_FewVer;
  165. [SerializeField]
  166. private GameObject m_ManyVer;
  167. [SerializeField]
  168. [Header("この数以上で多数表示")]
  169. private int m_ManyModeCount = 8;
  170. private UIPanel m_MyPanel;
  171. private UIScrollView m_UIScroll;
  172. private UIGrid m_UIGrid;
  173. [SerializeField]
  174. [Header("固定3人イベントのときの呼称")]
  175. private string m_IdolNotice = "アイドルルート";
  176. private string m_JumpLabel = string.Empty;
  177. }