MaidTransferMain.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Runtime.CompilerServices;
  5. using MaidStatus;
  6. using MaidStatus.Old;
  7. using UnityEngine;
  8. [RequireComponent(typeof(UIPanel))]
  9. public class MaidTransferMain : WfFadeBehaviour
  10. {
  11. public void Awake()
  12. {
  13. this.statusMgr.Init();
  14. this.statusMgr.statusCtrl.gameObject.SetActive(true);
  15. this.loadBlackBG.SetActive(false);
  16. this.maidList = new List<Maid>(this.maidStorageObject.GetComponents<Maid>());
  17. this.charaSelectMgr.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
  18. this.deserializeCount = -1;
  19. this.initCount = 0;
  20. this.initCoroutine = this.InitializeMaid();
  21. base.StartCoroutine(this.initCoroutine);
  22. }
  23. private IEnumerator InitializeMaid()
  24. {
  25. this.initCount = 0;
  26. while (0 <= this.initCount)
  27. {
  28. this.maidList[this.initCount].InitializeStatus();
  29. this.initCount++;
  30. if (this.maidList.Count <= this.initCount)
  31. {
  32. this.initCount = -1;
  33. }
  34. yield return null;
  35. }
  36. yield break;
  37. }
  38. public void Call(string loadSaveFilePath)
  39. {
  40. if (this.initCount != -1)
  41. {
  42. base.StopCoroutine(this.initCoroutine);
  43. while (0 <= this.initCount)
  44. {
  45. this.maidList[this.initCount].InitializeStatus();
  46. this.initCount++;
  47. if (this.maidList.Count <= this.initCount)
  48. {
  49. this.initCount = -1;
  50. }
  51. }
  52. }
  53. if (this.deserializeCount != -1)
  54. {
  55. return;
  56. }
  57. this.loadSaveFilePath = loadSaveFilePath;
  58. OldDataConverter oldDataConverter = new OldDataConverter();
  59. this.oldDataList = oldDataConverter.OpenFile(loadSaveFilePath);
  60. base.StartCoroutine(this.InitializeDeserialize());
  61. }
  62. private IEnumerator InitializeDeserialize()
  63. {
  64. UICamera.InputEnable = false;
  65. this.deserializeCount = 0;
  66. GameMain.Instance.LoadIcon.NextLoadIcontImmediatelyDisplay();
  67. GameMain.Instance.LoadIcon.force_draw_new = true;
  68. GameMain.Instance.LoadIcon.SetForceDraw(true);
  69. GameMain.Instance.LoadIcon.is_center_draw = true;
  70. this.loadBlackBG.SetActive(true);
  71. foreach (OldDataConverter.MaidData oldData in this.oldDataList)
  72. {
  73. Texture2D iconTex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
  74. iconTex.LoadImage(oldData.ReadThumbnailByte());
  75. this.maidList[this.deserializeCount].status.Deserialize(oldData.statusReader, false);
  76. this.maidList[this.deserializeCount].status.leader = oldData.statusReader.leader;
  77. if (this.maidList[this.deserializeCount].GetThumIcon() != null)
  78. {
  79. UnityEngine.Object.DestroyImmediate(this.maidList[this.deserializeCount].GetThumIcon());
  80. }
  81. this.maidList[this.deserializeCount].SetThumIcon(iconTex);
  82. this.deserializeCount++;
  83. yield return null;
  84. }
  85. this.loadBlackBG.SetActive(false);
  86. GameMain.Instance.LoadIcon.is_center_draw = false;
  87. GameMain.Instance.LoadIcon.force_draw_new = false;
  88. GameMain.Instance.LoadIcon.SetForceDraw(false);
  89. this.deserializeCount = -1;
  90. this.transferPossibleMaidList = this.GetEnabledMaid();
  91. if (this.transferPossibleMaidList.Count == 0)
  92. {
  93. UICamera.InputEnable = true;
  94. GameMain.Instance.SysDlg.Show("移籍可能なメイドがいませんでした", SystemDialog.TYPE.OK, null, null);
  95. yield break;
  96. }
  97. List<Maid> list = this.transferPossibleMaidList;
  98. if (MaidTransferMain.<>f__mg$cache0 == null)
  99. {
  100. MaidTransferMain.<>f__mg$cache0 = new Comparison<Maid>(CharacterSelectManager.SortMaidStandardNoSchedule);
  101. }
  102. list.Sort(MaidTransferMain.<>f__mg$cache0);
  103. this.charaSelectMgr.SetCallBackMaidList(delegate(List<Maid> draw_list)
  104. {
  105. draw_list.Clear();
  106. foreach (Maid item in this.$this.transferPossibleMaidList)
  107. {
  108. draw_list.Add(item);
  109. }
  110. });
  111. this.charaSelectMgr.Create(CharacterSelectManager.Type.Select, 3, true);
  112. this.charaSelectMgr.big_thumbnail.Visible = false;
  113. this.charaSelectMgr.gameObject.SetActive(true);
  114. WfFadeJob.Create(this, this.loadUi, this.fadeTime, iTween.EaseType.easeOutSine);
  115. yield break;
  116. }
  117. public void Close()
  118. {
  119. WfFadeJob.Create(this.loadUi, this, this.fadeTime, iTween.EaseType.easeOutSine);
  120. }
  121. public void OnDestroy()
  122. {
  123. foreach (Maid maid in this.maidList)
  124. {
  125. if (!(maid == null))
  126. {
  127. if (maid.GetThumIcon() != null)
  128. {
  129. UnityEngine.Object.DestroyImmediate(maid.GetThumIcon());
  130. }
  131. }
  132. }
  133. }
  134. public void OnSelectChara(Maid select_maid)
  135. {
  136. if (select_maid == null)
  137. {
  138. return;
  139. }
  140. this.statusMgr.UpdateMaidStatus(select_maid);
  141. this.selectedMaid = select_maid;
  142. }
  143. public void ExecTransfer()
  144. {
  145. if (this.selectedMaid == null || string.IsNullOrEmpty(this.loadSaveFilePath))
  146. {
  147. return;
  148. }
  149. OldDataConverter.MaidData maidData = null;
  150. foreach (OldDataConverter.MaidData maidData2 in this.oldDataList)
  151. {
  152. if (this.selectedMaid.status.guid == maidData2.statusReader.guid)
  153. {
  154. maidData = maidData2;
  155. break;
  156. }
  157. }
  158. if (maidData != null)
  159. {
  160. this.maidManagementMain.Transfer(this.loadSaveFilePath, maidData);
  161. }
  162. }
  163. public List<Maid> GetEnabledMaid()
  164. {
  165. List<Maid> list = new List<Maid>();
  166. Dictionary<MaidStatus.Old.Personal, bool> dictionary = new Dictionary<MaidStatus.Old.Personal, bool>();
  167. dictionary.Add(MaidStatus.Old.Personal.Pure, MaidStatus.Personal.IsEnabled("Pure"));
  168. dictionary.Add(MaidStatus.Old.Personal.Pride, MaidStatus.Personal.IsEnabled("Pride"));
  169. dictionary.Add(MaidStatus.Old.Personal.Cool, MaidStatus.Personal.IsEnabled("Cool"));
  170. dictionary.Add(MaidStatus.Old.Personal.Yandere, MaidStatus.Personal.IsEnabled("Yandere"));
  171. dictionary.Add(MaidStatus.Old.Personal.Anesan, MaidStatus.Personal.IsEnabled("Anesan"));
  172. dictionary.Add(MaidStatus.Old.Personal.Genki, MaidStatus.Personal.IsEnabled("Genki"));
  173. dictionary.Add(MaidStatus.Old.Personal.Sadist, MaidStatus.Personal.IsEnabled("Sadist"));
  174. HashSet<string> hashSet = new HashSet<string>();
  175. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  176. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  177. {
  178. Maid stockMaid = characterMgr.GetStockMaid(i);
  179. if (stockMaid != null && !hashSet.Contains(stockMaid.status.guid))
  180. {
  181. hashSet.Add(stockMaid.status.guid);
  182. }
  183. }
  184. for (int j = 0; j < this.oldDataList.Count; j++)
  185. {
  186. StatusReader statusReader = this.oldDataList[j].statusReader;
  187. if (!statusReader.isRentalMaid && dictionary[statusReader.personal])
  188. {
  189. if (!hashSet.Contains(statusReader.guid))
  190. {
  191. list.Add(this.maidList[j]);
  192. }
  193. }
  194. }
  195. return list;
  196. }
  197. public override void OnUpdateFadeIn(float val)
  198. {
  199. this.alpha = val;
  200. }
  201. public override void OnUpdateFadeOut(float val)
  202. {
  203. this.alpha = val;
  204. }
  205. public virtual float alpha
  206. {
  207. set
  208. {
  209. if (this.targetPanels != null && 0 < this.targetPanels.Length)
  210. {
  211. foreach (UIPanel uipanel in this.targetPanels)
  212. {
  213. if (uipanel != null)
  214. {
  215. uipanel.alpha = value;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. [SerializeField]
  222. public GameObject maidStorageObject;
  223. [SerializeField]
  224. public float fadeTime;
  225. [SerializeField]
  226. private WfFadeBehaviour loadUi;
  227. [SerializeField]
  228. private GameObject loadBlackBG;
  229. [SerializeField]
  230. private MaidManagementMain maidManagementMain;
  231. [SerializeField]
  232. private CharacterSelectManager charaSelectMgr;
  233. [SerializeField]
  234. private CharaSelectStatusMgr statusMgr;
  235. [SerializeField]
  236. public UIPanel[] targetPanels;
  237. public string loadSaveFilePath;
  238. private List<Maid> maidList = new List<Maid>();
  239. private List<OldDataConverter.MaidData> oldDataList;
  240. private List<Maid> transferPossibleMaidList = new List<Maid>();
  241. private Maid selectedMaid;
  242. private IEnumerator initCoroutine;
  243. private int initCount;
  244. private int deserializeCount;
  245. [CompilerGenerated]
  246. private static Comparison<Maid> <>f__mg$cache0;
  247. }