LoadReplaceMaid.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using UnityEngine;
  5. using wf;
  6. public class LoadReplaceMaid : MonoBehaviour
  7. {
  8. public void Awake()
  9. {
  10. this.chara_mgr_ = GameMain.Instance.CharacterMgr;
  11. EventDelegate.Add(this.OKButton.onClick, new EventDelegate.Callback(this.OnClickOK));
  12. this.ui_panel_ = base.gameObject.GetComponentInChildren<UIPanel>();
  13. this.positionBackup.Add(this.OKButton.transform, this.OKButton.transform.localPosition);
  14. this.bgBackupSize = new Vector2((float)this.bgWidget.width, (float)this.bgWidget.height);
  15. }
  16. public void OnEnable()
  17. {
  18. if (this.scroll_view_ != null)
  19. {
  20. return;
  21. }
  22. this.scroll_view_ = NGUITools.FindInParents<UIScrollView>(this.ContentGrid.transform);
  23. this.ui_panel_.alpha = 0f;
  24. }
  25. public bool CheckAndStart(List<KeyValuePair<string, string>> check_guid_maid_list)
  26. {
  27. if (!base.gameObject.activeSelf)
  28. {
  29. base.gameObject.SetActive(true);
  30. }
  31. this.not_exist_maid_list_.Clear();
  32. this.already_used_maid_list_.Clear();
  33. this.replace_result_dic_.Clear();
  34. for (int i = 0; i < check_guid_maid_list.Count; i++)
  35. {
  36. string key = check_guid_maid_list[i].Key;
  37. Maid stockMaid = this.chara_mgr_.GetStockMaid(key);
  38. if (stockMaid == null)
  39. {
  40. this.not_exist_maid_list_.Add(new KeyValuePair<string, string>(check_guid_maid_list[i].Key, check_guid_maid_list[i].Value));
  41. }
  42. else
  43. {
  44. this.already_used_maid_list_.Add(stockMaid);
  45. }
  46. }
  47. bool flag = 0 < this.not_exist_maid_list_.Count;
  48. if (flag)
  49. {
  50. this.ui_panel_.alpha = 1f;
  51. this.SelectReplaceMaid();
  52. }
  53. else
  54. {
  55. this.ui_panel_.alpha = 0f;
  56. base.gameObject.SetActive(false);
  57. if (this.OnReplaceEndEvent != null)
  58. {
  59. this.OnReplaceEndEvent(this.replace_result_dic_);
  60. }
  61. }
  62. return flag;
  63. }
  64. private void ChangeMode(int not_exist_maid_count, string maid_name)
  65. {
  66. if (ScenePresetWindow.SelectData != null)
  67. {
  68. this.bgWidget.SetDimensions(818, 500);
  69. Vector3 vector = this.positionBackup[this.OKButton.transform];
  70. this.OKButton.transform.localPosition = new Vector3(1140f, vector.y, vector.z);
  71. if (0 <= ScenePresetWindow.SelectData.charaFocusImages.Length - not_exist_maid_count && ScenePresetWindow.SelectData.charaFocusImages.Length - not_exist_maid_count < ScenePresetWindow.SelectData.charaFocusImages.Length)
  72. {
  73. this.ui2dSprite.gameObject.SetActive(true);
  74. int num = ScenePresetWindow.SelectData.charaFocusImages.Length - not_exist_maid_count;
  75. string str = ScenePresetWindow.SelectData.charaFocusImages[num];
  76. Texture2D texture2D = ImportCM.CreateTexture(str + ".tex");
  77. Sprite sprite2D = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
  78. if (this.ui2dSprite.sprite2D != null && this.ui2dSprite.sprite2D.texture != null)
  79. {
  80. UnityEngine.Object.DestroyImmediate(this.ui2dSprite.sprite2D.texture);
  81. }
  82. this.ui2dSprite.sprite2D = sprite2D;
  83. this.ui2dSprite.SetDimensions(texture2D.width, texture2D.height);
  84. this.TextLabel.text = "ポジション" + (num + 1) + "に読み込むメイドを選択してください。";
  85. }
  86. }
  87. else
  88. {
  89. this.bgWidget.SetDimensions((int)this.bgBackupSize.x, (int)this.bgBackupSize.y);
  90. this.OKButton.transform.localPosition = this.positionBackup[this.OKButton.transform];
  91. this.ui2dSprite.gameObject.SetActive(false);
  92. this.TextLabel.text = string.Format(LoadReplaceMaid.kText, maid_name);
  93. }
  94. }
  95. private bool SelectReplaceMaid()
  96. {
  97. this.select_maid_ = null;
  98. if (this.not_exist_maid_list_.Count <= 0)
  99. {
  100. return false;
  101. }
  102. this.ChangeMode(this.not_exist_maid_list_.Count, this.not_exist_maid_list_[0].Value);
  103. List<Maid> list = new List<Maid>();
  104. for (int i = 0; i < this.chara_mgr_.GetStockMaidCount(); i++)
  105. {
  106. if (!this.already_used_maid_list_.Contains(this.chara_mgr_.GetStockMaid(i)))
  107. {
  108. list.Add(this.chara_mgr_.GetStockMaid(i));
  109. }
  110. }
  111. List<Maid> list2 = list;
  112. if (LoadReplaceMaid.<>f__mg$cache0 == null)
  113. {
  114. LoadReplaceMaid.<>f__mg$cache0 = new Comparison<Maid>(CharacterSelectManager.SortMaidStandardNoSchedule);
  115. }
  116. list2.Sort(LoadReplaceMaid.<>f__mg$cache0);
  117. list.Insert(0, null);
  118. for (int j = 0; j < this.ContentGrid.transform.childCount; j++)
  119. {
  120. UnityEngine.Object.Destroy(this.ContentGrid.transform.GetChild(j).gameObject);
  121. }
  122. this.ContentGrid.gameObject.transform.DetachChildren();
  123. this.TabPanel.ResetSelect();
  124. UIWFTabButton uiwftabButton = null;
  125. for (int k = 0; k < list.Count; k++)
  126. {
  127. GameObject f_goParent;
  128. if (list[k] == null)
  129. {
  130. f_goParent = Utility.CreatePrefab(this.ContentGrid.gameObject, "ScenePhotoMode/SimpleMaidPlateSelectNot", true);
  131. }
  132. else
  133. {
  134. f_goParent = Utility.CreatePrefab(this.ContentGrid.gameObject, "ScenePhotoMode/SimpleMaidPlateSelect", true);
  135. }
  136. SimpleMaidPlate component = UTY.GetChildObject(f_goParent, "Plate", false).GetComponent<SimpleMaidPlate>();
  137. component.SetMaidData(list[k]);
  138. UIWFTabButton component2 = UTY.GetChildObject(f_goParent, "Plate/Button", false).GetComponent<UIWFTabButton>();
  139. EventDelegate.Add(component2.onSelect, new EventDelegate.Callback(this.OnSelectMaid));
  140. if (list[k] == null)
  141. {
  142. component2.gameObject.name = string.Empty;
  143. }
  144. else
  145. {
  146. component2.gameObject.name = list[k].status.guid;
  147. }
  148. if (uiwftabButton == null)
  149. {
  150. uiwftabButton = component2;
  151. }
  152. }
  153. this.ContentGrid.Reposition();
  154. this.scroll_view_.ResetPosition();
  155. this.TabPanel.UpdateChildren();
  156. this.TabPanel.Select(uiwftabButton);
  157. return true;
  158. }
  159. public void OnClickOK()
  160. {
  161. this.replace_result_dic_.Add(this.not_exist_maid_list_[0].Key, this.select_maid_);
  162. this.not_exist_maid_list_.RemoveAt(0);
  163. this.already_used_maid_list_.Add(this.select_maid_);
  164. this.select_maid_ = null;
  165. if (!this.SelectReplaceMaid())
  166. {
  167. this.ui_panel_.alpha = 0f;
  168. base.gameObject.SetActive(false);
  169. if (this.OnReplaceEndEvent != null)
  170. {
  171. this.OnReplaceEndEvent(this.replace_result_dic_);
  172. }
  173. }
  174. }
  175. public void OnSelectMaid()
  176. {
  177. if (!UIWFSelectButton.current.isSelected)
  178. {
  179. return;
  180. }
  181. if (string.IsNullOrEmpty(UIWFSelectButton.current.gameObject.name))
  182. {
  183. this.select_maid_ = null;
  184. }
  185. else
  186. {
  187. this.select_maid_ = this.chara_mgr_.GetStockMaid(UIWFSelectButton.current.gameObject.name);
  188. }
  189. }
  190. public UIWFTabPanel TabPanel;
  191. public UIGrid ContentGrid;
  192. public UILabel TextLabel;
  193. public UIButton OKButton;
  194. public UIWidget bgWidget;
  195. public UI2DSprite ui2dSprite;
  196. public Action<Dictionary<string, Maid>> OnReplaceEndEvent;
  197. private Dictionary<Transform, Vector3> positionBackup = new Dictionary<Transform, Vector3>();
  198. private Vector2 bgBackupSize;
  199. private static string kText = "メイド「{0}」が見つかりませんでした。\n変わりとして読み込むメイドを選択してください。";
  200. private CharacterMgr chara_mgr_;
  201. private List<KeyValuePair<string, string>> not_exist_maid_list_ = new List<KeyValuePair<string, string>>();
  202. private HashSet<Maid> already_used_maid_list_ = new HashSet<Maid>();
  203. private Dictionary<string, Maid> replace_result_dic_ = new Dictionary<string, Maid>();
  204. private Maid select_maid_;
  205. private UIScrollView scroll_view_;
  206. private UIPanel ui_panel_;
  207. [CompilerGenerated]
  208. private static Comparison<Maid> <>f__mg$cache0;
  209. }