SceneScenarioSelect.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. Utility.SetLocalizeTerm(this.m_ContentsLabel, this.m_CurrentScenario.EventContentTerm);
  93. string[] conditionTextTerms = this.m_CurrentScenario.ConditionTextTerms;
  94. for (int i = 0; i < this.m_PlayableTextUIList.Count; i++)
  95. {
  96. GameObject gameObject = this.m_PlayableTextUIList[i].transform.parent.gameObject;
  97. gameObject.SetActive(false);
  98. if (i < this.m_CurrentScenario.ConditionText.Count<string>())
  99. {
  100. string text = this.m_CurrentScenario.ConditionText[i];
  101. if (!string.IsNullOrEmpty(text))
  102. {
  103. gameObject.SetActive(true);
  104. this.m_PlayableTextUIList[i].text = text;
  105. Utility.SetLocalizeTerm(this.m_PlayableTextUIList[i], conditionTextTerms[i]);
  106. }
  107. }
  108. }
  109. this.UpdateCharaUI();
  110. }
  111. private void UpdateCharaUI()
  112. {
  113. this.m_SelectedMaid.Clear();
  114. if (this.m_CurrentScenario.IsFixedMaid)
  115. {
  116. this.m_CharaSelectMgr.Create(CharacterSelectManager.Type.Multiple, this.m_CurrentScenario.EventMaidCount, true);
  117. for (int i = 0; i < this.m_CurrentScenario.EventMaidCount; i++)
  118. {
  119. this.m_SelectedMaid.Add(this.m_CurrentScenario.GetEventMaid(i));
  120. }
  121. base.StartCoroutine(this.ColiderOff());
  122. }
  123. else
  124. {
  125. CharacterSelectManager.CallBackOnSelect callBackCallBackOnSelect = delegate(Maid maid)
  126. {
  127. this.m_SelectedMaid.Clear();
  128. this.m_SelectedMaid.Add(maid);
  129. };
  130. this.m_CharaSelectMgr.SetCallBackCallBackOnSelect(callBackCallBackOnSelect);
  131. this.m_CharaSelectMgr.Create(CharacterSelectManager.Type.Select, 3, true);
  132. }
  133. this.m_CharaSelectMgr.big_thumbnail.Visible = false;
  134. for (int j = 0; j < GameMain.Instance.CharacterMgr.GetStockMaidCount(); j++)
  135. {
  136. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(j);
  137. if (!this.m_CurrentScenario.ExistEventMaid(stockMaid))
  138. {
  139. this.m_CharaSelectMgr.RemoveMaidPlate(stockMaid);
  140. }
  141. }
  142. if (this.m_CurrentScenario.IsFixedMaid || this.m_CurrentScenario.EventMaidCount == 0)
  143. {
  144. return;
  145. }
  146. if (this.m_CurrentScenario.EventMaidCount != GameMain.Instance.CharacterMgr.GetStockMaidCount())
  147. {
  148. List<Transform> childList = this.m_CharaSelectMgr.MaidPlateParentGrid.GetChildList();
  149. this.m_CharaSelectMgr.SelectMaid(childList[0].GetComponent<MaidPlate>().maid);
  150. }
  151. }
  152. private IEnumerator ColiderOff()
  153. {
  154. yield return null;
  155. List<Transform> maid_plates = this.m_CharaSelectMgr.MaidPlateParentGrid.GetChildList();
  156. foreach (Transform transform in maid_plates)
  157. {
  158. transform.GetComponentInChildren<BoxCollider>().enabled = false;
  159. }
  160. yield break;
  161. }
  162. private void SetScenarioPlate()
  163. {
  164. foreach (ScenarioData scenarioData in GameMain.Instance.ScenarioSelectMgr.GetAllScenarioData())
  165. {
  166. if (scenarioData.IsPlayable)
  167. {
  168. GameObject gameObject = Utility.CreatePrefab(this.m_ScenarioScroll.Grid.gameObject, "SceneScenarioSelect/Prefab/ScenarioPlate", true);
  169. UILabel component = UTY.GetChildObject(gameObject, "Title", false).GetComponent<UILabel>();
  170. component.text = scenarioData.Title;
  171. Utility.SetLocalizeTerm(component, scenarioData.TitleTerm);
  172. gameObject.name = scenarioData.NotLineTitle;
  173. UTY.GetChildObject(gameObject, "Icon", false).GetComponent<UI2DSprite>().sprite2D = Resources.Load<Sprite>("SceneScenarioSelect/Sprite/" + scenarioData.IconName);
  174. UIWFTabButton componentInChildren = gameObject.GetComponentInChildren<UIWFTabButton>();
  175. EventDelegate.Add(componentInChildren.onSelect, new EventDelegate.Callback(this.OnSelectScenario));
  176. this.m_ScenarioButtonpair.Add(componentInChildren, scenarioData);
  177. }
  178. }
  179. this.m_ScenarioScroll.Grid.repositionNow = true;
  180. this.m_ScenarioScroll.ScrollView.ResetPosition();
  181. this.m_UIWFTabPanel.UpdateChildren();
  182. if (this.m_ScenarioButtonpair.Count<KeyValuePair<UIWFTabButton, ScenarioData>>() > 0)
  183. {
  184. this.m_UIWFTabPanel.Select(this.m_ScenarioButtonpair.Keys.First<UIWFTabButton>());
  185. }
  186. else
  187. {
  188. this.m_OkButton.isEnabled = false;
  189. }
  190. }
  191. private void SetPlayableText()
  192. {
  193. for (int i = 0; i < Enum.GetValues(typeof(ScenarioData.PlayableCondition)).Length; i++)
  194. {
  195. GameObject gameObject = Utility.CreatePrefab(this.m_PlayableScroll.Grid.gameObject, "SceneScenarioSelect/Prefab/PlayableText", true);
  196. UTY.GetChildObject(gameObject, "Number", false).GetComponent<UILabel>().text = (i + 1).ToString();
  197. this.m_PlayableTextUIList.Add(UTY.GetChildObject(gameObject, "Text", false).GetComponent<UILabel>());
  198. gameObject.SetActive(false);
  199. }
  200. this.m_PlayableScroll.Grid.repositionNow = true;
  201. this.m_PlayableScroll.ScrollView.ResetPosition();
  202. }
  203. [SerializeField]
  204. [Header("昼背景名")]
  205. private string m_DayBGName = "Shitsumu";
  206. [SerializeField]
  207. [Header("夜背景名")]
  208. private string m_NightBGName = "Shitsumu_Night";
  209. [SerializeField]
  210. [Header("BGM名")]
  211. private string m_BGMName = "BGM009.ogg";
  212. [SerializeField]
  213. [Header("シナリオプレート列挙に使うもの")]
  214. private SceneScenarioSelect.NeedScrollUI m_ScenarioScroll;
  215. [SerializeField]
  216. private UIWFTabPanel m_UIWFTabPanel;
  217. [SerializeField]
  218. [Header("シナリオ内容表示UI")]
  219. private UILabel m_ContentsLabel;
  220. [SerializeField]
  221. private SceneScenarioSelect.NeedScrollUI m_PlayableScroll;
  222. private List<UILabel> m_PlayableTextUIList = new List<UILabel>();
  223. [SerializeField]
  224. [Header("")]
  225. private UIButton m_OkButton;
  226. [SerializeField]
  227. private UIButton m_CancelButton;
  228. [SerializeField]
  229. [Header("キャラ選択管理クラス")]
  230. private CharacterSelectManager m_CharaSelectMgr;
  231. private string m_OkLabel;
  232. private string m_CancelLabel;
  233. private string m_JumpLabel;
  234. private ADVKagManager m_AdvkagMgr;
  235. private ScenarioData m_CurrentScenario;
  236. private List<Maid> m_SelectedMaid = new List<Maid>();
  237. private Dictionary<UIWFTabButton, ScenarioData> m_ScenarioButtonpair = new Dictionary<UIWFTabButton, ScenarioData>();
  238. [Serializable]
  239. private class NeedScrollUI
  240. {
  241. public UIScrollView ScrollView;
  242. public UIGrid Grid;
  243. }
  244. }