SceneScenarioSelect.cs 8.7 KB

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