AdditionalScenario.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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, string, string> action = delegate(string title, string chara, string titleTerm, string charaTerm)
  64. {
  65. GameObject gameObject2 = Utility.CreatePrefab(this.m_UIGrid.gameObject, "SceneScenarioSelect/Prefab/Additional", true);
  66. UILabel component = gameObject2.transform.Find("Title").GetComponent<UILabel>();
  67. UILabel component2 = gameObject2.transform.Find("Chara").GetComponent<UILabel>();
  68. component.text = title;
  69. component2.text = chara;
  70. Utility.SetLocalizeTerm(component, titleTerm);
  71. Utility.SetLocalizeTerm(component2, charaTerm);
  72. };
  73. foreach (ScenarioData scenarioData2 in addedScenario)
  74. {
  75. string notLineTitle = scenarioData2.NotLineTitle;
  76. string titleTerm2 = scenarioData2.TitleTerm;
  77. string notification = scenarioData2.Notification;
  78. string notificationTerm = scenarioData2.NotificationTerm;
  79. if (!scenarioData2.IsFixedMaid)
  80. {
  81. if (scenarioData2.EventMaidCount > 0)
  82. {
  83. foreach (Maid maid2 in scenarioData2.GetEventMaidList())
  84. {
  85. if (string.IsNullOrEmpty(notification))
  86. {
  87. action(notLineTitle, (!maid2.status.isFirstNameCall) ? maid2.status.lastName : maid2.status.firstName, titleTerm2, string.Empty);
  88. }
  89. else
  90. {
  91. action(notLineTitle, notification, titleTerm2, notificationTerm);
  92. }
  93. }
  94. }
  95. else
  96. {
  97. action(notLineTitle, notification, titleTerm2, notificationTerm);
  98. }
  99. }
  100. else if (!string.IsNullOrEmpty(notification))
  101. {
  102. action(notLineTitle, notification, titleTerm2, notificationTerm);
  103. }
  104. else if (scenarioData2.EventMaidCount == 1)
  105. {
  106. if (scenarioData2.GetEventMaid(0).status.heroineType == HeroineType.Sub)
  107. {
  108. action(notLineTitle, "NPC", titleTerm2, "SceneScenarioSelect/通知時表記/NPC");
  109. }
  110. else
  111. {
  112. action(notLineTitle, GameMain.Instance.ScenarioSelectMgr.GetConvertPersonal(scenarioData2.GetEventMaid(0)), titleTerm2, GameMain.Instance.ScenarioSelectMgr.GetConvertPersonalTerm(scenarioData2.GetEventMaid(0)));
  113. }
  114. }
  115. else
  116. {
  117. action(notLineTitle, this.m_IdolNotice, titleTerm2, "SceneScenarioSelect/通知時表記/" + this.m_IdolNotice);
  118. }
  119. }
  120. if (this.m_UIGrid)
  121. {
  122. this.m_UIGrid.repositionNow = true;
  123. }
  124. if (this.m_UIScroll)
  125. {
  126. this.m_UIScroll.ResetPosition();
  127. }
  128. EventDelegate.Add(this.m_MyButton.onClick, new EventDelegate.Callback(this.FadeOut));
  129. }
  130. private void FadeOut()
  131. {
  132. if (this.m_MyPanel.alpha > 0.9f)
  133. {
  134. base.StartCoroutine(this.Fade(false));
  135. }
  136. }
  137. private IEnumerator Fade(bool is_fadein)
  138. {
  139. float timer = 0f;
  140. for (;;)
  141. {
  142. float rate = Mathf.Sin(Mathf.Clamp01(timer / this.m_FadeTime) * 90f * 0.0174532924f);
  143. if (!is_fadein)
  144. {
  145. rate = 1f - rate;
  146. }
  147. this.m_MyPanel.alpha = rate;
  148. timer += Time.deltaTime;
  149. if (timer >= this.m_FadeTime)
  150. {
  151. break;
  152. }
  153. yield return null;
  154. }
  155. if (!is_fadein)
  156. {
  157. UnityEngine.Object.Destroy(base.gameObject);
  158. if (!string.IsNullOrEmpty(this.m_JumpLabel))
  159. {
  160. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_JumpLabel);
  161. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  162. }
  163. }
  164. yield break;
  165. yield break;
  166. }
  167. [SerializeField]
  168. private float m_FadeTime = 0.5f;
  169. [SerializeField]
  170. private UIButton m_MyButton;
  171. [SerializeField]
  172. private GameObject m_FewVer;
  173. [SerializeField]
  174. private GameObject m_ManyVer;
  175. [SerializeField]
  176. [Header("この数以上で多数表示")]
  177. private int m_ManyModeCount = 8;
  178. private UIPanel m_MyPanel;
  179. private UIScrollView m_UIScroll;
  180. private UIGrid m_UIGrid;
  181. [SerializeField]
  182. [Header("固定3人イベントのときの呼称")]
  183. private string m_IdolNotice = "アイドルルート";
  184. private string m_JumpLabel = string.Empty;
  185. }