UndressingManager.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. public UndressingManager.UndressingData GetUndressingData(UndressingManager.UnitType unitType)
  129. {
  130. return (!this.unit_dic_.ContainsKey(unitType)) ? null : this.unit_dic_[unitType];
  131. }
  132. public void OnClickButton(UndressingManager.UndressingData unit_data)
  133. {
  134. UndressingManager.MaskStatus status = (unit_data.mask_mode != UndressingManager.MaskStatus.On) ? UndressingManager.MaskStatus.On : UndressingManager.MaskStatus.Off;
  135. this.SetMaskMode(unit_data.unit_type, status);
  136. }
  137. private void ApplyAllMaid()
  138. {
  139. if (this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode == UndressingManager.MaskStatus.On)
  140. {
  141. for (int i = 0; i < this.all_maid_data_.Length; i++)
  142. {
  143. this.all_maid_data_[i].body0.SetMaskMode(TBody.MaskMode.Nude);
  144. }
  145. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair in this.unit_dic_)
  146. {
  147. UndressingManager.UndressingData value = keyValuePair.Value;
  148. if (value.unit_type != UndressingManager.UnitType.全脱衣 && value.unit_type != UndressingManager.UnitType.全着衣)
  149. {
  150. value.mask_mode = UndressingManager.MaskStatus.On;
  151. }
  152. }
  153. return;
  154. }
  155. if (this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode == UndressingManager.MaskStatus.On)
  156. {
  157. for (int j = 0; j < this.all_maid_data_.Length; j++)
  158. {
  159. this.all_maid_data_[j].body0.SetMaskMode(TBody.MaskMode.None);
  160. }
  161. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair2 in this.unit_dic_)
  162. {
  163. UndressingManager.UndressingData value2 = keyValuePair2.Value;
  164. if (value2.unit_type != UndressingManager.UnitType.全脱衣 && value2.unit_type != UndressingManager.UnitType.全着衣)
  165. {
  166. value2.mask_mode = UndressingManager.MaskStatus.Off;
  167. }
  168. }
  169. return;
  170. }
  171. foreach (KeyValuePair<UndressingManager.UnitType, UndressingManager.UndressingData> keyValuePair3 in this.unit_dic_)
  172. {
  173. UndressingManager.UndressingData value3 = keyValuePair3.Value;
  174. for (int k = 0; k < this.all_maid_data_.Length; k++)
  175. {
  176. value3.ApplyMask(this.all_maid_data_[k]);
  177. }
  178. value3.UpdateMaskStatus(this.maid_);
  179. }
  180. }
  181. [SerializeField]
  182. public List<UndressingManager.UnitData> UnitDataList = new List<UndressingManager.UnitData>();
  183. private Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData> unit_dic_ = new Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData>();
  184. private Maid maid_;
  185. private Maid[] all_maid_data_;
  186. private UndressingManager.OnClickEventDelegate onclick_event_;
  187. public enum UnitType
  188. {
  189. 全脱衣,
  190. 全着衣,
  191. トップス,
  192. ボトムス,
  193. ブラジャ\u30FC,
  194. パンツ,
  195. ソックス,
  196. シュ\u30FCズ,
  197. ヘッドドレス,
  198. メガネ,
  199. 背中,
  200. 手袋,
  201. Max
  202. }
  203. public enum MaskStatus
  204. {
  205. On,
  206. Off
  207. }
  208. [Serializable]
  209. public class UnitData
  210. {
  211. public UndressingManager.UnitType UnitType;
  212. public UIButton ButtonObject;
  213. }
  214. public delegate void OnClickEventDelegate(string call_file);
  215. public class UndressingData
  216. {
  217. public UndressingManager.MaskStatus mask_mode
  218. {
  219. get
  220. {
  221. return this.button_mask_status_;
  222. }
  223. set
  224. {
  225. if (this.button_mask_status_ == value)
  226. {
  227. return;
  228. }
  229. this.button_mask_status_ = value;
  230. if (this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  231. {
  232. return;
  233. }
  234. if (this.button_mask_status_ == UndressingManager.MaskStatus.Off)
  235. {
  236. this.button_object.defaultColor = this.button_default_color;
  237. }
  238. else
  239. {
  240. Color defaultColor = this.button_default_color;
  241. defaultColor.a = 0.5f;
  242. this.button_object.defaultColor = defaultColor;
  243. }
  244. }
  245. }
  246. public void UpdateMaskStatus(Maid maid)
  247. {
  248. if (maid == null || maid.body0 == null || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  249. {
  250. return;
  251. }
  252. bool flag = false;
  253. for (int i = 0; i < this.target_sloat_id_list.Count; i++)
  254. {
  255. if (maid.body0.GetSlotLoaded(this.target_sloat_id_list[i]))
  256. {
  257. flag = true;
  258. break;
  259. }
  260. }
  261. if (!flag)
  262. {
  263. this.button_object.defaultColor = this.button_object.disabledColor;
  264. this.button_object.isEnabled = false;
  265. return;
  266. }
  267. bool flag2 = true;
  268. for (int j = 0; j < this.target_sloat_id_list.Count; j++)
  269. {
  270. if (maid.body0.GetMask(this.target_sloat_id_list[j]))
  271. {
  272. flag2 = false;
  273. break;
  274. }
  275. }
  276. this.mask_mode = ((!flag2) ? UndressingManager.MaskStatus.Off : UndressingManager.MaskStatus.On);
  277. }
  278. public void ApplyMask(Maid[] maid_array)
  279. {
  280. if (maid_array == null)
  281. {
  282. return;
  283. }
  284. for (int i = 0; i < maid_array.Length; i++)
  285. {
  286. this.ApplyMask(maid_array[i]);
  287. }
  288. }
  289. public void ApplyMask(Maid maid)
  290. {
  291. if (maid == null || maid.body0 == null || !this.button_object.isEnabled || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣)
  292. {
  293. return;
  294. }
  295. bool flag = this.mask_mode == UndressingManager.MaskStatus.On;
  296. for (int i = 0; i < this.target_sloat_id_list.Count; i++)
  297. {
  298. maid.body0.SetMask(this.target_sloat_id_list[i], !flag);
  299. }
  300. }
  301. public UndressingManager.UnitType unit_type;
  302. public List<TBody.SlotID> target_sloat_id_list = new List<TBody.SlotID>();
  303. public string call_scenario = string.Empty;
  304. public Color button_default_color;
  305. public UIButton button_object;
  306. private UndressingManager.MaskStatus button_mask_status_ = UndressingManager.MaskStatus.Off;
  307. }
  308. }