YotogiOldVRSkillSelectManager.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. using Yotogis;
  6. public class YotogiOldVRSkillSelectManager : WfFadeBehaviour
  7. {
  8. public void Awake()
  9. {
  10. this.skillStorageObject = new GameObject();
  11. this.skillStorageObject.name = "skillStorageObject";
  12. this.skillStorageObject.transform.SetParent(base.transform, false);
  13. this.skillStorageObject.SetActive(false);
  14. if (this.init_pos_dic_.Count == 0)
  15. {
  16. this.init_pos_dic_.Add(this.cancelBtn, this.cancelBtn.transform.localPosition);
  17. }
  18. EventDelegate.Add(this.cancelBtn.onClick, new EventDelegate.Callback(this.OnClickCancel));
  19. this.cblConfigBtn.gameObject.SetActive(false);
  20. for (int i = 0; i < this.categorySelectTabPanel.transform.childCount; i++)
  21. {
  22. UIWFTabButton componentInChildren = this.categorySelectTabPanel.transform.GetChild(i).GetComponentInChildren<UIWFTabButton>();
  23. EventDelegate eventDelegate = new EventDelegate(this, "OnClickFromCategoryButton");
  24. EventDelegate.Parameter[] parameters = eventDelegate.parameters;
  25. parameters[0].value = this.categorySelectTabPanel.transform.GetChild(i).name;
  26. componentInChildren.onClick.Add(eventDelegate);
  27. }
  28. this.categorySelectTabPanel.UpdateChildren();
  29. this.selectCategoryName = YotogiOld.Category.淫欲.ToString();
  30. this.widget.alpha = 0f;
  31. this.stageSelectBtn.SetOnSelectEvent(new Action<StageOldUnitCircle>(this.OnClickStageSelect));
  32. }
  33. public override void OnStartedFadeIn()
  34. {
  35. this.uiMask.enabled = true;
  36. this.fadeInStartBgAlpha = this.bgSprite.alpha;
  37. this.fadeInStartBgSize = new Vector2((float)this.bgSprite.width, (float)this.bgSprite.height);
  38. }
  39. public override void OnStartedFadeOut()
  40. {
  41. this.uiMask.enabled = true;
  42. }
  43. public override void OnUpdateFadeIn(float val)
  44. {
  45. this.bgSprite.alpha = Mathf.Lerp(this.fadeInStartBgAlpha, 1f, val);
  46. this.bgSprite.width = (int)Mathf.Lerp(this.fadeInStartBgSize.x, this.bgSize.x, val);
  47. this.bgSprite.height = (int)Mathf.Lerp(this.fadeInStartBgSize.y, this.bgSize.y, val);
  48. this.widget.alpha = val;
  49. }
  50. public override void OnUpdateFadeOut(float val)
  51. {
  52. this.widget.alpha = val;
  53. }
  54. public override void OnCompleteFadeIn()
  55. {
  56. this.uiMask.enabled = false;
  57. }
  58. public override void OnCompleteFadeOut()
  59. {
  60. this.OnCompleteFadeIn();
  61. }
  62. public void SelectCategory(string category)
  63. {
  64. for (int i = 0; i < this.categorySelectTabPanel.transform.childCount; i++)
  65. {
  66. Transform child = this.categorySelectTabPanel.transform.GetChild(i);
  67. UIWFTabButton componentInChildren = child.GetComponentInChildren<UIWFTabButton>();
  68. if (category == child.name && componentInChildren.isEnabled)
  69. {
  70. this.categorySelectTabPanel.Select(componentInChildren);
  71. return;
  72. }
  73. }
  74. }
  75. public void SetCancelButtonText(string text)
  76. {
  77. this.cancelBtn.GetComponentInChildren<UILabel>().text = text;
  78. }
  79. public void UpdateData(Maid maid, YotogiOld.Stage stage, int spot_no)
  80. {
  81. bool isDaytime = GameMain.Instance.CharacterMgr.status.isDaytime;
  82. YotogiOld.StageData.SpotData spotData = YotogiOld.vr_stage_data_list[stage].spot_data[spot_no];
  83. this.stageSelectBtn.SetStageSpotData(YotogiOld.vr_stage_data_list[stage], spot_no);
  84. List<YotogiOld.VRSkillData> vrskillDataList = YotogiOld.GetVRSkillDataList(stage, spot_no);
  85. this.skill_data_ = new Dictionary<string, List<YotogiOld.VRSkillData>>();
  86. foreach (YotogiOld.VRSkillData vrskillData in vrskillDataList)
  87. {
  88. Skill.Old.Data skill = vrskillData.skill;
  89. string key = vrskillData.skill.category.ToString();
  90. bool flag = maid.status.yotogiSkill.oldDatas.ContainsKey(skill.id) && skill.IsExecMaid(maid.status);
  91. if (flag)
  92. {
  93. if (!this.skill_data_.ContainsKey(key))
  94. {
  95. this.skill_data_.Add(key, new List<YotogiOld.VRSkillData>());
  96. }
  97. this.skill_data_[key].Add(vrskillData);
  98. }
  99. }
  100. int num = 0;
  101. foreach (KeyValuePair<string, List<YotogiOld.VRSkillData>> keyValuePair in this.skill_data_)
  102. {
  103. if (num < keyValuePair.Value.Count)
  104. {
  105. num = keyValuePair.Value.Count;
  106. }
  107. }
  108. if (this.skillStorageObject.transform.childCount < num)
  109. {
  110. int num2 = num - this.skillStorageObject.transform.childCount;
  111. for (int i = 0; i < num2; i++)
  112. {
  113. this.CreateNewSkillUnit(this.skillStorageObject);
  114. }
  115. }
  116. string value = string.Empty;
  117. for (int j = 0; j < this.categorySelectTabPanel.transform.childCount; j++)
  118. {
  119. Transform child = this.categorySelectTabPanel.transform.GetChild(j);
  120. UIWFTabButton componentInChildren = child.GetComponentInChildren<UIWFTabButton>();
  121. bool flag2 = this.skill_data_.ContainsKey(child.name) && this.skill_data_[child.name].Count > 0;
  122. componentInChildren.SetSelect(false);
  123. componentInChildren.isEnabled = flag2;
  124. if (!flag2 && child.name == this.selectCategoryName)
  125. {
  126. this.selectCategoryName = string.Empty;
  127. }
  128. else if (flag2 && string.IsNullOrEmpty(value))
  129. {
  130. value = child.name;
  131. }
  132. }
  133. if (string.IsNullOrEmpty(this.selectCategoryName))
  134. {
  135. this.selectCategoryName = value;
  136. }
  137. List<Transform> list = new List<Transform>();
  138. for (int k = 0; k < this.skillUnitParent.childCount; k++)
  139. {
  140. list.Add(this.skillUnitParent.GetChild(k));
  141. }
  142. foreach (Transform transform in list)
  143. {
  144. transform.SetParent(this.skillStorageObject.transform, false);
  145. }
  146. UIScrollView componentInChildren2 = base.gameObject.GetComponentInChildren<UIScrollView>();
  147. Utility.ResetNGUI(componentInChildren2);
  148. this.SelectCategory(this.selectCategoryName);
  149. }
  150. private void OnClickFromCategoryButton(string category)
  151. {
  152. this.selectCategoryName = category;
  153. List<Transform> list = new List<Transform>();
  154. for (int i = 0; i < this.skillUnitParent.childCount; i++)
  155. {
  156. list.Add(this.skillUnitParent.GetChild(i));
  157. }
  158. foreach (Transform transform in list)
  159. {
  160. transform.SetParent(this.skillStorageObject.transform, false);
  161. }
  162. UIScrollView componentInChildren = base.gameObject.GetComponentInChildren<UIScrollView>();
  163. Utility.ResetNGUI(componentInChildren);
  164. if (!this.skill_data_.ContainsKey(category))
  165. {
  166. return;
  167. }
  168. Transform transform2 = this.skillStorageObject.transform;
  169. List<YotogiOld.VRSkillData> list2 = this.skill_data_[category];
  170. list.Clear();
  171. for (int j = 0; j < list2.Count; j++)
  172. {
  173. Transform transform3 = transform2.GetChild(j).transform;
  174. YotogiOldSkillUnitVR component = transform3.GetComponent<YotogiOldSkillUnitVR>();
  175. component.SetSkillData(list2[j]);
  176. component.isSelect = (this.selectedSkill == component.skill_data);
  177. list.Add(transform3);
  178. }
  179. foreach (Transform transform4 in list)
  180. {
  181. transform4.SetParent(this.skillUnitParent, false);
  182. }
  183. Utility.ResetNGUI(this.skillUnitParent.GetComponentInChildren<UIGrid>());
  184. Utility.ResetNGUI(componentInChildren);
  185. }
  186. private void OnClickSkillBtn(YotogiOldSkillUnitVR skill_data)
  187. {
  188. this.selectedSkill = skill_data.skill_data;
  189. YotogiOldManager.select_vr_skill_data = this.selectedSkill;
  190. EventDelegate.Execute(this.onClickEnterEvent);
  191. }
  192. private void OnClickStageSelect(StageOldUnitCircle circle)
  193. {
  194. if (this.uiMask.enabled)
  195. {
  196. return;
  197. }
  198. EventDelegate.Execute(this.onClickStageSelect);
  199. }
  200. private void OnClickCancel()
  201. {
  202. EventDelegate.Execute(this.onClickCancelEvent);
  203. }
  204. private YotogiOldSkillUnitVR CreateNewSkillUnit(GameObject root)
  205. {
  206. GameObject gameObject = Utility.CreatePrefab(root, "SceneYotogi/SkillSelect/Prefab/Old/SkillUnitVR", true);
  207. EventDelegate eventDelegate = new EventDelegate(this, "OnClickSkillBtn");
  208. EventDelegate.Parameter parameter = eventDelegate.parameters[0];
  209. parameter.obj = gameObject.GetComponent<YotogiOldSkillUnitVR>();
  210. gameObject.GetComponentInChildren<UIButton>().onClick.Add(eventDelegate);
  211. return gameObject.GetComponent<YotogiOldSkillUnitVR>();
  212. }
  213. [SerializeField]
  214. private UISprite bgSprite;
  215. [SerializeField]
  216. private Vector2 bgSize;
  217. [SerializeField]
  218. private StageOldUnitCircle stageSelectBtn;
  219. [SerializeField]
  220. private UIButton configBtn;
  221. [SerializeField]
  222. private UIButton vrConfigBtn;
  223. [SerializeField]
  224. private UIButton cblConfigBtn;
  225. [SerializeField]
  226. private UIButton cancelBtn;
  227. [SerializeField]
  228. private UIWidget widget;
  229. [SerializeField]
  230. private UIWFHitMasks uiMask;
  231. [SerializeField]
  232. private UIWFTabPanel categorySelectTabPanel;
  233. [SerializeField]
  234. private Transform skillUnitParent;
  235. [HideInInspector]
  236. public YotogiOld.VRSkillData selectedSkill;
  237. [HideInInspector]
  238. public List<EventDelegate> onClickEnterEvent = new List<EventDelegate>();
  239. [HideInInspector]
  240. public List<EventDelegate> onClickStageSelect = new List<EventDelegate>();
  241. [HideInInspector]
  242. public List<EventDelegate> onClickCancelEvent = new List<EventDelegate>();
  243. private GameObject skillStorageObject;
  244. private string selectCategoryName;
  245. private Dictionary<UIButton, Vector3> init_pos_dic_ = new Dictionary<UIButton, Vector3>();
  246. private Dictionary<string, List<YotogiOld.VRSkillData>> skill_data_ = new Dictionary<string, List<YotogiOld.VRSkillData>>();
  247. private float fadeInStartBgAlpha;
  248. private Vector2 fadeInStartBgSize;
  249. }