YotogiOldVRStageSelectManager.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. using Yotogis;
  6. public class YotogiOldVRStageSelectManager : WfFadeBehaviour
  7. {
  8. public YotogiOld.StageData selectStageData { get; private set; }
  9. public int selectSpotNo { get; private set; }
  10. public bool visibledCancelBtn
  11. {
  12. get
  13. {
  14. return this.visibledCancelBtnValue;
  15. }
  16. set
  17. {
  18. this.visibledCancelBtnValue = value;
  19. this.UpdateCancelButton();
  20. }
  21. }
  22. public void Awake()
  23. {
  24. Skill.Old.CreateData();
  25. this.stageList = new List<YotogiOld.StageData>();
  26. foreach (KeyValuePair<YotogiOld.Stage, YotogiOld.StageData> keyValuePair in YotogiOld.vr_stage_data_list)
  27. {
  28. this.stageList.Add(keyValuePair.Value);
  29. }
  30. this.stageList.Sort((YotogiOld.StageData a, YotogiOld.StageData b) => a.sort_id - b.sort_id);
  31. this.unitList = new List<StageOldUnitCircle>();
  32. for (int i = 0; i < this.stageList.Count; i++)
  33. {
  34. GameObject gameObject = Utility.CreatePrefab(this.contentGrid.gameObject, "SceneYotogi/StageSelect/Prefab/Old/StageUnitCircle", true);
  35. StageOldUnitCircle component = gameObject.GetComponent<StageOldUnitCircle>();
  36. component.SetStageData(this.stageList[i]);
  37. component.SetOnSelectEvent(new Action<StageOldUnitCircle>(this.OnUnitClick));
  38. component.SetOnFinishAnimeEvent(new Action<StageOldUnitCircle>(this.OnUnitAnimeEnd));
  39. this.unitList.Add(component);
  40. }
  41. this.contentGrid.Reposition();
  42. EventDelegate.Add(this.cancelBtn.onClick, new EventDelegate.Callback(this.OnCancel));
  43. this.selectStageData = null;
  44. this.selectSpotNo = -1;
  45. this.mode = YotogiOldVRStageSelectManager.Mode.StageSelect;
  46. this.widget.alpha = 0f;
  47. }
  48. public override void OnStartedFadeIn()
  49. {
  50. this.widget.alpha = 0f;
  51. this.fadeInStartBgAlpha = this.bgSprite.alpha;
  52. this.fadeInStartBgSize = new Vector2((float)this.bgSprite.width, (float)this.bgSprite.height);
  53. this.mode = YotogiOldVRStageSelectManager.Mode.StageSelect;
  54. this.cancelBtn.normalSprite = "vr_cancel";
  55. this.UpdateCancelButton();
  56. for (int i = 0; i < this.unitList.Count; i++)
  57. {
  58. this.unitList[i].SetStageData(this.stageList[i]);
  59. this.unitList[i].transform.localRotation = Quaternion.identity;
  60. }
  61. }
  62. public override void OnStartedFadeOut()
  63. {
  64. this.uiMask.enabled = true;
  65. }
  66. public override void OnUpdateFadeIn(float val)
  67. {
  68. this.uiMask.enabled = true;
  69. this.bgSprite.alpha = Mathf.Lerp(this.fadeInStartBgAlpha, 1f, val);
  70. this.bgSprite.width = (int)Mathf.Lerp(this.fadeInStartBgSize.x, this.bgSize.x, val);
  71. this.bgSprite.height = (int)Mathf.Lerp(this.fadeInStartBgSize.y, this.bgSize.y, val);
  72. this.widget.alpha = val;
  73. }
  74. public override void OnUpdateFadeOut(float val)
  75. {
  76. this.widget.alpha = val;
  77. }
  78. public override void OnCompleteFadeIn()
  79. {
  80. this.uiMask.enabled = false;
  81. }
  82. public override void OnCompleteFadeOut()
  83. {
  84. this.OnCompleteFadeIn();
  85. }
  86. public void SetStageData(YotogiOld.Stage stage, int spot_no)
  87. {
  88. NDebug.Assert(YotogiOld.vr_stage_data_list.ContainsKey(stage), "vrステージではありません\n" + stage.ToString());
  89. NDebug.Assert(spot_no < YotogiOld.vr_stage_data_list[stage].spot_data.Length, "スポット数が不正です\n" + stage.ToString() + " : " + spot_no.ToString());
  90. this.selectStageData = YotogiOld.vr_stage_data_list[stage];
  91. this.selectSpotNo = spot_no;
  92. }
  93. private void OnCancel()
  94. {
  95. if (this.mode == YotogiOldVRStageSelectManager.Mode.StageSelect)
  96. {
  97. EventDelegate.Execute(this.onClickCancelEvent);
  98. return;
  99. }
  100. this.mode = YotogiOldVRStageSelectManager.Mode.StageSelect;
  101. this.cancelBtn.normalSprite = "vr_cancel";
  102. this.UpdateCancelButton();
  103. int num = 0;
  104. while (num < this.unitList.Count && num < this.selectStageData.spot_data.Length)
  105. {
  106. this.unitList[num].PlayAnimeFadeOut();
  107. num++;
  108. }
  109. }
  110. private void OnUnitClick(StageOldUnitCircle unit)
  111. {
  112. if (this.mode == YotogiOldVRStageSelectManager.Mode.StageSelect)
  113. {
  114. this.uiMask.enabled = true;
  115. this.selectStageData = unit.stage_data;
  116. this.selectSpotNo = -1;
  117. this.mode = YotogiOldVRStageSelectManager.Mode.SpotSelect;
  118. for (int i = 0; i < this.unitList.Count; i++)
  119. {
  120. this.unitList[i].PlayAnimeFadeOut();
  121. }
  122. this.cancelBtn.normalSprite = "vr_back";
  123. this.cancelBtn.gameObject.SetActive(true);
  124. }
  125. else if (this.mode == YotogiOldVRStageSelectManager.Mode.SpotSelect)
  126. {
  127. this.selectSpotNo = unit.spot_no;
  128. EventDelegate.Execute(this.onClickEnterEvent);
  129. }
  130. }
  131. private void OnUnitAnimeEnd(StageOldUnitCircle unit)
  132. {
  133. int num = 0;
  134. while (num < this.unitList.Count && unit != this.unitList[num])
  135. {
  136. num++;
  137. }
  138. if (this.unitList.Count <= num)
  139. {
  140. return;
  141. }
  142. this.uiMask.enabled = false;
  143. if (this.mode == YotogiOldVRStageSelectManager.Mode.SpotSelect)
  144. {
  145. if (num < this.selectStageData.spot_data.Length)
  146. {
  147. unit.SetStageSpotData(this.selectStageData, num);
  148. unit.PlayAnimeFadeIn();
  149. }
  150. this.cancelBtn.gameObject.SetActive(true);
  151. }
  152. else if (this.mode == YotogiOldVRStageSelectManager.Mode.StageSelect)
  153. {
  154. if (num == 0)
  155. {
  156. for (int i = 0; i < this.unitList.Count; i++)
  157. {
  158. if (i >= this.selectStageData.spot_data.Length)
  159. {
  160. this.unitList[i].SetStageData(this.stageList[i]);
  161. this.unitList[i].PlayAnimeFadeIn();
  162. }
  163. }
  164. this.UpdateCancelButton();
  165. }
  166. this.selectSpotNo = -1;
  167. unit.SetStageData(this.stageList[num]);
  168. unit.PlayAnimeFadeIn();
  169. }
  170. }
  171. private void UpdateCancelButton()
  172. {
  173. if (this.mode == YotogiOldVRStageSelectManager.Mode.StageSelect)
  174. {
  175. this.cancelBtn.gameObject.SetActive(this.visibledCancelBtnValue);
  176. }
  177. else
  178. {
  179. this.cancelBtn.gameObject.SetActive(true);
  180. }
  181. }
  182. [SerializeField]
  183. private UISprite bgSprite;
  184. [SerializeField]
  185. private Vector2 bgSize;
  186. [SerializeField]
  187. private UIWFHitMasks uiMask;
  188. [SerializeField]
  189. private UIButton cancelBtn;
  190. [SerializeField]
  191. private UIGrid contentGrid;
  192. [SerializeField]
  193. private UIWidget widget;
  194. [HideInInspector]
  195. public List<EventDelegate> onClickEnterEvent = new List<EventDelegate>();
  196. [HideInInspector]
  197. public List<EventDelegate> onClickCancelEvent = new List<EventDelegate>();
  198. private YotogiOldVRStageSelectManager.Mode mode;
  199. private List<YotogiOld.StageData> stageList;
  200. private List<StageOldUnitCircle> unitList;
  201. private Vector2 fadeInStartBgSize;
  202. private float fadeInStartBgAlpha;
  203. private bool visibledCancelBtnValue;
  204. private enum Mode
  205. {
  206. StageSelect,
  207. SpotSelect
  208. }
  209. }