ScoutMainScreenManager.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using System;
  2. using UnityEngine;
  3. namespace scoutmode
  4. {
  5. public class ScoutMainScreenManager : WfScreenChildren
  6. {
  7. public new SceneScoutScreenManager parent_mgr
  8. {
  9. get
  10. {
  11. return base.parent_mgr as SceneScoutScreenManager;
  12. }
  13. }
  14. public ScoutMaidData scoutingMaidData { get; private set; }
  15. public ScoutMaidData selectedScoutMaid { get; private set; }
  16. public string SelectedStageName
  17. {
  18. get
  19. {
  20. return this.progressInformation.SelectStage.ToString();
  21. }
  22. }
  23. private ScoutManager Manager
  24. {
  25. get
  26. {
  27. return ScoutManager.Instance;
  28. }
  29. }
  30. public override void Awake()
  31. {
  32. base.Awake();
  33. if (this.menus != null)
  34. {
  35. ScoutMainScreenManager.MenuButton[] array = this.menus;
  36. for (int i = 0; i < array.Length; i++)
  37. {
  38. ScoutMainScreenManager.MenuButton menu = array[i];
  39. ScoutMainScreenManager $this = this;
  40. if (menu.button != null)
  41. {
  42. EventDelegate.Add(menu.button.onClick, delegate()
  43. {
  44. $this.OnClickMenuButton(menu.type);
  45. });
  46. }
  47. }
  48. }
  49. }
  50. protected override void OnCall()
  51. {
  52. GameMain.Instance.MainLight.Reset();
  53. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  54. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  55. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  56. GameMain.Instance.CharacterMgr.Deactivate(0, false);
  57. GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 1f, true);
  58. GameMain.Instance.BgMgr.ChangeBg((!GameMain.Instance.CharacterMgr.status.isDaytime) ? "ShinShitsumu_ChairRot_Night" : "ShinShitsumu_ChairRot");
  59. this.showStatusPanel = false;
  60. this.OnSelectedScoutMaid(null);
  61. this.scoutCharaSelect.callbackGetScoutMaidList = (() => this.Manager.scoutMaidList);
  62. this.scoutCharaSelect.callbackSelectItem = new Action<ScoutMaidData>(this.OnSelectedScoutMaid);
  63. this.scoutCharaSelect.SetData();
  64. this.progressInformation.SetStage((!GameMain.Instance.CharacterMgr.status.isDaytime) ? ScoutProgressInformation.Stage.Club : ScoutProgressInformation.Stage.ShoppingMall);
  65. foreach (ScoutMaidData scoutMaidData in this.Manager.scoutMaidList)
  66. {
  67. if (scoutMaidData.instanceData.enabled && scoutMaidData.instanceData.stageName == this.SelectedStageName)
  68. {
  69. this.scoutingMaidData = scoutMaidData;
  70. break;
  71. }
  72. }
  73. this.UpdateProgressInfoCharacter();
  74. ScoutOption scoutOption = this.scoutOption;
  75. scoutOption.onChangeValue = (Action<ScoutOption.SettingType, string>)Delegate.Combine(scoutOption.onChangeValue, new Action<ScoutOption.SettingType, string>(delegate(ScoutOption.SettingType type, string value)
  76. {
  77. if (type == ScoutOption.SettingType.BaseChara)
  78. {
  79. this.UpdateProgressInfoCharacter();
  80. }
  81. }));
  82. foreach (ScoutMainScreenManager.MenuButton menuButton in this.menus)
  83. {
  84. if (menuButton.type == ScoutMainScreenManager.ButtonType.Cancel)
  85. {
  86. menuButton.button.transform.parent.gameObject.SetActive(false);
  87. break;
  88. }
  89. }
  90. uGUITutorialPanel.OpenTutorial("SceneScout", null, false);
  91. GameMain.Instance.SysShortcut.strSceneHelpName = "SceneScout";
  92. }
  93. public void OnClickMenuButton(ScoutMainScreenManager.ButtonType type)
  94. {
  95. Debug.Log(type.ToString());
  96. if (type == ScoutMainScreenManager.ButtonType.AddScoutMaid)
  97. {
  98. this.AddScoutMaid();
  99. }
  100. else if (type == ScoutMainScreenManager.ButtonType.DeleteScoutMaid)
  101. {
  102. this.DeleteScoutMaid(this.scoutCharaSelect.selectedMaidData);
  103. }
  104. else if (type == ScoutMainScreenManager.ButtonType.Start)
  105. {
  106. this.StartScout();
  107. }
  108. else if (type == ScoutMainScreenManager.ButtonType.ShowStatus)
  109. {
  110. this.showStatusPanel = !this.showStatusPanel;
  111. this.UpdateShowPanels();
  112. }
  113. else if (type == ScoutMainScreenManager.ButtonType.Exist)
  114. {
  115. this.parent_mgr.CallExist(this);
  116. }
  117. else if (type == ScoutMainScreenManager.ButtonType.Cancel)
  118. {
  119. this.Manager.CancelScout(this.scoutingMaidData);
  120. this.scoutingMaidData = null;
  121. this.UpdateProgressInfoCharacter();
  122. this.UpdateShowPanels();
  123. }
  124. }
  125. private bool StartScout()
  126. {
  127. ScoutMaidData callScoutMaid = null;
  128. if (this.scoutingMaidData == null)
  129. {
  130. callScoutMaid = this.selectedScoutMaid;
  131. if (!ScoutManager.Instance.options.baseCharaSelect)
  132. {
  133. callScoutMaid = this.Manager.GetRandomWaitingScoutmaid();
  134. }
  135. else if (callScoutMaid != null && callScoutMaid.instanceData.enabled)
  136. {
  137. GameMain.Instance.SysDlg.Show("指定キャラクターは既にスカウト中のため開始できません", SystemDialog.TYPE.OK, null, null);
  138. return false;
  139. }
  140. if (callScoutMaid == null)
  141. {
  142. GameMain.Instance.SysDlg.Show("新たにスカウトを開始するメイドが存在しません", SystemDialog.TYPE.OK, null, null);
  143. return false;
  144. }
  145. this.Manager.CreateRandomScoutMaidData(callScoutMaid, ScoutManager.Instance.options);
  146. }
  147. else
  148. {
  149. foreach (ScoutMaidData scoutMaidData in this.Manager.scoutMaidList)
  150. {
  151. if (scoutMaidData.instanceData.enabled && scoutMaidData.instanceData.stageName == this.SelectedStageName)
  152. {
  153. callScoutMaid = scoutMaidData;
  154. break;
  155. }
  156. }
  157. }
  158. if (callScoutMaid == null)
  159. {
  160. return false;
  161. }
  162. this.onFinishEvent = delegate()
  163. {
  164. this.Manager.StartScout(this.Manager.ActiveScoutMaid(callScoutMaid, 0), this.SelectedStageName, ScoutManager.Instance.options);
  165. this.progressInformation.ChangeBg(this.progressInformation.SelectStage);
  166. };
  167. this.parent_mgr.CallStart(this);
  168. return true;
  169. }
  170. private void AddScoutMaid()
  171. {
  172. this.onFinishEvent = delegate()
  173. {
  174. Maid maid = GameMain.Instance.CharacterMgr.AddStockMaid();
  175. maid.Visible = true;
  176. GameMain.Instance.CharacterMgr.SetActiveMaid(maid, 0);
  177. };
  178. this.parent_mgr.CallAddScoutCharacter(this);
  179. }
  180. private void DeleteScoutMaid(ScoutMaidData scoutMaid)
  181. {
  182. if (scoutMaid == null)
  183. {
  184. return;
  185. }
  186. if (scoutMaid.instanceData.enabled)
  187. {
  188. GameMain.Instance.SysDlg.Show("スカウト中のため削除できません", SystemDialog.TYPE.OK, null, null);
  189. return;
  190. }
  191. this.Manager.RemoveScoutMaid(scoutMaid);
  192. this.scoutCharaSelect.DeleteItem(scoutMaid);
  193. if (this.scoutCharaSelect.selectedMaidData == null)
  194. {
  195. this.OnSelectedScoutMaid(null);
  196. }
  197. }
  198. public void OnSelectedScoutMaid(ScoutMaidData scoutMaid)
  199. {
  200. foreach (ScoutMainScreenManager.MenuButton menuButton in this.menus)
  201. {
  202. if (!(menuButton.button == null) && ScoutMainScreenManager.ButtonType.Start > menuButton.type)
  203. {
  204. if (menuButton.type == ScoutMainScreenManager.ButtonType.DeleteScoutMaid || menuButton.type == ScoutMainScreenManager.ButtonType.ShowStatus)
  205. {
  206. menuButton.button.isEnabled = (scoutMaid != null);
  207. }
  208. }
  209. }
  210. if (scoutMaid != null)
  211. {
  212. this.scoutCharaSelect.bigThumbnail.SetFile(new string[]
  213. {
  214. ScoutMaidData.GetThumbnailFilePath(scoutMaid.status.guid, true),
  215. ScoutMaidData.GetThumbnailFilePath(scoutMaid.status.guid, false)
  216. });
  217. }
  218. else
  219. {
  220. this.scoutCharaSelect.bigThumbnail.SetFile(null);
  221. }
  222. this.selectedScoutMaid = scoutMaid;
  223. this.UpdateProgressInfoCharacter();
  224. this.UpdateShowPanels();
  225. }
  226. public void OnAddedScoutMaidReturned()
  227. {
  228. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  229. this.Manager.AddScoutMaid(maid);
  230. GameMain.Instance.CharacterMgr.BanishmentMaid(maid);
  231. }
  232. private void UpdateShowPanels()
  233. {
  234. this.scoutCharaSelect.bigThumbnail.Visible = (!this.showStatusPanel && this.selectedScoutMaid != null);
  235. this.statusPanel.visible = (this.showStatusPanel && this.selectedScoutMaid != null);
  236. if (this.statusPanel.visible)
  237. {
  238. this.statusPanel.SetDrawStatus(this.selectedScoutMaid);
  239. }
  240. }
  241. private void UpdateProgressInfoCharacter()
  242. {
  243. bool isEnabled = false;
  244. if (this.scoutingMaidData != null)
  245. {
  246. this.progressInformation.SetCharacter(this.scoutingMaidData, true);
  247. isEnabled = true;
  248. }
  249. else if (this.Manager.options.baseCharaSelect)
  250. {
  251. this.progressInformation.SetCharacter(this.selectedScoutMaid, false);
  252. isEnabled = (this.selectedScoutMaid != null);
  253. }
  254. else if (this.Manager.GetRandomWaitingScoutmaid() != null)
  255. {
  256. this.progressInformation.SetCharacterRandom();
  257. isEnabled = true;
  258. }
  259. else
  260. {
  261. this.progressInformation.SetCharacter(null, false);
  262. }
  263. foreach (ScoutMainScreenManager.MenuButton menuButton in this.menus)
  264. {
  265. if (menuButton.type == ScoutMainScreenManager.ButtonType.Start)
  266. {
  267. menuButton.button.isEnabled = isEnabled;
  268. break;
  269. }
  270. }
  271. }
  272. protected override void OnFinish()
  273. {
  274. if (this.onFinishEvent != null)
  275. {
  276. this.onFinishEvent();
  277. }
  278. this.parent_mgr.CallScreen("Move");
  279. }
  280. [SerializeField]
  281. private ScoutMainScreenManager.MenuButton[] menus;
  282. [SerializeField]
  283. private ScoutCharacterSelectCtrl scoutCharaSelect;
  284. [SerializeField]
  285. private ScoutOption scoutOption;
  286. [SerializeField]
  287. private ScoutProgressInformation progressInformation;
  288. [SerializeField]
  289. private ScoutStatusPanel statusPanel;
  290. private Action onFinishEvent;
  291. private bool showStatusPanel;
  292. public enum ButtonType
  293. {
  294. AddScoutMaid = 10,
  295. DeleteScoutMaid = 20,
  296. ShowStatus = 30,
  297. Start = 100,
  298. Exist = 110,
  299. Cancel = 120
  300. }
  301. [Serializable]
  302. private struct MenuButton
  303. {
  304. public ScoutMainScreenManager.ButtonType type;
  305. public UIButton button;
  306. }
  307. }
  308. }