UndressingManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidExtension;
  4. using UnityEngine;
  5. public class UndressingManager : MonoBehaviour
  6. {
  7. public void Awake()
  8. {
  9. for (int i = 0; i < this.UnitDataList.Count; i++)
  10. {
  11. UndressingManager.UnitData unitData = this.UnitDataList[i];
  12. NDebug.Assert(unitData.ButtonObject != null, "button object null error.");
  13. UndressingManager.UndressingData undressingData = new UndressingManager.UndressingData();
  14. undressingData.unit_type = unitData.UnitType;
  15. undressingData.button_object = unitData.ButtonObject;
  16. undressingData.button_default_color = unitData.ButtonObject.defaultColor;
  17. EventDelegate eventDelegate = new EventDelegate(this, "OnClickButton");
  18. eventDelegate.parameters[0].value = undressingData;
  19. undressingData.button_object.onClick.Add(eventDelegate);
  20. this.unit_dic_.Add(unitData.UnitType, undressingData);
  21. }
  22. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("yotogi_play_undressing.nei"))
  23. {
  24. using (CsvParser csvParser = new CsvParser())
  25. {
  26. bool condition = csvParser.Open(afileBase);
  27. NDebug.Assert(condition, "file open error[yotogi_play_undressing.nei]");
  28. for (int j = 1; j < csvParser.max_cell_y; j++)
  29. {
  30. if (csvParser.IsCellToExistData(0, j))
  31. {
  32. int num = 0;
  33. string cellAsString = csvParser.GetCellAsString(num++, j);
  34. string cellAsString2 = csvParser.GetCellAsString(num++, j);
  35. UndressingManager.UnitType key = UndressingManager.UnitType.全着衣;
  36. try
  37. {
  38. key = (UndressingManager.UnitType)Enum.Parse(typeof(UndressingManager.UnitType), cellAsString2);
  39. }
  40. catch (ArgumentException)
  41. {
  42. NDebug.Assert("enum parse error.\n[" + cellAsString2 + "] Convert to UnitData.Type Failed.", false);
  43. }
  44. if (this.unit_dic_.ContainsKey(key))
  45. {
  46. UndressingManager.UndressingData undressingData2 = this.unit_dic_[key];
  47. string cellAsString3 = csvParser.GetCellAsString(num++, j);
  48. if (!string.IsNullOrEmpty(cellAsString3))
  49. {
  50. string[] array = cellAsString3.Split(new char[]
  51. {
  52. ','
  53. });
  54. for (int k = 0; k < array.Length; k++)
  55. {
  56. TBody.SlotID item = TBody.SlotID.wear;
  57. try
  58. {
  59. item = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), array[k]);
  60. }
  61. catch
  62. {
  63. NDebug.Assert("TBody.SlotID enum parse error.\n" + array[k], false);
  64. }
  65. undressingData2.target_sloat_id_list.Add(item);
  66. }
  67. }
  68. undressingData2.call_scenario = csvParser.GetCellAsString(num++, j);
  69. cellAsString3 = csvParser.GetCellAsString(num++, j);
  70. if (!string.IsNullOrEmpty(cellAsString3))
  71. {
  72. string[] array2 = cellAsString3.Split(new char[]
  73. {
  74. ','
  75. });
  76. for (int l = 0; l < array2.Length; l++)
  77. {
  78. MPN mpn = MPN.null_mpn;
  79. try
  80. {
  81. mpn = (MPN)Enum.Parse(typeof(MPN), array2[l]);
  82. }
  83. catch
  84. {
  85. NDebug.Assert("mpn enum parse error.\n" + array2[l], false);
  86. }
  87. if (mpn != MPN.null_mpn)
  88. {
  89. undressingData2.target_newbody_mpn_id_list.Add(mpn);
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98. if (this.hannugiButton != null)
  99. {
  100. EventDelegate.Add(this.hannugiButton.onClick, delegate()
  101. {
  102. if (this.all_maid_data_ == null || this.all_maid_data_.Length <= 0)
  103. {
  104. return;
  105. }
  106. bool flag = false;
  107. foreach (Maid maid in this.all_maid_data_)
  108. {
  109. if (!(maid == null) && maid.IsCrcBody && maid.mekureController.IsSupportedCostumeType(MaidCostumeChangeController.CostumeType.Hadake))
  110. {
  111. flag = maid.mekureController.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake);
  112. break;
  113. }
  114. }
  115. foreach (Maid maid2 in this.all_maid_data_)
  116. {
  117. if (!(maid2 == null))
  118. {
  119. maid2.mekureController.SetEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake, !flag, null);
  120. }
  121. }
  122. this.UpdateHannugiButton();
  123. });
  124. }
  125. }
  126. public void UpdateHannugiButton()
  127. {
  128. if (this.hannugiButton == null)
  129. {
  130. return;
  131. }
  132. foreach (Maid maid in this.all_maid_data_)
  133. {
  134. if (!(maid == null) && maid.IsCrcBody && maid.mekureController.IsSupportedCostumeType(MaidCostumeChangeController.CostumeType.Hadake))
  135. {
  136. this.hannugiButton.isEnabled = maid.mekureController.IsSupportedCostumeType(MaidCostumeChangeController.CostumeType.Hadake);
  137. if (this.hannugiButton.isEnabled)
  138. {
  139. bool flag = maid.mekureController.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake);
  140. Color defaultColor = this.hannugiButton.defaultColor;
  141. defaultColor.a = ((!flag) ? 0.5f : 1f);
  142. this.hannugiButton.defaultColor = defaultColor;
  143. break;
  144. }
  145. }
  146. }
  147. }
  148. public void SetCallBackEvent(UndressingManager.OnClickEventDelegate func)
  149. {
  150. this.onclick_event_ = func;
  151. }
  152. public void SetMaid(Maid maid, Maid[] linked_maid_array)
  153. {
  154. this.maid_ = maid;
  155. UIGrid component = base.GetComponent<UIGrid>();
  156. if (this.maid_.IsCrcBody)
  157. {
  158. component.cellWidth = 92f;
  159. if (this.hannugiButton != null)
  160. {
  161. this.hannugiButton.gameObject.SetActive(true);
  162. }
  163. }
  164. else
  165. {
  166. component.cellWidth = 100f;
  167. if (this.hannugiButton != null)
  168. {
  169. this.hannugiButton.gameObject.SetActive(false);
  170. }
  171. }
  172. Behaviour behaviour = component;
  173. bool flag = true;
  174. component.repositionNow = flag;
  175. behaviour.enabled = flag;
  176. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair in this.unit_dic_)
  177. {
  178. UndressingManager.UndressingData value = keyValuePair.Value;
  179. value.UpdateMaskStatus(maid);
  180. }
  181. if (linked_maid_array == null || linked_maid_array.Length == 0)
  182. {
  183. this.all_maid_data_ = new Maid[1];
  184. this.all_maid_data_[0] = this.maid_;
  185. }
  186. else
  187. {
  188. List<Maid> list = new List<Maid>();
  189. foreach (Maid maid2 in linked_maid_array)
  190. {
  191. if (!(maid2 == this.maid_))
  192. {
  193. list.Add(maid2);
  194. }
  195. }
  196. list.Insert(0, this.maid_);
  197. this.all_maid_data_ = list.ToArray();
  198. }
  199. this.UpdateHannugiButton();
  200. this.ApplyAllMaid();
  201. }
  202. public void SetMaskMode(UndressingManager.UnitType type, UndressingManager.MaskStatus status)
  203. {
  204. if (!this.unit_dic_.ContainsKey(type))
  205. {
  206. return;
  207. }
  208. UndressingManager.UndressingData undressingData = this.unit_dic_[type];
  209. if (undressingData.unit_type != UndressingManager.UnitType.全脱衣)
  210. {
  211. this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode = UndressingManager.MaskStatus.Off;
  212. }
  213. if (undressingData.unit_type != UndressingManager.UnitType.全着衣)
  214. {
  215. this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode = UndressingManager.MaskStatus.Off;
  216. }
  217. undressingData.mask_mode = status;
  218. this.ApplyAllMaid();
  219. if (this.onclick_event_ != null)
  220. {
  221. this.onclick_event_(undressingData.call_scenario);
  222. }
  223. }
  224. public UndressingManager.UndressingData GetUndressingData(UndressingManager.UnitType unitType)
  225. {
  226. return (!this.unit_dic_.ContainsKey(unitType)) ? null : this.unit_dic_[unitType];
  227. }
  228. public void OnClickButton(UndressingManager.UndressingData unit_data)
  229. {
  230. UndressingManager.MaskStatus status = (unit_data.mask_mode != UndressingManager.MaskStatus.On) ? UndressingManager.MaskStatus.On : UndressingManager.MaskStatus.Off;
  231. this.SetMaskMode(unit_data.unit_type, status);
  232. }
  233. private void ApplyAllMaid()
  234. {
  235. if (this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode == UndressingManager.MaskStatus.On)
  236. {
  237. for (int i = 0; i < this.all_maid_data_.Length; i++)
  238. {
  239. this.all_maid_data_[i].body0.SetMaskMode(TBody.MaskMode.Nude);
  240. }
  241. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair in this.unit_dic_)
  242. {
  243. UndressingManager.UndressingData value = keyValuePair.Value;
  244. if (value.unit_type != UndressingManager.UnitType.全脱衣 && value.unit_type != UndressingManager.UnitType.全着衣)
  245. {
  246. value.mask_mode = UndressingManager.MaskStatus.On;
  247. }
  248. }
  249. return;
  250. }
  251. if (this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode == UndressingManager.MaskStatus.On)
  252. {
  253. for (int j = 0; j < this.all_maid_data_.Length; j++)
  254. {
  255. this.all_maid_data_[j].body0.SetMaskMode(TBody.MaskMode.None);
  256. }
  257. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair2 in this.unit_dic_)
  258. {
  259. UndressingManager.UndressingData value2 = keyValuePair2.Value;
  260. if (value2.unit_type != UndressingManager.UnitType.全脱衣 && value2.unit_type != UndressingManager.UnitType.全着衣)
  261. {
  262. value2.mask_mode = UndressingManager.MaskStatus.Off;
  263. }
  264. }
  265. return;
  266. }
  267. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair3 in this.unit_dic_)
  268. {
  269. UndressingManager.UndressingData value3 = keyValuePair3.Value;
  270. for (int k = 0; k < this.all_maid_data_.Length; k++)
  271. {
  272. value3.ApplyMask(this.all_maid_data_[k]);
  273. }
  274. value3.UpdateMaskStatus(this.maid_);
  275. }
  276. }
  277. [SerializeField]
  278. public List<UndressingManager.UnitData> UnitDataList = new List<UndressingManager.UnitData>();
  279. [SerializeField]
  280. private UIButton hannugiButton;
  281. private Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData> unit_dic_ = new Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData>();
  282. private Maid maid_;
  283. private Maid[] all_maid_data_;
  284. private UndressingManager.OnClickEventDelegate onclick_event_;
  285. public enum UnitType
  286. {
  287. 全脱衣,
  288. 全着衣,
  289. トップス,
  290. ボトムス,
  291. ブラジャ\u30FC,
  292. パンツ,
  293. ソックス,
  294. シュ\u30FCズ,
  295. ヘッドドレス,
  296. メガネ,
  297. 背中,
  298. 手袋,
  299. Max
  300. }
  301. public enum MaskStatus
  302. {
  303. On,
  304. Off
  305. }
  306. [Serializable]
  307. public class UnitData
  308. {
  309. public UndressingManager.UnitType UnitType;
  310. public UIButton ButtonObject;
  311. }
  312. public delegate void OnClickEventDelegate(string call_file);
  313. public class UndressingData
  314. {
  315. public UndressingManager.MaskStatus mask_mode
  316. {
  317. get
  318. {
  319. return this.button_mask_status_;
  320. }
  321. set
  322. {
  323. if (this.button_mask_status_ == value)
  324. {
  325. return;
  326. }
  327. this.button_mask_status_ = value;
  328. if (this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  329. {
  330. return;
  331. }
  332. if (this.button_mask_status_ == UndressingManager.MaskStatus.Off)
  333. {
  334. this.button_object.defaultColor = this.button_default_color;
  335. }
  336. else
  337. {
  338. Color defaultColor = this.button_default_color;
  339. defaultColor.a = 0.5f;
  340. this.button_object.defaultColor = defaultColor;
  341. }
  342. }
  343. }
  344. public void UpdateMaskStatus(Maid maid)
  345. {
  346. if (maid == null || maid.body0 == null || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  347. {
  348. return;
  349. }
  350. if (this.target_newbody_mpn_id_list[0] == MPN.acchead)
  351. {
  352. bool mask = maid.body0.GetMask(MPN.acchead);
  353. bool mask2 = maid.body0.GetMask(MPN.wear);
  354. }
  355. bool flag = false;
  356. if (maid.body0.IsCrcBody)
  357. {
  358. for (int i = 0; i < this.target_newbody_mpn_id_list.Count; i++)
  359. {
  360. if (maid.body0.GetSlotLoaded(this.target_newbody_mpn_id_list[i]))
  361. {
  362. flag = true;
  363. break;
  364. }
  365. }
  366. }
  367. else
  368. {
  369. for (int j = 0; j < this.target_sloat_id_list.Count; j++)
  370. {
  371. if (maid.body0.GetSlotLoaded(this.target_sloat_id_list[j]))
  372. {
  373. flag = true;
  374. break;
  375. }
  376. }
  377. }
  378. if (!flag)
  379. {
  380. this.button_object.defaultColor = this.button_object.disabledColor;
  381. this.button_object.isEnabled = false;
  382. return;
  383. }
  384. bool flag2 = true;
  385. if (maid.body0.IsCrcBody)
  386. {
  387. for (int k = 0; k < this.target_newbody_mpn_id_list.Count; k++)
  388. {
  389. if (maid.body0.GetMask(this.target_newbody_mpn_id_list[k]))
  390. {
  391. flag2 = false;
  392. break;
  393. }
  394. }
  395. }
  396. else
  397. {
  398. for (int l = 0; l < this.target_sloat_id_list.Count; l++)
  399. {
  400. if (maid.body0.GetMask(this.target_sloat_id_list[l]))
  401. {
  402. flag2 = false;
  403. break;
  404. }
  405. }
  406. }
  407. this.mask_mode = ((!flag2) ? UndressingManager.MaskStatus.Off : UndressingManager.MaskStatus.On);
  408. }
  409. public void ApplyMask(Maid[] maid_array)
  410. {
  411. if (maid_array == null)
  412. {
  413. return;
  414. }
  415. for (int i = 0; i < maid_array.Length; i++)
  416. {
  417. this.ApplyMask(maid_array[i]);
  418. }
  419. }
  420. public void ApplyMask(Maid maid)
  421. {
  422. if (maid == null || maid.body0 == null || !this.button_object.isEnabled || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  423. {
  424. return;
  425. }
  426. bool flag = this.mask_mode == UndressingManager.MaskStatus.On;
  427. if (maid.body0.IsCrcBody)
  428. {
  429. for (int i = 0; i < this.target_newbody_mpn_id_list.Count; i++)
  430. {
  431. maid.body0.SetMask(this.target_newbody_mpn_id_list[i], !flag);
  432. }
  433. }
  434. else
  435. {
  436. for (int j = 0; j < this.target_sloat_id_list.Count; j++)
  437. {
  438. maid.body0.SetMask(this.target_sloat_id_list[j], !flag);
  439. }
  440. }
  441. }
  442. public UndressingManager.UnitType unit_type;
  443. public List<TBody.SlotID> target_sloat_id_list = new List<TBody.SlotID>();
  444. public List<MPN> target_newbody_mpn_id_list = new List<MPN>();
  445. public string call_scenario = string.Empty;
  446. public Color button_default_color;
  447. public UIButton button_object;
  448. private UndressingManager.MaskStatus button_mask_status_ = UndressingManager.MaskStatus.Off;
  449. }
  450. }