UndressingManager.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class UndressingManager : MonoBehaviour
  5. {
  6. public void Awake()
  7. {
  8. for (int i = 0; i < this.UnitDataList.Count; i++)
  9. {
  10. UndressingManager.UnitData unitData = this.UnitDataList[i];
  11. NDebug.Assert(unitData.ButtonObject != null, "button object null error.");
  12. UndressingManager.UndressingData undressingData = new UndressingManager.UndressingData();
  13. undressingData.unit_type = unitData.UnitType;
  14. undressingData.button_object = unitData.ButtonObject;
  15. undressingData.button_default_color = unitData.ButtonObject.defaultColor;
  16. EventDelegate eventDelegate = new EventDelegate(this, "OnClickButton");
  17. eventDelegate.parameters[0].value = undressingData;
  18. undressingData.button_object.onClick.Add(eventDelegate);
  19. this.unit_dic_.Add(unitData.UnitType, undressingData);
  20. }
  21. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("yotogi_play_undressing.nei"))
  22. {
  23. using (CsvParser csvParser = new CsvParser())
  24. {
  25. bool condition = csvParser.Open(afileBase);
  26. NDebug.Assert(condition, "file open error[yotogi_play_undressing.nei]");
  27. for (int j = 1; j < csvParser.max_cell_y; j++)
  28. {
  29. if (csvParser.IsCellToExistData(0, j))
  30. {
  31. int num = 0;
  32. string cellAsString = csvParser.GetCellAsString(num++, j);
  33. string cellAsString2 = csvParser.GetCellAsString(num++, j);
  34. UndressingManager.UnitType key = UndressingManager.UnitType.全着衣;
  35. try
  36. {
  37. key = (UndressingManager.UnitType)Enum.Parse(typeof(UndressingManager.UnitType), cellAsString2);
  38. }
  39. catch (ArgumentException)
  40. {
  41. NDebug.Assert("enum parse error.\n[" + cellAsString2 + "] Convert to UnitData.Type Failed.", false);
  42. }
  43. if (this.unit_dic_.ContainsKey(key))
  44. {
  45. UndressingManager.UndressingData undressingData2 = this.unit_dic_[key];
  46. string cellAsString3 = csvParser.GetCellAsString(num++, j);
  47. if (!string.IsNullOrEmpty(cellAsString3))
  48. {
  49. string[] array = cellAsString3.Split(new char[]
  50. {
  51. ','
  52. });
  53. for (int k = 0; k < array.Length; k++)
  54. {
  55. TBody.SlotID item = TBody.SlotID.wear;
  56. try
  57. {
  58. item = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), array[k]);
  59. }
  60. catch
  61. {
  62. NDebug.Assert("TBody.SlotID enum parse error.\n" + array[k], false);
  63. }
  64. undressingData2.target_sloat_id_list.Add(item);
  65. }
  66. }
  67. undressingData2.call_scenario = csvParser.GetCellAsString(num++, j);
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. public void SetCallBackEvent(UndressingManager.OnClickEventDelegate func)
  75. {
  76. this.onclick_event_ = func;
  77. }
  78. public void SetMaid(Maid maid, Maid[] linked_maid_array)
  79. {
  80. this.maid_ = maid;
  81. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair in this.unit_dic_)
  82. {
  83. UndressingManager.UndressingData value = keyValuePair.Value;
  84. value.UpdateMaskStatus(maid);
  85. }
  86. if (linked_maid_array == null || linked_maid_array.Length == 0)
  87. {
  88. this.all_maid_data_ = new Maid[1];
  89. this.all_maid_data_[0] = this.maid_;
  90. }
  91. else
  92. {
  93. List<Maid> list = new List<Maid>();
  94. foreach (Maid maid2 in linked_maid_array)
  95. {
  96. if (!(maid2 == this.maid_))
  97. {
  98. list.Add(maid2);
  99. }
  100. }
  101. list.Insert(0, this.maid_);
  102. this.all_maid_data_ = list.ToArray();
  103. }
  104. this.ApplyAllMaid();
  105. }
  106. public void SetMaskMode(UndressingManager.UnitType type, UndressingManager.MaskStatus status)
  107. {
  108. if (!this.unit_dic_.ContainsKey(type))
  109. {
  110. return;
  111. }
  112. UndressingManager.UndressingData undressingData = this.unit_dic_[type];
  113. if (undressingData.unit_type != UndressingManager.UnitType.全脱衣)
  114. {
  115. this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode = UndressingManager.MaskStatus.Off;
  116. }
  117. if (undressingData.unit_type != UndressingManager.UnitType.全着衣)
  118. {
  119. this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode = UndressingManager.MaskStatus.Off;
  120. }
  121. undressingData.mask_mode = status;
  122. this.ApplyAllMaid();
  123. if (this.onclick_event_ != null)
  124. {
  125. this.onclick_event_(undressingData.call_scenario);
  126. }
  127. }
  128. private void OnClickButton(UndressingManager.UndressingData unit_data)
  129. {
  130. UndressingManager.MaskStatus status = (unit_data.mask_mode != UndressingManager.MaskStatus.On) ? UndressingManager.MaskStatus.On : UndressingManager.MaskStatus.Off;
  131. this.SetMaskMode(unit_data.unit_type, status);
  132. }
  133. private void ApplyAllMaid()
  134. {
  135. if (this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode == UndressingManager.MaskStatus.On)
  136. {
  137. for (int i = 0; i < this.all_maid_data_.Length; i++)
  138. {
  139. this.all_maid_data_[i].body0.SetMaskMode(TBody.MaskMode.Nude);
  140. }
  141. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair in this.unit_dic_)
  142. {
  143. UndressingManager.UndressingData value = keyValuePair.Value;
  144. if (value.unit_type != UndressingManager.UnitType.全脱衣 && value.unit_type != UndressingManager.UnitType.全着衣)
  145. {
  146. value.mask_mode = UndressingManager.MaskStatus.On;
  147. }
  148. }
  149. return;
  150. }
  151. if (this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode == UndressingManager.MaskStatus.On)
  152. {
  153. for (int j = 0; j < this.all_maid_data_.Length; j++)
  154. {
  155. this.all_maid_data_[j].body0.SetMaskMode(TBody.MaskMode.None);
  156. }
  157. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair2 in this.unit_dic_)
  158. {
  159. UndressingManager.UndressingData value2 = keyValuePair2.Value;
  160. if (value2.unit_type != UndressingManager.UnitType.全脱衣 && value2.unit_type != UndressingManager.UnitType.全着衣)
  161. {
  162. value2.mask_mode = UndressingManager.MaskStatus.Off;
  163. }
  164. }
  165. return;
  166. }
  167. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair3 in this.unit_dic_)
  168. {
  169. UndressingManager.UndressingData value3 = keyValuePair3.Value;
  170. for (int k = 0; k < this.all_maid_data_.Length; k++)
  171. {
  172. value3.ApplyMask(this.all_maid_data_[k]);
  173. }
  174. value3.UpdateMaskStatus(this.maid_);
  175. }
  176. }
  177. [SerializeField]
  178. public List<UndressingManager.UnitData> UnitDataList = new List<UndressingManager.UnitData>();
  179. private Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData> unit_dic_ = new Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData>();
  180. private Maid maid_;
  181. private Maid[] all_maid_data_;
  182. private UndressingManager.OnClickEventDelegate onclick_event_;
  183. public enum UnitType
  184. {
  185. 全脱衣,
  186. 全着衣,
  187. トップス,
  188. ボトムス,
  189. ブラジャ\u30FC,
  190. パンツ,
  191. ソックス,
  192. シュ\u30FCズ,
  193. ヘッドドレス,
  194. メガネ,
  195. 背中,
  196. 手袋,
  197. Max
  198. }
  199. public enum MaskStatus
  200. {
  201. On,
  202. Off
  203. }
  204. [Serializable]
  205. public class UnitData
  206. {
  207. public UndressingManager.UnitType UnitType;
  208. public UIButton ButtonObject;
  209. }
  210. public delegate void OnClickEventDelegate(string call_file);
  211. private class UndressingData
  212. {
  213. public UndressingManager.MaskStatus mask_mode
  214. {
  215. get
  216. {
  217. return this.button_mask_status_;
  218. }
  219. set
  220. {
  221. if (this.button_mask_status_ == value)
  222. {
  223. return;
  224. }
  225. this.button_mask_status_ = value;
  226. if (this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  227. {
  228. return;
  229. }
  230. if (this.button_mask_status_ == UndressingManager.MaskStatus.Off)
  231. {
  232. this.button_object.defaultColor = this.button_default_color;
  233. }
  234. else
  235. {
  236. Color defaultColor = this.button_default_color;
  237. defaultColor.a = 0.5f;
  238. this.button_object.defaultColor = defaultColor;
  239. }
  240. }
  241. }
  242. public void UpdateMaskStatus(Maid maid)
  243. {
  244. if (maid == null || maid.body0 == null || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  245. {
  246. return;
  247. }
  248. bool flag = false;
  249. for (int i = 0; i < this.target_sloat_id_list.Count; i++)
  250. {
  251. if (maid.body0.GetSlotLoaded(this.target_sloat_id_list[i]))
  252. {
  253. flag = true;
  254. break;
  255. }
  256. }
  257. if (!flag)
  258. {
  259. this.button_object.isEnabled = false;
  260. return;
  261. }
  262. bool flag2 = true;
  263. for (int j = 0; j < this.target_sloat_id_list.Count; j++)
  264. {
  265. if (maid.body0.GetMask(this.target_sloat_id_list[j]))
  266. {
  267. flag2 = false;
  268. break;
  269. }
  270. }
  271. this.mask_mode = ((!flag2) ? UndressingManager.MaskStatus.Off : UndressingManager.MaskStatus.On);
  272. }
  273. public void ApplyMask(Maid[] maid_array)
  274. {
  275. if (maid_array == null)
  276. {
  277. return;
  278. }
  279. for (int i = 0; i < maid_array.Length; i++)
  280. {
  281. this.ApplyMask(maid_array[i]);
  282. }
  283. }
  284. public void ApplyMask(Maid maid)
  285. {
  286. if (maid == null || maid.body0 == null || !this.button_object.isEnabled || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  287. {
  288. return;
  289. }
  290. bool flag = this.mask_mode == UndressingManager.MaskStatus.On;
  291. for (int i = 0; i < this.target_sloat_id_list.Count; i++)
  292. {
  293. maid.body0.SetMask(this.target_sloat_id_list[i], !flag);
  294. }
  295. }
  296. public UndressingManager.UnitType unit_type;
  297. public List<TBody.SlotID> target_sloat_id_list = new List<TBody.SlotID>();
  298. public string call_scenario = string.Empty;
  299. public Color button_default_color;
  300. public UIButton button_object;
  301. private UndressingManager.MaskStatus button_mask_status_ = UndressingManager.MaskStatus.Off;
  302. }
  303. }