YotogiSkillListManager.cs 12 KB

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