YotogiSkillListManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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.specialConditionType == Skill.Data.SpecialConditionType.Faint || value.skillData.specialConditionType == Skill.Data.SpecialConditionType.NewType)
  134. {
  135. continue;
  136. }
  137. if (lockNTRPlay && (value.skillData.category == Yotogi.Category.交換 || value.skillData.category == Yotogi.Category.乱交))
  138. {
  139. continue;
  140. }
  141. }
  142. else if (value.skillDataOld != null && lockNTRPlay && (value.skillDataOld.category == YotogiOld.Category.交換 || value.skillDataOld.category == YotogiOld.Category.乱交))
  143. {
  144. continue;
  145. }
  146. if (value.skillData != null && value.skillData.getcondition_data.requestPersonals.Length != 0)
  147. {
  148. list2.Add(value);
  149. }
  150. else
  151. {
  152. string skillName = (value.skillData == null) ? value.skillDataOld.name : value.skillData.name;
  153. string skillNameTerm = (value.skillData == null) ? value.skillDataOld.name : value.skillData.termName;
  154. int skillId = (value.skillData == null) ? value.skillDataOld.id : value.skillData.id;
  155. GameObject gameObject = this.CreateItemObject(maid, ++num, skillName, skillNameTerm, skillId);
  156. if (0 < value.conditionDatas.Length)
  157. {
  158. List<KeyValuePair<string[], Color>> list3 = new List<KeyValuePair<string[], Color>>();
  159. foreach (KeyValuePair<string[], bool> keyValuePair2 in value.conditionDatas)
  160. {
  161. list3.Add(new KeyValuePair<string[], Color>(keyValuePair2.Key, (!keyValuePair2.Value) ? Color.gray : Color.white));
  162. }
  163. this.conditionDatas.Add(gameObject.GetInstanceID(), list3.ToArray());
  164. this.instansToSkillDatas.Add(gameObject.GetInstanceID(), new KeyValuePair<Skill.Data, Skill.Old.Data>(value.skillData, value.skillDataOld));
  165. }
  166. }
  167. }
  168. foreach (YotogiSkillListManager.Data data in list2)
  169. {
  170. string skillName2 = (data.skillData == null) ? data.skillDataOld.name : data.skillData.name;
  171. string skillNameTerm2 = (data.skillData == null) ? data.skillDataOld.name : data.skillData.termName;
  172. int skillId2 = (data.skillData == null) ? data.skillDataOld.id : data.skillData.id;
  173. GameObject gameObject2 = this.CreateItemObject(maid, -1, skillName2, skillNameTerm2, skillId2);
  174. if (0 < data.conditionDatas.Length)
  175. {
  176. List<KeyValuePair<string[], Color>> list4 = new List<KeyValuePair<string[], Color>>();
  177. if (data.skillData != null)
  178. {
  179. foreach (Personal.Data data2 in data.skillData.getcondition_data.requestPersonals)
  180. {
  181. if (maid.status.personal.id == data2.id)
  182. {
  183. string text = GameUty.supportMultiLanguage ? maid.status.personal.termName : maid.status.personal.drawName;
  184. list4.Add(new KeyValuePair<string[], Color>(new string[]
  185. {
  186. "MaidStatus/条件文/ヒロインタイプ {0}",
  187. text
  188. }, Color.white));
  189. break;
  190. }
  191. }
  192. }
  193. foreach (KeyValuePair<string[], bool> keyValuePair3 in data.conditionDatas)
  194. {
  195. list4.Add(new KeyValuePair<string[], Color>(keyValuePair3.Key, (!keyValuePair3.Value) ? Color.gray : Color.white));
  196. }
  197. this.conditionDatas.Add(gameObject2.GetInstanceID(), list4.ToArray());
  198. this.instansToSkillDatas.Add(gameObject2.GetInstanceID(), new KeyValuePair<Skill.Data, Skill.Old.Data>(data.skillData, data.skillDataOld));
  199. }
  200. }
  201. Utility.ResetNGUI(this.itemGrid);
  202. Utility.ResetNGUI(this.scrollView);
  203. }
  204. private void OnEnable()
  205. {
  206. Utility.ResetNGUI(this.itemGrid);
  207. Utility.ResetNGUI(this.scrollView);
  208. this.OnHoverOutItem();
  209. }
  210. private GameObject InstantiateSkillItem(GameObject parent)
  211. {
  212. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/Profile/Prefab/ProfileYotogiSkillItem", true);
  213. UIEventTrigger component = gameObject.GetComponent<UIEventTrigger>();
  214. EventDelegate eventDelegate = new EventDelegate(this, "OnHoverOverItem");
  215. eventDelegate.parameters[0].value = gameObject.GetInstanceID();
  216. EventDelegate.Add(component.onHoverOver, eventDelegate);
  217. EventDelegate.Add(component.onHoverOut, new EventDelegate.Callback(this.OnHoverOutItem));
  218. return gameObject;
  219. }
  220. private void OnHoverOverItem(int instanceId)
  221. {
  222. if (this.conditionDatas.ContainsKey(instanceId))
  223. {
  224. KeyValuePair<Skill.Data, Skill.Old.Data> keyValuePair = this.instansToSkillDatas[instanceId];
  225. this.conditionTitleLabel.text = ((keyValuePair.Key == null) ? keyValuePair.Value.name : keyValuePair.Key.name) + " 取得条件";
  226. if (GameUty.supportMultiLanguage)
  227. {
  228. Localize component = this.conditionTitleLabel.GetComponent<Localize>();
  229. if (component != null)
  230. {
  231. string term = (keyValuePair.Key == null) ? keyValuePair.Value.name : keyValuePair.Key.termName;
  232. Localize.ArgsPair[] termArgs = new Localize.ArgsPair[]
  233. {
  234. Localize.ArgsPair.Create(" {0}", false),
  235. Localize.ArgsPair.Create("System/取得条件", true)
  236. };
  237. component.TermArgs = termArgs;
  238. component.SetTerm(term);
  239. }
  240. }
  241. this.conditionList.SetTexts(this.conditionDatas[instanceId], 500);
  242. this.conditionBG.height = 90 + this.conditionList.height;
  243. this.conditionsObject.SetActive(true);
  244. }
  245. else
  246. {
  247. this.OnHoverOutItem();
  248. }
  249. }
  250. private void OnHoverOutItem()
  251. {
  252. this.conditionsObject.SetActive(false);
  253. }
  254. private GameObject CreateItemObject(Maid maid, int no, string skillName, string skillNameTerm, int skillId)
  255. {
  256. GameObject gameObject;
  257. if (this.storageObject.transform.childCount == 0)
  258. {
  259. gameObject = this.InstantiateSkillItem(this.storageObject);
  260. }
  261. else
  262. {
  263. gameObject = this.storageObject.transform.GetChild(0).gameObject;
  264. }
  265. gameObject.transform.SetParent(this.contentObject.transform, false);
  266. if (0 <= no)
  267. {
  268. gameObject.name = no.ToString("D4");
  269. }
  270. else
  271. {
  272. gameObject.name = "EX";
  273. }
  274. UILabel component = UTY.GetChildObject(gameObject, "Number/Value", false).GetComponent<UILabel>();
  275. if (0 <= no)
  276. {
  277. component.text = no.ToString();
  278. }
  279. else
  280. {
  281. component.text = "EX";
  282. }
  283. UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent<UILabel>();
  284. component2.text = skillName;
  285. Localize component3 = component2.GetComponent<Localize>();
  286. if (component3 != null)
  287. {
  288. component3.SetTerm(skillNameTerm);
  289. }
  290. UISprite component4 = UTY.GetChildObject(gameObject, "LevelOfAchievement/Icon", false).GetComponent<UISprite>();
  291. int num = (!maid.status.yotogiSkill.Contains(skillId)) ? 0 : maid.status.yotogiSkill.Get(skillId).level;
  292. string spriteName = "profile_yotogiskill_sign_minus";
  293. if (num != 1)
  294. {
  295. if (num != 2)
  296. {
  297. if (num == 3)
  298. {
  299. spriteName = "cm3d2_edit_profile_yotogiskill_sign_nijumaru";
  300. }
  301. }
  302. else
  303. {
  304. spriteName = "cm3d2_edit_profile_yotogiskill_sign_maru";
  305. }
  306. }
  307. else
  308. {
  309. spriteName = "cm3d2_edit_profile_yotogiskill_sign_sankaku";
  310. }
  311. if (maid.status.yotogiSkill.Contains(skillId) && maid.status.yotogiSkill.Get(skillId).playCount == 0u)
  312. {
  313. spriteName = "cm3d2_edit_profile_yotogiskill_sign_batu";
  314. }
  315. component4.spriteName = spriteName;
  316. component2.color = ((num != 0) ? Color.white : Color.gray);
  317. gameObject.GetComponent<BoxCollider>().enabled = (num == 0);
  318. return gameObject;
  319. }
  320. private void DeleteItemAllObject()
  321. {
  322. List<GameObject> list = new List<GameObject>();
  323. for (int i = 0; i < this.contentObject.transform.childCount; i++)
  324. {
  325. list.Add(this.contentObject.transform.GetChild(i).gameObject);
  326. }
  327. foreach (GameObject obj in list)
  328. {
  329. this.DeleteItemObject(obj);
  330. }
  331. }
  332. private void DeleteItemObject(GameObject obj)
  333. {
  334. if (obj.transform.parent != this.storageObject.transform)
  335. {
  336. obj.transform.SetParent(this.storageObject.transform, false);
  337. }
  338. }
  339. [SerializeField]
  340. private GameObject storageObject;
  341. [SerializeField]
  342. private GameObject contentObject;
  343. [SerializeField]
  344. private UIScrollView scrollView;
  345. [SerializeField]
  346. private GameObject conditionsObject;
  347. [SerializeField]
  348. private UILabel conditionTitleLabel;
  349. private UIGrid itemGrid;
  350. private UIWFConditionList conditionList;
  351. private UIWidget conditionBG;
  352. private Dictionary<int, KeyValuePair<string[], Color>[]> conditionDatas;
  353. private Dictionary<int, KeyValuePair<Skill.Data, Skill.Old.Data>> instansToSkillDatas;
  354. public class Data
  355. {
  356. public bool enabled
  357. {
  358. get
  359. {
  360. return this.maidStatusSkillData != null;
  361. }
  362. }
  363. public Skill.Data skillData;
  364. public Skill.Old.Data skillDataOld;
  365. public KeyValuePair<string[], bool>[] conditionDatas;
  366. public YotogiSkillData maidStatusSkillData;
  367. }
  368. }