MaidItemWindow.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. public class MaidItemWindow : BaseMaidPhotoWindow
  6. {
  7. public override void Awake()
  8. {
  9. base.Awake();
  10. PhotoMaidItemData.Create();
  11. this.tab_panel_ = this.ContentGrid.GetComponentInChildren<UIWFTabPanel>();
  12. this.scroll_view_ = NGUITools.FindInParents<UIScrollView>(this.ContentGrid.transform);
  13. this.PopupList.onChangePopUpListValue.Add(new Action<KeyValuePair<string, UnityEngine.Object>>(this.OnChangePopUpList));
  14. UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent<BoxCollider>().enabled = false;
  15. this.tmp_parent_ = new GameObject();
  16. this.tmp_parent_.name = "一時置き場";
  17. this.tmp_parent_.transform.SetParent(this.ContentGrid.transform.parent, false);
  18. for (int i = 0; i < PhotoMaidItemData.data.Count; i++)
  19. {
  20. GameObject gameObject = Utility.CreatePrefab(this.tmp_parent_, "ScenePhotoMode/WindowListItem", true);
  21. gameObject.name = PhotoMaidItemData.data[i].id.ToString();
  22. gameObject.GetComponentInChildren<UILabel>().text = PhotoMaidItemData.data[i].name;
  23. EventDelegate.Add(gameObject.GetComponent<UIWFTabButton>().onSelect, new EventDelegate.Callback(this.OnSelectItem));
  24. }
  25. this.tmp_parent_.SetActive(false);
  26. }
  27. public override void Start()
  28. {
  29. base.Start();
  30. this.UpdateChildren();
  31. }
  32. public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
  33. {
  34. base.OnMaidAddEvent(maid, is_deserialize_load);
  35. if (maid == null || maid.boMAN)
  36. {
  37. return;
  38. }
  39. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(maid);
  40. if (!is_deserialize_load || maidStoreData.Count <= 0)
  41. {
  42. for (int i = 0; i < PhotoMaidItemData.data.Count; i++)
  43. {
  44. PhotoMaidItemData photoMaidItemData = PhotoMaidItemData.data[i];
  45. if (photoMaidItemData.init_item)
  46. {
  47. maidStoreData[photoMaidItemData.category] = photoMaidItemData.id.ToString();
  48. }
  49. }
  50. }
  51. else
  52. {
  53. Dictionary<string, string> dictionary = new Dictionary<string, string>();
  54. foreach (KeyValuePair<string, string> keyValuePair in maidStoreData)
  55. {
  56. if (PhotoMaidItemData.Get(long.Parse(keyValuePair.Value)) == null)
  57. {
  58. for (int j = 0; j < PhotoMaidItemData.data.Count; j++)
  59. {
  60. if (keyValuePair.Key == PhotoMaidItemData.data[j].category && PhotoMaidItemData.data[j].init_item)
  61. {
  62. dictionary[keyValuePair.Key] = PhotoMaidItemData.data[j].id.ToString();
  63. break;
  64. }
  65. }
  66. }
  67. }
  68. foreach (KeyValuePair<string, string> keyValuePair2 in dictionary)
  69. {
  70. maidStoreData[keyValuePair2.Key] = keyValuePair2.Value;
  71. }
  72. }
  73. foreach (KeyValuePair<string, string> keyValuePair3 in maidStoreData)
  74. {
  75. PhotoMaidItemData photoMaidItemData2 = PhotoMaidItemData.Get(long.Parse(keyValuePair3.Value));
  76. if (photoMaidItemData2 != null)
  77. {
  78. photoMaidItemData2.Apply(maid);
  79. }
  80. }
  81. }
  82. public override void OnMaidRemoveEventPrev(Maid maid)
  83. {
  84. base.OnMaidRemoveEventPrev(maid);
  85. if (maid == null || maid.boMAN)
  86. {
  87. return;
  88. }
  89. PhotoMaidItemData.Clear(maid);
  90. }
  91. public override void OnMaidChangeEvent(Maid maid)
  92. {
  93. base.OnMaidChangeEvent(maid);
  94. if (maid == null || maid.boMAN)
  95. {
  96. UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent<BoxCollider>().enabled = false;
  97. this.PopupList.popup_value_list = null;
  98. this.PopupList.SetPopupValue(this.PopupList.popup_value_list[0].Key);
  99. }
  100. else
  101. {
  102. UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent<BoxCollider>().enabled = true;
  103. if (this.PopupList.popup_value_list.Count == 1)
  104. {
  105. this.PopupList.popup_value_list = PhotoMaidItemData.popup_category_list;
  106. this.PopupList.SetPopupValue(this.PopupList.popup_value_list[0].Key);
  107. }
  108. else
  109. {
  110. this.PopupList.SetPopupValue(this.PopupList.popup_select_value.Key);
  111. }
  112. }
  113. }
  114. protected void OnChangePopUpList(KeyValuePair<string, UnityEngine.Object> popup_val)
  115. {
  116. List<Transform> childList = this.ContentGrid.GetChildList();
  117. for (int i = 0; i < childList.Count; i++)
  118. {
  119. childList[i].GetComponent<UIWFTabButton>().SetSelect(false);
  120. childList[i].SetParent(this.tmp_parent_.transform, false);
  121. }
  122. this.ContentGrid.transform.DetachChildren();
  123. this.tab_panel_.ResetSelect();
  124. this.tab_panel_.UpdateChildren();
  125. if (!PhotoMaidItemData.category_list.ContainsKey(popup_val.Key))
  126. {
  127. this.ContentGrid.Reposition();
  128. this.scroll_view_.ResetPosition();
  129. return;
  130. }
  131. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  132. long num = long.Parse(maidStoreData[popup_val.Key]);
  133. UIWFTabButton uiwftabButton = null;
  134. List<PhotoMaidItemData> list = PhotoMaidItemData.category_list[popup_val.Key];
  135. for (int j = 0; j < list.Count; j++)
  136. {
  137. GameObject childObject = UTY.GetChildObject(this.tmp_parent_, list[j].id.ToString(), false);
  138. childObject.transform.SetParent(this.ContentGrid.transform, false);
  139. if (num == long.Parse(childObject.name))
  140. {
  141. uiwftabButton = childObject.GetComponent<UIWFTabButton>();
  142. }
  143. }
  144. this.tab_panel_.UpdateChildren();
  145. this.ContentGrid.Reposition();
  146. this.scroll_view_.ResetPosition();
  147. if (uiwftabButton != null)
  148. {
  149. this.tab_panel_.Select(uiwftabButton);
  150. }
  151. }
  152. private void OnSelectItem()
  153. {
  154. if (UIWFSelectButton.current == null || base.mgr.select_maid == null || !UIWFSelectButton.current.isSelected)
  155. {
  156. return;
  157. }
  158. PhotoMaidItemData photoMaidItemData = PhotoMaidItemData.Get(long.Parse(UIWFTabButton.current.name));
  159. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  160. maidStoreData[this.PopupList.popup_select_value.Key] = photoMaidItemData.id.ToString();
  161. photoMaidItemData.Apply(base.mgr.select_maid);
  162. }
  163. public override void OnDeserializeEvent()
  164. {
  165. }
  166. public WindowPartsPopUpList PopupList;
  167. public UIGrid ContentGrid;
  168. private UIScrollView scroll_view_;
  169. private GameObject tmp_parent_;
  170. private UIWFTabPanel tab_panel_;
  171. }