YotogiOldSkillSelectManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using MaidStatus;
  5. using UnityEngine;
  6. using wf;
  7. using Yotogis;
  8. public class YotogiOldSkillSelectManager : WfScreenChildren
  9. {
  10. public override void Awake()
  11. {
  12. base.Awake();
  13. this.yotogi_mgr_ = base.GetComponentInParent<YotogiOldManager>();
  14. this.common_buttons_ = UTY.GetChildObject(base.root_obj, "CommonPanel", false).GetComponent<YotogiCommonButtons>();
  15. GameObject gameObject = Utility.CreatePrefab(base.root_obj, "SceneYotogi/Common/Prefab/Old/ParameterViewer", true);
  16. gameObject.transform.localPosition = new Vector3(782f, 449f, 0f);
  17. this.paramenter_viewer_ = gameObject.GetComponent<YotogiOldParameterViewer>();
  18. this.paramenter_viewer_.SetAttributeViewer(UTY.GetChildObject(base.root_obj.transform.parent.gameObject, "AttributeViewer", false));
  19. EventDelegate.Add(this.paramenter_viewer_.costume_button.onClick, new EventDelegate.Callback(this.OnClickEdit));
  20. this.skill_container_mgr_ = new YotogiOldSkillContainerViewer(base.root_obj, this);
  21. this.skill_container_mgr_.SetOnSkillChangeEvent(new Action<YotogiOldSkillContainerViewer>(this.OnSkillChangeEvent));
  22. this.arrow_obj_ = UTY.GetChildObject(base.root_obj, "CategoryViewer/Arrow", false);
  23. GameObject childObject = UTY.GetChildObject(base.root_obj, "CategoryViewer/Content", false);
  24. GameObject childObject2 = UTY.GetChildObject(childObject, "CategoryUnitParent", false);
  25. bool lockNTRPlay = GameMain.Instance.CharacterMgr.status.lockNTRPlay;
  26. this.category_data_array_ = new YotogiOldSkillSelectManager.CategoryData[9];
  27. for (int i = 0; i < this.category_data_array_.Length; i++)
  28. {
  29. this.category_data_array_[i].skill_list = new List<YotogiOld.SkillDataPair>();
  30. this.category_data_array_[i].category = (YotogiOld.Category)i;
  31. this.category_data_array_[i].obj = Utility.CreatePrefab(childObject2, "SceneYotogi/SkillSelect/Prefab/CategoryBtn", true);
  32. this.category_data_array_[i].obj.name = this.category_data_array_[i].category.ToString();
  33. UTY.GetChildObject(this.category_data_array_[i].obj, "Label", false).GetComponent<UILabel>().text = this.category_data_array_[i].obj.name;
  34. UIWFTabButton component = UTY.GetChildObject(this.category_data_array_[i].obj, "Button", false).GetComponent<UIWFTabButton>();
  35. EventDelegate eventDelegate = new EventDelegate(this, "OnClickFromCategoryButton");
  36. EventDelegate.Parameter[] parameters = eventDelegate.parameters;
  37. parameters[0].value = this.category_data_array_[i].obj;
  38. parameters[1].value = (YotogiOld.Category)i;
  39. if (lockNTRPlay && (this.category_data_array_[i].category == YotogiOld.Category.交換 || this.category_data_array_[i].category == YotogiOld.Category.乱交))
  40. {
  41. this.category_data_array_[i].obj.SetActive(false);
  42. }
  43. component.onClick.Add(eventDelegate);
  44. }
  45. this.tab_panel_ = childObject2.GetComponent<UIWFTabPanel>();
  46. this.tab_panel_.UpdateChildren();
  47. Utility.ResetNGUI(childObject2.GetComponent<UIGrid>());
  48. Utility.ResetNGUI(childObject.GetComponent<UIScrollView>());
  49. childObject.GetComponent<UIPanel>().UpdateAnchors();
  50. }
  51. protected override bool IsCallFadeIn()
  52. {
  53. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  54. Maid man = characterMgr.GetMan(0);
  55. bool result = false;
  56. if (!man.IsBusy && !this.maid_.IsBusy)
  57. {
  58. man.Visible = false;
  59. this.maid_.SetPosOffset(Vector3.zero);
  60. if (YotogiOldSkillSelectWaitMotion.ApplyMaidGesture(this.maid_, this.setting_stage_data_.stage))
  61. {
  62. result = true;
  63. }
  64. }
  65. return result;
  66. }
  67. protected override void OnCall()
  68. {
  69. GameMain.Instance.ScriptMgr.compatibilityMode = true;
  70. this.maid_ = this.yotogi_mgr_.maid;
  71. this.paramenter_viewer_.SetMaid(this.maid_);
  72. this.possible_maid_num_ = this.yotogi_mgr_.GetPlayPossibleMaidCount();
  73. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  74. for (int i = 0; i < characterMgr.GetMaidCount(); i++)
  75. {
  76. Maid maid = characterMgr.GetMaid(i);
  77. if (maid != null && maid != this.maid_ && maid.Visible)
  78. {
  79. maid.Visible = false;
  80. }
  81. }
  82. GameMain.Instance.MainLight.Reset();
  83. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  84. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  85. GameMain.Instance.SoundMgr.VoiceStopAll();
  86. YotogiOld.Stage key = YotogiOld.Stage.プレイル\u30FCム;
  87. if (!string.IsNullOrEmpty(YotogiOldStageSelectManager.StageName))
  88. {
  89. try
  90. {
  91. key = (YotogiOld.Stage)Enum.Parse(typeof(YotogiOld.Stage), YotogiOldStageSelectManager.StageName);
  92. }
  93. catch
  94. {
  95. NDebug.Assert("Yotogi.Stage enum convert error.\n" + YotogiOldStageSelectManager.StageName, false);
  96. }
  97. }
  98. this.setting_stage_data_ = YotogiOld.stage_data_list[key];
  99. GameMain.Instance.SoundMgr.PlayBGM(this.setting_stage_data_.bgm_file, 1.5f, true);
  100. this.yotogi_mgr_.CreateBackUpSkillID();
  101. this.yotogi_mgr_.fix_skill_level = 0;
  102. if (!string.IsNullOrEmpty(YotogiOldStageSelectManager.StagePrefab))
  103. {
  104. GameMain.Instance.BgMgr.ChangeBg(YotogiOldStageSelectManager.StagePrefab);
  105. }
  106. this.maid_.status.currentHp = this.maid_.status.maxHp;
  107. this.maid_.status.currentMind = this.maid_.status.maxMind;
  108. this.maid_.status.currentReason = this.maid_.status.maxReason;
  109. Maid man = characterMgr.GetMan(0);
  110. man.Visible = true;
  111. this.maid_.Visible = true;
  112. man.AllProcPropSeqStart();
  113. this.maid_.AllProcPropSeqStart();
  114. this.common_buttons_.next_btn.onClick.Clear();
  115. EventDelegate.Add(this.common_buttons_.next_btn.onClick, new EventDelegate.Callback(this.OnClickNext));
  116. this.common_buttons_.viwe_reset_btn.gameObject.SetActive(false);
  117. this.paramenter_viewer_.SetMaid(this.maid_);
  118. this.paramenter_viewer_.UpdateTextCommon();
  119. this.paramenter_viewer_.UpdateTextParam();
  120. this.skill_container_mgr_.Init(this.maid_);
  121. this.skill_container_mgr_.SetMaxHp(this.maid_.status.maxHp);
  122. this.skill_container_mgr_.SetCurrentHp(this.maid_.status.currentHp);
  123. for (int j = 0; j < this.category_data_array_.Length; j++)
  124. {
  125. this.category_data_array_[j].skill_list.Clear();
  126. }
  127. ReadOnlySortedDictionary<int, YotogiSkillData> oldDatas = this.maid_.status.yotogiSkill.oldDatas;
  128. foreach (YotogiSkillData yotogiSkillData in oldDatas.GetValueArray())
  129. {
  130. Skill.Old.Data oldData = yotogiSkillData.oldData;
  131. if (oldData.IsExecStage(this.setting_stage_data_.stage) && oldData.IsExecMaid(this.maid_.status))
  132. {
  133. this.category_data_array_[(int)oldData.category].skill_list.Add(YotogiOld.SkillDataPair.Create(this.maid_, oldData));
  134. }
  135. }
  136. for (int l = 0; l < this.category_data_array_.Length; l++)
  137. {
  138. this.category_data_array_[l].skill_list.Sort((YotogiOld.SkillDataPair a, YotogiOld.SkillDataPair b) => a.base_data.id - b.base_data.id);
  139. if (this.category_data_array_[l].obj != null)
  140. {
  141. UIButton component = UTY.GetChildObject(this.category_data_array_[l].obj, "Button", false).GetComponent<UIButton>();
  142. component.isEnabled = (0 < this.category_data_array_[l].skill_list.Count);
  143. }
  144. }
  145. for (int m = 0; m < this.category_data_array_.Length; m++)
  146. {
  147. if (0 < this.category_data_array_[m].skill_list.Count && this.category_data_array_[m].obj != null)
  148. {
  149. this.tab_panel_.Select(UTY.GetChildObject(this.category_data_array_[m].obj, "Button", false).GetComponent<UIWFTabButton>());
  150. break;
  151. }
  152. }
  153. GameMain.Instance.TutorialPanel.SetImage(TutorialPanel.ImageSet.Yotogi, false);
  154. }
  155. private void SetCategorySkill(YotogiOld.Category category)
  156. {
  157. GameObject childObject = UTY.GetChildObject(base.root_obj, "SkillViewer/Contents", false);
  158. GameObject childObject2 = UTY.GetChildObject(childObject, "SkillUnitParent", false);
  159. Transform transform = childObject2.transform;
  160. this.skill_unit_list_.Clear();
  161. for (int i = 0; i < transform.childCount; i++)
  162. {
  163. UnityEngine.Object.Destroy(transform.GetChild(i).gameObject);
  164. }
  165. transform.DetachChildren();
  166. List<YotogiOld.SkillDataPair> skill_list = this.category_data_array_[(int)category].skill_list;
  167. for (int j = 0; j < skill_list.Count; j++)
  168. {
  169. GameObject gameObject = this.CreateNewSkillUnit(childObject2);
  170. YotogiOldSkillUnit component = gameObject.GetComponent<YotogiOldSkillUnit>();
  171. component.SetSkillData(this.maid_, skill_list[j].base_data, skill_list[j].param);
  172. this.skill_unit_list_.Add(gameObject);
  173. }
  174. Utility.ResetNGUI(childObject2.GetComponent<UIGrid>());
  175. Utility.ResetNGUI(childObject.GetComponent<UIScrollView>());
  176. this.OnSkillChangeEvent(this.skill_container_mgr_);
  177. }
  178. private void OnClickFromSkillUnit(GameObject game_obj)
  179. {
  180. YotogiOldSkillUnit component = game_obj.GetComponent<YotogiOldSkillUnit>();
  181. this.skill_container_mgr_.AddSkill(component.skill_data);
  182. }
  183. private void OnClickFromCategoryButton(GameObject obj, YotogiOld.Category category)
  184. {
  185. for (int i = 0; i < this.category_data_array_.Length; i++)
  186. {
  187. if (this.category_data_array_[i].category == category)
  188. {
  189. this.SetCategorySkill(this.category_data_array_[i].category);
  190. Vector3 position = this.category_data_array_[i].obj.transform.TransformPoint(new Vector3(0f, 0f, 0f));
  191. Vector3 local_pos = this.arrow_obj_.transform.parent.InverseTransformPoint(position);
  192. local_pos.x = this.arrow_obj_.transform.localPosition.x;
  193. local_pos.y += 18f;
  194. Hashtable args = TweenHash.EaseOutQuint(TweenHash.Type.Position, local_pos, 0.3f);
  195. iTween.MoveTo(this.arrow_obj_, args);
  196. }
  197. }
  198. }
  199. private void OnSkillChangeEvent(YotogiOldSkillContainerViewer obj)
  200. {
  201. Skill.Old.Data[] settingSkillArray = obj.GetSettingSkillArray();
  202. int num = this.yotogi_mgr_.skill_select_max_hp;
  203. for (int i = 0; i < settingSkillArray.Length; i++)
  204. {
  205. num -= settingSkillArray[i].exec_need_hp;
  206. }
  207. bool flag = settingSkillArray.Length != 7 && 0 < num;
  208. for (int j = 0; j < this.skill_unit_list_.Count; j++)
  209. {
  210. Skill.Old.Data skill_data = this.skill_unit_list_[j].GetComponent<YotogiOldSkillUnit>().skill_data;
  211. bool flag2 = flag;
  212. if (flag2 && this.possible_maid_num_ < skill_data.player_num)
  213. {
  214. flag2 = false;
  215. }
  216. if (flag2 && skill_data.ban_id_array != null && 0 < skill_data.ban_id_array.Length)
  217. {
  218. for (int k = 0; k < skill_data.ban_id_array.Length; k++)
  219. {
  220. for (int l = 0; l < settingSkillArray.Length; l++)
  221. {
  222. if (skill_data.ban_id_array[k] == settingSkillArray[l].id)
  223. {
  224. flag2 = false;
  225. break;
  226. }
  227. }
  228. if (!flag2)
  229. {
  230. break;
  231. }
  232. }
  233. }
  234. UTY.GetChildObject(this.skill_unit_list_[j], "Button", false).GetComponent<UIButton>().isEnabled = flag2;
  235. }
  236. this.skill_container_mgr_.SetCurrentHp(num);
  237. this.maid_.status.currentHp = num;
  238. this.paramenter_viewer_.UpdateTextParam();
  239. this.common_buttons_.next_btn.isEnabled = (0 < settingSkillArray.Length);
  240. }
  241. public void SetEditNextLabel(string label)
  242. {
  243. this.edit_next_label_ = label;
  244. }
  245. private void OnClickAllReset()
  246. {
  247. this.skill_container_mgr_.ResetAllSkill();
  248. }
  249. private GameObject CreateNewSkillUnit(GameObject root)
  250. {
  251. GameObject gameObject = Utility.CreatePrefab(root, "SceneYotogi/SkillSelect/Prefab/Old/SkillUnit", true);
  252. EventDelegate eventDelegate = new EventDelegate(this, "OnClickFromSkillUnit");
  253. EventDelegate.Parameter parameter = eventDelegate.parameters[0];
  254. parameter.obj = gameObject;
  255. GameObject childObject = UTY.GetChildObject(gameObject, "Button", false);
  256. childObject.GetComponent<UIButton>().onClick.Add(eventDelegate);
  257. return gameObject;
  258. }
  259. private void OnClickEdit()
  260. {
  261. if (string.IsNullOrEmpty(this.edit_next_label_))
  262. {
  263. return;
  264. }
  265. this.yotogi_mgr_.null_mgr.SetNextLabel(this.edit_next_label_);
  266. this.Finish();
  267. }
  268. private void OnClickNext()
  269. {
  270. this.yotogi_mgr_.SetPlaySkillArray(this.skill_container_mgr_.GetSettingSkillArray());
  271. if (this.maid_.status.currentHp <= 0)
  272. {
  273. GameMain.Instance.SysDlg.Show("体力が0以下のため気絶します。\n本当に実行しますか?", SystemDialog.TYPE.OK_CANCEL, delegate
  274. {
  275. GameMain.Instance.SysDlg.Close();
  276. if (this.yotogi_mgr_.null_mgr.IsExistNextLabel())
  277. {
  278. this.Finish();
  279. }
  280. }, null);
  281. }
  282. else if (this.yotogi_mgr_.null_mgr.IsExistNextLabel())
  283. {
  284. this.Finish();
  285. }
  286. }
  287. protected override void OnFinish()
  288. {
  289. UIWFTabButton selectButtonObject = this.tab_panel_.GetSelectButtonObject();
  290. if (selectButtonObject != null)
  291. {
  292. selectButtonObject.SetSelect(false);
  293. }
  294. GameMain.Instance.CharacterMgr.SetCharaAllPos(Vector3.zero);
  295. GameMain.Instance.CharacterMgr.SetCharaAllRot(Vector3.zero);
  296. GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
  297. GameMain.Instance.ScriptMgr.StopMotionScript();
  298. if (this.yotogi_mgr_.null_mgr.IsExistNextLabel())
  299. {
  300. this.yotogi_mgr_.CallScreen(YotogiOldManager.CallScreenType.Null.ToString());
  301. }
  302. }
  303. private Maid maid_;
  304. private YotogiOldManager yotogi_mgr_;
  305. private YotogiOld.StageData setting_stage_data_;
  306. private YotogiCommonButtons common_buttons_;
  307. private UIWFTabPanel tab_panel_;
  308. private GameObject arrow_obj_;
  309. private YotogiOldParameterViewer paramenter_viewer_;
  310. private YotogiOldSkillSelectManager.CategoryData[] category_data_array_;
  311. private List<GameObject> skill_unit_list_ = new List<GameObject>();
  312. private YotogiOldSkillContainerViewer skill_container_mgr_;
  313. private string edit_next_label_ = string.Empty;
  314. private int possible_maid_num_;
  315. private struct CategoryData
  316. {
  317. public GameObject obj;
  318. public YotogiOld.Category category;
  319. public List<YotogiOld.SkillDataPair> skill_list;
  320. }
  321. }