YotogiSkillListManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using MaidStatus;
  5. using UnityEngine;
  6. using wf;
  7. using Yotogis;
  8. public class YotogiSkillListManager : MonoBehaviour
  9. {
  10. public static Dictionary<int, YotogiSkillListManager.Data> CreateDatas(Status status, bool specialConditionCheck, Skill.Data.SpecialConditionType type = Skill.Data.SpecialConditionType.Null)
  11. {
  12. Dictionary<int, YotogiSkillListManager.Data> dictionary = new Dictionary<int, YotogiSkillListManager.Data>();
  13. List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
  14. foreach (SortedDictionary<int, Skill.Data> sortedDictionary in Skill.skill_data_list)
  15. {
  16. foreach (KeyValuePair<int, Skill.Data> keyValuePair in sortedDictionary)
  17. {
  18. list.Clear();
  19. Skill.Data value = keyValuePair.Value;
  20. if (!specialConditionCheck || value.specialConditionType == type)
  21. {
  22. if (value.IsExecSeikeiken(status.seikeiken) && value.IsExecRelation(status.relation) && value.IsExecContract(status.contract) && value.IsExecPersonal(status.personal))
  23. {
  24. YotogiSkillData yotogiSkillData = status.yotogiSkill.Get(value.id);
  25. if (yotogiSkillData == null)
  26. {
  27. if (value.getcondition_data.yotogi_class != null && !value.getcondition_data.yotogi_class.learnConditions.isFutureLearnPossible(status))
  28. {
  29. continue;
  30. }
  31. list = value.getcondition_data.CreateConditionTextAndStaturResults(status);
  32. }
  33. if (list.Count == 0)
  34. {
  35. list.Add(new KeyValuePair<string[], bool>(new string[]
  36. {
  37. "MaidStatus/条件文/なし"
  38. }, true));
  39. }
  40. YotogiSkillListManager.Data data = new YotogiSkillListManager.Data();
  41. data.skillData = value;
  42. data.conditionDatas = list.ToArray();
  43. data.maidStatusSkillData = yotogiSkillData;
  44. dictionary.Add(data.skillData.id, data);
  45. }
  46. }
  47. }
  48. }
  49. return dictionary;
  50. }
  51. public static Dictionary<int, YotogiSkillListManager.Data> CreateDatasOld(Status status)
  52. {
  53. Dictionary<int, YotogiSkillListManager.Data> dictionary = new Dictionary<int, YotogiSkillListManager.Data>();
  54. List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
  55. foreach (SortedDictionary<int, Skill.Old.Data> sortedDictionary in Skill.Old.skill_data_list)
  56. {
  57. foreach (KeyValuePair<int, Skill.Old.Data> keyValuePair in sortedDictionary)
  58. {
  59. list.Clear();
  60. Skill.Old.Data value = keyValuePair.Value;
  61. if (value.IsExecSeikeiken(status.seikeiken) && value.IsExecRelation(status.relation))
  62. {
  63. YotogiSkillData yotogiSkillData = status.yotogiSkill.Get(value.id);
  64. if (yotogiSkillData == null)
  65. {
  66. list = value.getcondition_data.CreateConditionTextAndStaturResults(status);
  67. }
  68. if (list.Count == 0)
  69. {
  70. list.Add(new KeyValuePair<string[], bool>(new string[]
  71. {
  72. "MaidStatus/条件文/なし"
  73. }, true));
  74. }
  75. YotogiSkillListManager.Data data = new YotogiSkillListManager.Data();
  76. data.skillDataOld = value;
  77. data.conditionDatas = list.ToArray();
  78. data.maidStatusSkillData = yotogiSkillData;
  79. dictionary.Add(value.id, data);
  80. }
  81. }
  82. }
  83. return dictionary;
  84. }
  85. private void Awake()
  86. {
  87. if (this.conditionDatas != null)
  88. {
  89. return;
  90. }
  91. this.itemGrid = this.contentObject.GetComponent<UIGrid>();
  92. NDebug.AssertNull(this.itemGrid != null);
  93. this.conditionList = this.conditionsObject.GetComponentInChildren<UIWFConditionList>();
  94. NDebug.AssertNull(this.conditionList != null);
  95. this.conditionBG = UTY.GetChildObject(this.conditionsObject, "BG", false).GetComponent<UIWidget>();
  96. for (int i = 0; i < 50; i++)
  97. {
  98. this.InstantiateSkillItem(this.storageObject);
  99. }
  100. this.conditionDatas = new Dictionary<int, KeyValuePair<string[], Color>[]>();
  101. this.instansToSkillDatas = new Dictionary<int, KeyValuePair<Skill.Data, Skill.Old.Data>>();
  102. this.conditionsObject.SetActive(false);
  103. }
  104. public void CreateData(Maid maid)
  105. {
  106. if (this.conditionDatas == null)
  107. {
  108. this.Awake();
  109. }
  110. this.DeleteItemAllObject();
  111. this.conditionDatas.Clear();
  112. this.instansToSkillDatas.Clear();
  113. Utility.ResetNGUI(this.itemGrid);
  114. Utility.ResetNGUI(this.scrollView);
  115. List<KeyValuePair<string, Color>> list = new List<KeyValuePair<string, Color>>();
  116. int num = 0;
  117. Dictionary<int, YotogiSkillListManager.Data> dictionary;
  118. if (MaidManagement.compatibilityMode)
  119. {
  120. dictionary = YotogiSkillListManager.CreateDatasOld(maid.status);
  121. }
  122. else
  123. {
  124. dictionary = YotogiSkillListManager.CreateDatas(maid.status, false, Skill.Data.SpecialConditionType.Null);
  125. }
  126. List<YotogiSkillListManager.Data> list2 = new List<YotogiSkillListManager.Data>();
  127. bool lockNTRPlay = GameMain.Instance.CharacterMgr.status.lockNTRPlay;
  128. foreach (KeyValuePair<int, YotogiSkillListManager.Data> keyValuePair in dictionary)
  129. {
  130. YotogiSkillListManager.Data value = keyValuePair.Value;
  131. if (value.skillData != null)
  132. {
  133. if (!value.skillData.IsSkillListDisplay(lockNTRPlay))
  134. {
  135. continue;
  136. }
  137. }
  138. else if (value.skillDataOld != null && lockNTRPlay && (value.skillDataOld.category == YotogiOld.Category.交換 || value.skillDataOld.category == YotogiOld.Category.乱交))
  139. {
  140. continue;
  141. }
  142. if (value.skillData != null && value.skillData.getcondition_data.requestPersonals.Length != 0)
  143. {
  144. list2.Add(value);
  145. }
  146. else
  147. {
  148. string skillName = (value.skillData == null) ? value.skillDataOld.name : value.skillData.name;
  149. string skillNameTerm = (value.skillData == null) ? value.skillDataOld.name : value.skillData.termName;
  150. int skillId = (value.skillData == null) ? value.skillDataOld.id : value.skillData.id;
  151. GameObject gameObject = this.CreateItemObject(maid, ++num, skillName, skillNameTerm, skillId);
  152. if (0 < value.conditionDatas.Length)
  153. {
  154. List<KeyValuePair<string[], Color>> list3 = new List<KeyValuePair<string[], Color>>();
  155. foreach (KeyValuePair<string[], bool> keyValuePair2 in value.conditionDatas)
  156. {
  157. list3.Add(new KeyValuePair<string[], Color>(keyValuePair2.Key, (!keyValuePair2.Value) ? Color.gray : Color.white));
  158. }
  159. this.conditionDatas.Add(gameObject.GetInstanceID(), list3.ToArray());
  160. this.instansToSkillDatas.Add(gameObject.GetInstanceID(), new KeyValuePair<Skill.Data, Skill.Old.Data>(value.skillData, value.skillDataOld));
  161. }
  162. }
  163. }
  164. foreach (YotogiSkillListManager.Data data in list2)
  165. {
  166. string skillName2 = (data.skillData == null) ? data.skillDataOld.name : data.skillData.name;
  167. string skillNameTerm2 = (data.skillData == null) ? data.skillDataOld.name : data.skillData.termName;
  168. int skillId2 = (data.skillData == null) ? data.skillDataOld.id : data.skillData.id;
  169. GameObject gameObject2 = this.CreateItemObject(maid, -1, skillName2, skillNameTerm2, skillId2);
  170. if (0 < data.conditionDatas.Length)
  171. {
  172. List<KeyValuePair<string[], Color>> list4 = new List<KeyValuePair<string[], Color>>();
  173. if (data.skillData != null)
  174. {
  175. foreach (Personal.Data data2 in data.skillData.getcondition_data.requestPersonals)
  176. {
  177. if (maid.status.personal.id == data2.id)
  178. {
  179. string text = Product.supportMultiLanguage ? maid.status.personal.termName : maid.status.personal.drawName;
  180. list4.Add(new KeyValuePair<string[], Color>(new string[]
  181. {
  182. "MaidStatus/条件文/ヒロインタイプ {0}",
  183. text
  184. }, Color.white));
  185. break;
  186. }
  187. }
  188. }
  189. foreach (KeyValuePair<string[], bool> keyValuePair3 in data.conditionDatas)
  190. {
  191. list4.Add(new KeyValuePair<string[], Color>(keyValuePair3.Key, (!keyValuePair3.Value) ? Color.gray : Color.white));
  192. }
  193. this.conditionDatas.Add(gameObject2.GetInstanceID(), list4.ToArray());
  194. this.instansToSkillDatas.Add(gameObject2.GetInstanceID(), new KeyValuePair<Skill.Data, Skill.Old.Data>(data.skillData, data.skillDataOld));
  195. }
  196. }
  197. Utility.ResetNGUI(this.itemGrid);
  198. Utility.ResetNGUI(this.scrollView);
  199. }
  200. private void OnEnable()
  201. {
  202. Utility.ResetNGUI(this.itemGrid);
  203. Utility.ResetNGUI(this.scrollView);
  204. this.OnHoverOutItem();
  205. }
  206. private GameObject InstantiateSkillItem(GameObject parent)
  207. {
  208. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/Profile/Prefab/ProfileYotogiSkillItem", true);
  209. UIEventTrigger component = gameObject.GetComponent<UIEventTrigger>();
  210. EventDelegate eventDelegate = new EventDelegate(this, "OnHoverOverItem");
  211. eventDelegate.parameters[0].value = gameObject.GetInstanceID();
  212. EventDelegate.Add(component.onHoverOver, eventDelegate);
  213. EventDelegate.Add(component.onHoverOut, new EventDelegate.Callback(this.OnHoverOutItem));
  214. return gameObject;
  215. }
  216. private void OnHoverOverItem(int instanceId)
  217. {
  218. if (this.conditionDatas.ContainsKey(instanceId))
  219. {
  220. KeyValuePair<Skill.Data, Skill.Old.Data> keyValuePair = this.instansToSkillDatas[instanceId];
  221. this.conditionTitleLabel.text = ((keyValuePair.Key == null) ? keyValuePair.Value.name : keyValuePair.Key.name) + " 取得条件";
  222. if (Product.supportMultiLanguage)
  223. {
  224. Localize component = this.conditionTitleLabel.GetComponent<Localize>();
  225. if (component != null)
  226. {
  227. string term = (keyValuePair.Key == null) ? keyValuePair.Value.name : keyValuePair.Key.termName;
  228. Localize.ArgsPair[] termArgs = new Localize.ArgsPair[]
  229. {
  230. Localize.ArgsPair.Create(" {0}", false),
  231. Localize.ArgsPair.Create("System/取得条件", true)
  232. };
  233. component.TermArgs = termArgs;
  234. component.SetTerm(term);
  235. }
  236. }
  237. this.conditionList.SetTexts(this.conditionDatas[instanceId], 500);
  238. this.conditionBG.height = 90 + this.conditionList.height;
  239. this.conditionsObject.SetActive(true);
  240. }
  241. else
  242. {
  243. this.OnHoverOutItem();
  244. }
  245. }
  246. private void OnHoverOutItem()
  247. {
  248. this.conditionsObject.SetActive(false);
  249. }
  250. private GameObject CreateItemObject(Maid maid, int no, string skillName, string skillNameTerm, int skillId)
  251. {
  252. GameObject gameObject;
  253. if (this.storageObject.transform.childCount == 0)
  254. {
  255. gameObject = this.InstantiateSkillItem(this.storageObject);
  256. }
  257. else
  258. {
  259. gameObject = this.storageObject.transform.GetChild(0).gameObject;
  260. }
  261. gameObject.transform.SetParent(this.contentObject.transform, false);
  262. if (0 <= no)
  263. {
  264. gameObject.name = no.ToString("D4");
  265. }
  266. else
  267. {
  268. gameObject.name = "EX";
  269. }
  270. UILabel component = UTY.GetChildObject(gameObject, "Number/Value", false).GetComponent<UILabel>();
  271. if (0 <= no)
  272. {
  273. component.text = no.ToString();
  274. }
  275. else
  276. {
  277. component.text = "EX";
  278. }
  279. UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent<UILabel>();
  280. component2.text = skillName;
  281. Localize component3 = component2.GetComponent<Localize>();
  282. if (component3 != null)
  283. {
  284. component3.SetTerm(skillNameTerm);
  285. }
  286. UISprite component4 = UTY.GetChildObject(gameObject, "LevelOfAchievement/Icon", false).GetComponent<UISprite>();
  287. int num = (!maid.status.yotogiSkill.Contains(skillId)) ? 0 : maid.status.yotogiSkill.Get(skillId).level;
  288. string spriteName = "profile_yotogiskill_sign_minus";
  289. if (num != 1)
  290. {
  291. if (num != 2)
  292. {
  293. if (num == 3)
  294. {
  295. spriteName = "cm3d2_edit_profile_yotogiskill_sign_nijumaru";
  296. }
  297. }
  298. else
  299. {
  300. spriteName = "cm3d2_edit_profile_yotogiskill_sign_maru";
  301. }
  302. }
  303. else
  304. {
  305. spriteName = "cm3d2_edit_profile_yotogiskill_sign_sankaku";
  306. }
  307. if (maid.status.yotogiSkill.Contains(skillId) && maid.status.yotogiSkill.Get(skillId).playCount == 0u)
  308. {
  309. spriteName = "cm3d2_edit_profile_yotogiskill_sign_batu";
  310. }
  311. component4.spriteName = spriteName;
  312. component2.color = ((num != 0) ? Color.white : Color.gray);
  313. gameObject.GetComponent<BoxCollider>().enabled = (num == 0);
  314. return gameObject;
  315. }
  316. private void DeleteItemAllObject()
  317. {
  318. List<GameObject> list = new List<GameObject>();
  319. for (int i = 0; i < this.contentObject.transform.childCount; i++)
  320. {
  321. list.Add(this.contentObject.transform.GetChild(i).gameObject);
  322. }
  323. foreach (GameObject obj in list)
  324. {
  325. this.DeleteItemObject(obj);
  326. }
  327. }
  328. private void DeleteItemObject(GameObject obj)
  329. {
  330. if (obj.transform.parent != this.storageObject.transform)
  331. {
  332. obj.transform.SetParent(this.storageObject.transform, false);
  333. }
  334. }
  335. [SerializeField]
  336. private GameObject storageObject;
  337. [SerializeField]
  338. private GameObject contentObject;
  339. [SerializeField]
  340. private UIScrollView scrollView;
  341. [SerializeField]
  342. private GameObject conditionsObject;
  343. [SerializeField]
  344. private UILabel conditionTitleLabel;
  345. private UIGrid itemGrid;
  346. private UIWFConditionList conditionList;
  347. private UIWidget conditionBG;
  348. private Dictionary<int, KeyValuePair<string[], Color>[]> conditionDatas;
  349. private Dictionary<int, KeyValuePair<Skill.Data, Skill.Old.Data>> instansToSkillDatas;
  350. public class Data
  351. {
  352. public bool enabled
  353. {
  354. get
  355. {
  356. return this.maidStatusSkillData != null;
  357. }
  358. }
  359. public Skill.Data skillData;
  360. public Skill.Old.Data skillDataOld;
  361. public KeyValuePair<string[], bool>[] conditionDatas;
  362. public YotogiSkillData maidStatusSkillData;
  363. }
  364. }