SceneScenarioSelect.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. using wf;
  7. public class SceneScenarioSelect : MonoBehaviour
  8. {
  9. private void Start()
  10. {
  11. if (GameMain.Instance.CharacterMgr.status.isDaytime)
  12. {
  13. GameMain.Instance.BgMgr.ChangeBg(this.m_DayBGName);
  14. }
  15. else
  16. {
  17. GameMain.Instance.BgMgr.ChangeBg(this.m_NightBGName);
  18. }
  19. GameMain.Instance.SoundMgr.PlayBGM(this.m_BGMName, 0f, true);
  20. GameMain.Instance.MainLight.Reset();
  21. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  22. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  23. GameMain.Instance.SoundMgr.VoiceStopAll();
  24. GameMain.Instance.SoundMgr.StopSe();
  25. this.m_AdvkagMgr = GameMain.Instance.ScriptMgr.adv_kag;
  26. if (!this.m_AdvkagMgr.tag_backup.ContainsKey("cancel_label"))
  27. {
  28. Debug.LogError("SceneScenarioSelect.cs:Cancel実行時に飛ぶラベルが設定されてません");
  29. }
  30. else
  31. {
  32. this.m_CancelLabel = this.m_AdvkagMgr.tag_backup["cancel_label"];
  33. }
  34. if (!this.m_AdvkagMgr.tag_backup.ContainsKey("label"))
  35. {
  36. Debug.LogError("SceneScenarioSelect.cs:イベント実行時に飛ぶラベルが設定されてません");
  37. }
  38. else
  39. {
  40. this.m_OkLabel = this.m_AdvkagMgr.tag_backup["label"];
  41. }
  42. EventDelegate.Add(this.m_OkButton.onClick, new EventDelegate.Callback(this.PushOkButton));
  43. EventDelegate.Add(this.m_CancelButton.onClick, new EventDelegate.Callback(this.PushCancelButton));
  44. this.SetPlayableText();
  45. this.SetScenarioPlate();
  46. GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
  47. }
  48. private void PushOkButton()
  49. {
  50. if (string.IsNullOrEmpty(this.m_OkLabel))
  51. {
  52. return;
  53. }
  54. this.m_JumpLabel = this.m_OkLabel;
  55. GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.JumpNextLabel), true, default(Color));
  56. }
  57. private void PushCancelButton()
  58. {
  59. if (string.IsNullOrEmpty(this.m_CancelLabel))
  60. {
  61. return;
  62. }
  63. this.m_JumpLabel = this.m_CancelLabel;
  64. GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.JumpNextLabel), true, default(Color));
  65. }
  66. private void JumpNextLabel()
  67. {
  68. if (this.m_JumpLabel == this.m_OkLabel)
  69. {
  70. this.m_CurrentScenario.ScenarioPlay(this.m_SelectedMaid);
  71. NDebug.Assert(!string.IsNullOrEmpty(this.m_CurrentScenario.ScenarioScript), "SceneScenarioSelect.cs:選択したシナリオのスクリプトファイル名が設定されてません");
  72. NDebug.Assert(!string.IsNullOrEmpty(this.m_CurrentScenario.ScriptLabel), "SceneScenarioSelect.cs:選択したシナリオのラベル名が設定されてません");
  73. string text = this.m_CurrentScenario.ScenarioScript;
  74. if (this.m_SelectedMaid.Count > 0 && text.IndexOf("?") >= 0)
  75. {
  76. text = ScriptManager.ReplacePersonal(this.m_SelectedMaid[0], text);
  77. }
  78. GameMain.Instance.ScriptMgr.EvalScript("&tf['scenario_file_name'] = '" + text + "';");
  79. GameMain.Instance.ScriptMgr.EvalScript("&tf['label_name'] = '" + this.m_CurrentScenario.ScriptLabel + "';");
  80. }
  81. this.m_AdvkagMgr.JumpLabel(this.m_JumpLabel);
  82. this.m_AdvkagMgr.Exec();
  83. }
  84. private void OnSelectScenario()
  85. {
  86. if (!UIWFSelectButton.current.isSelected)
  87. {
  88. return;
  89. }
  90. this.m_CurrentScenario = this.m_ScenarioButtonpair[(UIWFTabButton)UIWFSelectButton.current];
  91. this.m_ContentsLabel.text = this.m_CurrentScenario.EventContents;
  92. if (!Utility.SetLocalizeTerm(this.m_ContentsLabel, this.m_CurrentScenario.EventContentTerm, false))
  93. {
  94. this.m_ContentsLabel.text = this.m_ContentsLabel.text.Replace(" ", "\u00a0");
  95. }
  96. string[] conditionTextTerms = this.m_CurrentScenario.ConditionTextTerms;
  97. for (int i = 0; i < this.m_PlayableTextUIList.Count; i++)
  98. {
  99. GameObject gameObject = this.m_PlayableTextUIList[i].transform.parent.gameObject;
  100. gameObject.SetActive(false);
  101. if (i < this.m_CurrentScenario.ConditionText.Count<string>())
  102. {
  103. string text = this.m_CurrentScenario.ConditionText[i];
  104. if (!string.IsNullOrEmpty(text))
  105. {
  106. gameObject.SetActive(true);
  107. this.m_PlayableTextUIList[i].text = text;
  108. if (!Utility.SetLocalizeTerm(this.m_PlayableTextUIList[i], conditionTextTerms[i], false))
  109. {
  110. this.m_PlayableTextUIList[i].text = this.m_PlayableTextUIList[i].text.Replace(" ", "\u00a0");
  111. }
  112. }
  113. }
  114. }
  115. this.UpdateCharaUI();
  116. }
  117. private void UpdateCharaUI()
  118. {
  119. this.m_SelectedMaid.Clear();
  120. if (this.m_CurrentScenario.IsFixedMaid)
  121. {
  122. this.m_CharaSelectMgr.Create(CharacterSelectManager.Type.Multiple, this.m_CurrentScenario.EventMaidCount, true);
  123. for (int i = 0; i < this.m_CurrentScenario.EventMaidCount; i++)
  124. {
  125. this.m_SelectedMaid.Add(this.m_CurrentScenario.GetEventMaid(i));
  126. }
  127. base.StartCoroutine(this.ColiderOff());
  128. }
  129. else
  130. {
  131. CharacterSelectManager.CallBackOnSelect callBackCallBackOnSelect = delegate(Maid maid)
  132. {
  133. this.m_SelectedMaid.Clear();
  134. this.m_SelectedMaid.Add(maid);
  135. };
  136. this.m_CharaSelectMgr.SetCallBackCallBackOnSelect(callBackCallBackOnSelect);
  137. this.m_CharaSelectMgr.Create(CharacterSelectManager.Type.Select, 3, true);
  138. }
  139. this.m_CharaSelectMgr.big_thumbnail.Visible = false;
  140. for (int j = 0; j < GameMain.Instance.CharacterMgr.GetStockMaidCount(); j++)
  141. {
  142. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(j);
  143. if (!this.m_CurrentScenario.ExistEventMaid(stockMaid))
  144. {
  145. this.m_CharaSelectMgr.RemoveMaidPlate(stockMaid);
  146. }
  147. }
  148. if (this.m_CurrentScenario.IsFixedMaid || this.m_CurrentScenario.EventMaidCount == 0)
  149. {
  150. return;
  151. }
  152. if (this.m_CurrentScenario.EventMaidCount != GameMain.Instance.CharacterMgr.GetStockMaidCount())
  153. {
  154. List<Transform> childList = this.m_CharaSelectMgr.MaidPlateParentGrid.GetChildList();
  155. this.m_CharaSelectMgr.SelectMaid(childList[0].GetComponent<MaidPlate>().maid);
  156. }
  157. }
  158. private IEnumerator ColiderOff()
  159. {
  160. yield return null;
  161. List<Transform> maid_plates = this.m_CharaSelectMgr.MaidPlateParentGrid.GetChildList();
  162. foreach (Transform transform in maid_plates)
  163. {
  164. transform.GetComponentInChildren<BoxCollider>().enabled = false;
  165. }
  166. yield break;
  167. }
  168. private void SetScenarioPlate()
  169. {
  170. foreach (ScenarioData scenarioData in GameMain.Instance.ScenarioSelectMgr.GetAllScenarioData())
  171. {
  172. if (scenarioData.IsPlayable)
  173. {
  174. GameObject gameObject = Utility.CreatePrefab(this.m_ScenarioScroll.Grid.gameObject, "SceneScenarioSelect/Prefab/ScenarioPlate", true);
  175. UILabel component = UTY.GetChildObject(gameObject, "Title", false).GetComponent<UILabel>();
  176. component.text = scenarioData.Title;
  177. Utility.SetLocalizeTerm(component, scenarioData.TitleTerm, false);
  178. gameObject.name = scenarioData.NotLineTitle;
  179. UTY.GetChildObject(gameObject, "Icon", false).GetComponent<UI2DSprite>().sprite2D = Resources.Load<Sprite>("SceneScenarioSelect/Sprite/" + scenarioData.IconName);
  180. UIWFTabButton componentInChildren = gameObject.GetComponentInChildren<UIWFTabButton>();
  181. EventDelegate.Add(componentInChildren.onSelect, new EventDelegate.Callback(this.OnSelectScenario));
  182. this.m_ScenarioButtonpair.Add(componentInChildren, scenarioData);
  183. }
  184. }
  185. this.m_ScenarioScroll.Grid.repositionNow = true;
  186. this.m_ScenarioScroll.ScrollView.ResetPosition();
  187. this.m_UIWFTabPanel.UpdateChildren();
  188. if (this.m_ScenarioButtonpair.Count<KeyValuePair<UIWFTabButton, ScenarioData>>() > 0)
  189. {
  190. this.m_UIWFTabPanel.Select(this.m_ScenarioButtonpair.Keys.First<UIWFTabButton>());
  191. }
  192. else
  193. {
  194. this.m_OkButton.isEnabled = false;
  195. }
  196. }
  197. private void SetPlayableText()
  198. {
  199. for (int i = 0; i < Enum.GetValues(typeof(ScenarioData.PlayableCondition)).Length; i++)
  200. {
  201. GameObject gameObject = Utility.CreatePrefab(this.m_PlayableScroll.Grid.gameObject, "SceneScenarioSelect/Prefab/PlayableText", true);
  202. UTY.GetChildObject(gameObject, "Number", false).GetComponent<UILabel>().text = (i + 1).ToString();
  203. this.m_PlayableTextUIList.Add(UTY.GetChildObject(gameObject, "Text", false).GetComponent<UILabel>());
  204. gameObject.SetActive(false);
  205. }
  206. this.m_PlayableScroll.Grid.repositionNow = true;
  207. this.m_PlayableScroll.ScrollView.ResetPosition();
  208. }
  209. [SerializeField]
  210. [Header("昼背景名")]
  211. private string m_DayBGName = "Shitsumu";
  212. [SerializeField]
  213. [Header("夜背景名")]
  214. private string m_NightBGName = "Shitsumu_Night";
  215. [SerializeField]
  216. [Header("BGM名")]
  217. private string m_BGMName = "BGM009.ogg";
  218. [SerializeField]
  219. [Header("シナリオプレート列挙に使うもの")]
  220. private SceneScenarioSelect.NeedScrollUI m_ScenarioScroll;
  221. [SerializeField]
  222. private UIWFTabPanel m_UIWFTabPanel;
  223. [SerializeField]
  224. [Header("シナリオ内容表示UI")]
  225. private UILabel m_ContentsLabel;
  226. [SerializeField]
  227. private SceneScenarioSelect.NeedScrollUI m_PlayableScroll;
  228. private List<UILabel> m_PlayableTextUIList = new List<UILabel>();
  229. [SerializeField]
  230. [Header("")]
  231. private UIButton m_OkButton;
  232. [SerializeField]
  233. private UIButton m_CancelButton;
  234. [SerializeField]
  235. [Header("キャラ選択管理クラス")]
  236. private CharacterSelectManager m_CharaSelectMgr;
  237. private string m_OkLabel;
  238. private string m_CancelLabel;
  239. private string m_JumpLabel;
  240. private ADVKagManager m_AdvkagMgr;
  241. private ScenarioData m_CurrentScenario;
  242. private List<Maid> m_SelectedMaid = new List<Maid>();
  243. private Dictionary<UIWFTabButton, ScenarioData> m_ScenarioButtonpair = new Dictionary<UIWFTabButton, ScenarioData>();
  244. [Serializable]
  245. private class NeedScrollUI
  246. {
  247. public UIScrollView ScrollView;
  248. public UIGrid Grid;
  249. }
  250. }