MaidMiniManagementCtrl.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Kasizuki
  5. {
  6. public class MaidMiniManagementCtrl : WfScreenChildren
  7. {
  8. public override void Awake()
  9. {
  10. base.Awake();
  11. this.m_SwitchingWindowDic = new Dictionary<string, NGUIWindow>();
  12. this.m_SwitchingWindowDic.Add("ステータス", UTY.GetChildObject(base.root_obj, "MaidMiniStatusPanel", false).GetComponent<NGUIWindow>());
  13. this.m_SwitchingWindowDic.Add("性癖", UTY.GetChildObject(base.root_obj, "MaidSeihekiPanel", false).GetComponent<NGUIWindow>());
  14. this.m_SwitchingWindowDic.Add("好感度", UTY.GetChildObject(base.root_obj, "MaidLikabilityPanel", false).GetComponent<NGUIWindow>());
  15. this.m_SwitchingWindowDic.Add("持ち込みアイテム", UTY.GetChildObject(base.root_obj, "Window Select Item", false).GetComponent<NGUIWindow>());
  16. this.m_SwitchingWindowDic.Add("パラメータロック", UTY.GetChildObject(base.root_obj, "Window Parameter Lock", false).AddComponent<NGUIWindow>());
  17. this.m_CharaSelectMgr = UTY.GetChildObject(base.root_obj, "CharacterSelectPanel", false).GetComponent<KasizukiCharacterSelectCtrl>();
  18. this.m_ButtonDic.Add("エディット", UTY.GetChildObject(base.root_obj, "ButtonParent/エディット", false).GetComponent<UIButton>());
  19. this.m_ButtonDic.Add("OK", UTY.GetChildObject(base.root_obj, "ButtonParent/OK", false).GetComponent<UIButton>());
  20. this.m_ButtonDic.Add("Cancel", UTY.GetChildObject(base.root_obj, "ButtonParent/Cancel", false).GetComponent<UIButton>());
  21. foreach (KeyValuePair<string, UIButton> keyValuePair in this.m_ButtonDic)
  22. {
  23. EventDelegate.Add(keyValuePair.Value.onClick, new EventDelegate.Callback(this.OnClickButton));
  24. }
  25. this.SetUpParameterLockWindow();
  26. }
  27. public void OnEnable()
  28. {
  29. this.m_SelectMaid = null;
  30. this.UpdateMaidInfoButtonEnable(false, true);
  31. }
  32. public void Open()
  33. {
  34. if (GameMain.Instance.KasizukiMgr.GetNowManType() == 10)
  35. {
  36. this.m_SwitchingWindowDic["パラメータロック"].GetCache<WFCheckBox>("好感度").enabled = false;
  37. this.m_SwitchingWindowDic["パラメータロック"].GetCache<WFCheckBox>("好感度").check = true;
  38. }
  39. else
  40. {
  41. this.m_SwitchingWindowDic["パラメータロック"].GetCache<WFCheckBox>("好感度").enabled = true;
  42. this.m_SwitchingWindowDic["パラメータロック"].GetCache<WFCheckBox>("好感度").check = GameMain.Instance.KasizukiMgr.GetSystemData<bool>(SystemDataType.好感度ロック);
  43. }
  44. this.UpdateMaidInfoButtonEnable(false, true);
  45. this.m_CharaSelectMgr.SetData();
  46. }
  47. protected override void OnCall()
  48. {
  49. this.m_CharaMgr = GameMain.Instance.CharacterMgr;
  50. this.edit_label_ = (base.parent_mgr as SceneKasizukiMainMenu).strScriptReturnLabelEdit;
  51. this.SetUpCharacterSelectManager();
  52. (this.m_SwitchingWindowDic["持ち込みアイテム"] as KasizukiItemCtrl).SetData();
  53. this.m_SwitchingWindowDic["持ち込みアイテム"].Close(0f, null);
  54. }
  55. private void SetUpCharacterSelectManager()
  56. {
  57. this.m_CharaSelectMgr.callbackSelectItem = new Action<Maid>(this.OnSelectChara);
  58. }
  59. private void SetUpParameterLockWindow()
  60. {
  61. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  62. NGUIWindow nguiwindow = this.m_SwitchingWindowDic["パラメータロック"];
  63. WFCheckBox wfcheckBox = nguiwindow.CacheChildObject<WFCheckBox>("ParentToggle/LockLikability/好感度", "好感度");
  64. WFCheckBox wfcheckBox2 = nguiwindow.CacheChildObject<WFCheckBox>("ParentToggle/LockPlayCount/仕事回数", "仕事回数");
  65. wfcheckBox.check = kasizukiMgr.GetSystemData<bool>(SystemDataType.好感度ロック);
  66. wfcheckBox2.check = kasizukiMgr.GetSystemData<bool>(SystemDataType.仕事回数ロック);
  67. wfcheckBox.onClick.Add(new Action<WFCheckBox>(this.OnChangeLock));
  68. wfcheckBox2.onClick.Add(new Action<WFCheckBox>(this.OnChangeLock));
  69. }
  70. private void OnSelectChara(Maid select_maid)
  71. {
  72. this.m_SelectMaid = select_maid;
  73. this.UpdateMaidInfoButtonEnable(this.m_SelectMaid != null, false);
  74. this.m_ButtonDic["OK"].isEnabled = (this.m_SelectMaid != null);
  75. this.m_ButtonDic["エディット"].gameObject.SetActive(this.m_SelectMaid != null);
  76. this.m_CharaSelectMgr.bigThumbnail.Visible = (this.m_SelectMaid != null);
  77. this.m_CharaSelectMgr.bigThumbnail.SetMaid(this.m_SelectMaid);
  78. this.m_SwitchingWindowDic["ステータス"].GetComponent<IStatusCtrl<Maid>>().SetData(this.m_SelectMaid);
  79. this.m_SwitchingWindowDic["性癖"].GetComponent<IStatusCtrl<Maid>>().SetData(this.m_SelectMaid);
  80. this.m_SwitchingWindowDic["好感度"].GetComponent<IStatusCtrl<Maid>>().SetData(this.m_SelectMaid);
  81. this.m_SwitchingWindowDic["ステータス"].Open(0.25f, null);
  82. this.m_SwitchingWindowDic["性癖"].Open(0.25f, null);
  83. this.m_SwitchingWindowDic["好感度"].Open(0.25f, null);
  84. this.m_SwitchingWindowDic["パラメータロック"].Open(0.25f, null);
  85. }
  86. private void OnClickButton()
  87. {
  88. string text = string.Empty;
  89. foreach (KeyValuePair<string, UIButton> keyValuePair in this.m_ButtonDic)
  90. {
  91. if (keyValuePair.Value == UIButton.current)
  92. {
  93. text = keyValuePair.Key;
  94. break;
  95. }
  96. }
  97. if (string.IsNullOrEmpty(text))
  98. {
  99. Debug.LogWarning("押されたボタンの名前が見つかりませんでした");
  100. return;
  101. }
  102. Debug.LogFormat("ボタン「{0}」が押された", new object[]
  103. {
  104. text
  105. });
  106. if (text == "エディット")
  107. {
  108. if (this.m_SelectMaid == null)
  109. {
  110. Debug.LogWarning("メイドが選択されていません");
  111. return;
  112. }
  113. if (string.IsNullOrEmpty(this.edit_label_))
  114. {
  115. Debug.LogWarning("エディットの飛び先ラベルがありません");
  116. return;
  117. }
  118. this.m_CharaMgr.SetActiveMaid(this.m_SelectMaid, 0);
  119. (base.parent_mgr as SceneKasizukiMainMenu).moveScreen.SetNextLabel(this.edit_label_);
  120. this.Finish();
  121. }
  122. else if (text == "OK")
  123. {
  124. if (this.m_OnClickOK != null)
  125. {
  126. this.m_OnClickOK();
  127. }
  128. else
  129. {
  130. Debug.LogWarning("OKボタンを押したときのコールバックが未登録です");
  131. }
  132. }
  133. else if (text == "Cancel")
  134. {
  135. if (this.m_OnClickCancel != null)
  136. {
  137. this.m_OnClickCancel();
  138. }
  139. else
  140. {
  141. Debug.LogWarning("Cancelボタンを押したときのコールバックが未登録です");
  142. }
  143. }
  144. else if (this.m_SelectMaid == null)
  145. {
  146. Debug.LogWarningFormat("ボタン「{0}」を押しましたが、選択しているメイドがnullでした", new object[]
  147. {
  148. text
  149. });
  150. }
  151. else
  152. {
  153. Debug.LogWarningFormat("ボタン「{0}」の処理はありません", new object[]
  154. {
  155. text
  156. });
  157. }
  158. }
  159. private void OnChangeLock(WFCheckBox checkBox)
  160. {
  161. NGUIWindow nguiwindow = this.m_SwitchingWindowDic["パラメータロック"];
  162. List<UnityEngine.Object> values = nguiwindow.cachedObjectDic.Values;
  163. if (!values.Contains(checkBox))
  164. {
  165. NDebug.Warning(string.Format("クリックされたボタン名に対応するボタンがありません\n{0}", checkBox.name));
  166. }
  167. if (!checkBox.GetComponent<Collider>().enabled)
  168. {
  169. return;
  170. }
  171. string name = checkBox.name;
  172. bool check = checkBox.check;
  173. if (name == "好感度")
  174. {
  175. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  176. kasizukiMgr.SetSystemData<bool>(SystemDataType.好感度ロック, check, false);
  177. Debug.LogFormat("好感度ロック:{0}", new object[]
  178. {
  179. check
  180. });
  181. }
  182. else if (name == "仕事回数")
  183. {
  184. KasizukiManager kasizukiMgr2 = GameMain.Instance.KasizukiMgr;
  185. kasizukiMgr2.SetSystemData<bool>(SystemDataType.仕事回数ロック, check, false);
  186. Debug.LogFormat("仕事回数ロック:{0}", new object[]
  187. {
  188. check
  189. });
  190. }
  191. }
  192. public void UpdateMaidInfoButtonEnable(bool isEnable, bool isImmediate = false)
  193. {
  194. float num = (!isImmediate) ? 0.25f : 0.01f;
  195. float num2 = (!isEnable) ? 0f : 1f;
  196. if (this.m_CharaSelectMgr && this.m_CharaSelectMgr.bigThumbnail)
  197. {
  198. this.m_CharaSelectMgr.bigThumbnail.Visible = isEnable;
  199. }
  200. }
  201. public void OpenSwitchingWindow(string name, bool isImmediate = false)
  202. {
  203. Dictionary<string, NGUIWindow> switchingWindowDic = this.m_SwitchingWindowDic;
  204. if (switchingWindowDic == null)
  205. {
  206. NDebug.Assert("ウィンドウの配列にnullが指定されました", false);
  207. }
  208. if (!switchingWindowDic.ContainsKey(name))
  209. {
  210. NDebug.Assert(string.Format("ウィンドウの配列には「{0}」のキーが存在しません", name), false);
  211. }
  212. foreach (KeyValuePair<string, NGUIWindow> keyValuePair in switchingWindowDic)
  213. {
  214. if (keyValuePair.Key == name)
  215. {
  216. if (isImmediate)
  217. {
  218. keyValuePair.Value.Open(0.01f, null);
  219. }
  220. else
  221. {
  222. keyValuePair.Value.Open(0.25f, null);
  223. }
  224. }
  225. else if (isImmediate)
  226. {
  227. keyValuePair.Value.Close(0.01f, null);
  228. }
  229. else
  230. {
  231. keyValuePair.Value.Close(0.25f, null);
  232. }
  233. }
  234. }
  235. public void CloseSwitchingWindowAll(bool isImmediate = false)
  236. {
  237. Dictionary<string, NGUIWindow> switchingWindowDic = this.m_SwitchingWindowDic;
  238. if (switchingWindowDic == null)
  239. {
  240. NDebug.Assert("ウィンドウの配列にnullが指定されました", false);
  241. }
  242. foreach (KeyValuePair<string, NGUIWindow> keyValuePair in switchingWindowDic)
  243. {
  244. if (isImmediate)
  245. {
  246. keyValuePair.Value.Close(0.01f, null);
  247. }
  248. else
  249. {
  250. keyValuePair.Value.Close(0.25f, null);
  251. }
  252. }
  253. }
  254. public T GetWindow<T>(string cachedName) where T : MonoBehaviour
  255. {
  256. if (!this.m_SwitchingWindowDic.ContainsKey(cachedName))
  257. {
  258. NDebug.Assert(string.Format("ウィンドウの配列には「{0}」\nというオブジェクトが存在しません", cachedName), false);
  259. Debug.LogError(string.Format("ウィンドウの配列には「{0}」\nというオブジェクトが存在しません", cachedName));
  260. return (T)((object)null);
  261. }
  262. NGUIWindow nguiwindow = this.m_SwitchingWindowDic[cachedName];
  263. T result;
  264. try
  265. {
  266. T t = nguiwindow as T;
  267. result = t;
  268. }
  269. catch (Exception ex)
  270. {
  271. NDebug.Assert(ex.ToString(), false);
  272. Debug.LogError(ex);
  273. result = (T)((object)null);
  274. }
  275. return result;
  276. }
  277. protected override void OnFinish()
  278. {
  279. SceneKasizukiMainMenu sceneKasizukiMainMenu = base.parent_mgr as SceneKasizukiMainMenu;
  280. if (sceneKasizukiMainMenu.moveScreen.next_label == this.edit_label_ && this.m_CharaMgr.GetMaid(0) != null)
  281. {
  282. this.m_CharaMgr.GetMaid(0).Visible = true;
  283. }
  284. if (!string.IsNullOrEmpty(sceneKasizukiMainMenu.moveScreen.next_label))
  285. {
  286. sceneKasizukiMainMenu.CallScreen("Move");
  287. }
  288. }
  289. public Action onClickOK
  290. {
  291. set
  292. {
  293. this.m_OnClickOK = value;
  294. }
  295. }
  296. public Action onClickCancel
  297. {
  298. set
  299. {
  300. this.m_OnClickCancel = value;
  301. }
  302. }
  303. public Maid selectMaid
  304. {
  305. get
  306. {
  307. return this.m_SelectMaid;
  308. }
  309. set
  310. {
  311. this.m_SelectMaid = value;
  312. }
  313. }
  314. public KasizukiCharacterSelectCtrl charaSelectMgr
  315. {
  316. get
  317. {
  318. return this.m_CharaSelectMgr;
  319. }
  320. }
  321. public Dictionary<string, UIButton> buttonDic
  322. {
  323. get
  324. {
  325. return this.m_ButtonDic;
  326. }
  327. }
  328. public static string BackUpSelectMaidGUID = string.Empty;
  329. public static float BackUpBarValue = 0f;
  330. private Action m_OnClickOK;
  331. private Action m_OnClickCancel;
  332. private Maid m_SelectMaid;
  333. private CharacterMgr m_CharaMgr;
  334. private KasizukiCharacterSelectCtrl m_CharaSelectMgr;
  335. private Dictionary<string, UIButton> m_ButtonDic = new Dictionary<string, UIButton>();
  336. private Dictionary<string, NGUIWindow> m_SwitchingWindowDic;
  337. private string edit_label_;
  338. }
  339. }