MobileInputPlayer.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System;
  2. using FBInput;
  3. using GameWorld;
  4. using I2.Loc;
  5. using UnityEngine;
  6. public class MobileInputPlayer : SingletonMono<MobileInputPlayer>, IInputPlayer
  7. {
  8. public bool Visible
  9. {
  10. get
  11. {
  12. return this._panel.gameObject.activeSelf;
  13. }
  14. set
  15. {
  16. this._panel.gameObject.SetActive(value);
  17. }
  18. }
  19. public bool MainControllerVisiable
  20. {
  21. get
  22. {
  23. return this._mainControllerVisiable;
  24. }
  25. set
  26. {
  27. this._mainControllerVisiable = value;
  28. this._mainController.alpha = (float)((!value) ? 0 : 1);
  29. }
  30. }
  31. public bool OptionsVisible
  32. {
  33. get
  34. {
  35. return this._options.IsActive;
  36. }
  37. set
  38. {
  39. this._options.IsActive = true;
  40. }
  41. }
  42. public bool Button6Visible
  43. {
  44. get
  45. {
  46. return this._button6.IsActive;
  47. }
  48. set
  49. {
  50. this._button6.IsActive = value;
  51. }
  52. }
  53. public bool L2R2Visiable
  54. {
  55. get
  56. {
  57. return this._l2R2Widget.gameObject.activeSelf;
  58. }
  59. private set
  60. {
  61. this._l2R2Widget.gameObject.SetActive(value);
  62. }
  63. }
  64. public void Awake()
  65. {
  66. this.Visible = true;
  67. this.MainControllerVisiable = true;
  68. }
  69. public void VisiableBladeStorm()
  70. {
  71. this._button1.gameObject.SetActive(R.Player.Enhancement.BladeStorm > 0);
  72. }
  73. private void OnEnable()
  74. {
  75. EventManager.RegisterEvent<EnhanceArgs>("EnhanceLevelup", new EventManager.FBEventHandler<EnhanceArgs>(this.OnEnhancementLevelUp), EventManager.ListenerQueue.Game);
  76. }
  77. private void OnDisable()
  78. {
  79. EventManager.UnregisterEvent<EnhanceArgs>("EnhanceLevelup", new EventManager.FBEventHandler<EnhanceArgs>(this.OnEnhancementLevelUp), EventManager.ListenerQueue.Game);
  80. }
  81. private void Update()
  82. {
  83. if (R.Mode.CurrentMode != Mode.AllMode.Battle)
  84. {
  85. return;
  86. }
  87. this._button3Sprite.Term = ((!R.Enemy.CanBeExecutedEnemyExist() || !R.Player.CanExecute()) ? "mobile/uisprite/button_02_1" : "mobile/uisprite/button_02_2");
  88. }
  89. public void EnterSHI()
  90. {
  91. this._button1.gameObject.SetActive(false);
  92. this._button2.gameObject.SetActive(false);
  93. this._button3.gameObject.SetActive(false);
  94. this._button4.gameObject.SetActive(false);
  95. this._button5SHIMainSprite.spriteName = "Button_03";
  96. this._button5SHINumSprite.spriteName = "Num03";
  97. }
  98. public void ExitSHI()
  99. {
  100. this.VisiableBladeStorm();
  101. this._button2.gameObject.SetActive(true);
  102. this._button3.gameObject.SetActive(true);
  103. this._button4.gameObject.SetActive(true);
  104. this._button5SHIMainSprite.spriteName = "Button_01";
  105. this._button5SHINumSprite.spriteName = "Num01";
  106. }
  107. public Vector2 GetJoystick(string axis)
  108. {
  109. if (axis != null)
  110. {
  111. if (axis == "Joystick")
  112. {
  113. return (!this.MainControllerVisiable) ? Vector2.zero : this._joystick.Axis;
  114. }
  115. if (axis == "Swipe")
  116. {
  117. return (!this.MainControllerVisiable) ? Vector2.zero : this._swipe.Direction;
  118. }
  119. }
  120. throw new ArgumentOutOfRangeException("axis", axis);
  121. }
  122. public Vector2 GetJoystickRaw(string axis)
  123. {
  124. if (axis != null)
  125. {
  126. }
  127. throw new ArgumentOutOfRangeException("axis", axis);
  128. }
  129. public bool GetButton(string buttonName)
  130. {
  131. switch (buttonName)
  132. {
  133. case "Button1":
  134. return this.MainControllerVisiable && this._button1.IsPressed;
  135. case "Button2":
  136. return this.MainControllerVisiable && this._button2.IsPressed;
  137. case "Button3":
  138. return this.MainControllerVisiable && this._button3.IsPressed;
  139. case "Button4":
  140. return this.MainControllerVisiable && this._button4.IsPressed;
  141. case "Button5":
  142. return this.MainControllerVisiable && this._button5.IsPressed;
  143. case "Button6":
  144. return this._button6.IsPressed;
  145. case "Options":
  146. return this._options.IsPressed;
  147. case "L2":
  148. return this._l2.IsPressed;
  149. case "R2":
  150. return this._r2.IsPressed;
  151. }
  152. throw new ArgumentOutOfRangeException("buttonName", buttonName, string.Format("Button \"{0}\" is not exist.", buttonName));
  153. }
  154. public void SetVibration(float leftMotorValue, float rightMotorValue)
  155. {
  156. }
  157. public void ShowL2R2(string l2, string r2)
  158. {
  159. if (!this.L2R2Visiable)
  160. {
  161. this.L2R2Visiable = true;
  162. this.MainControllerVisiable = false;
  163. }
  164. this._l2.Text = l2;
  165. this._r2.Text = r2;
  166. }
  167. public void HideL2R2(bool showMainController = true)
  168. {
  169. this.L2R2Visiable = false;
  170. this.MainControllerVisiable = showMainController;
  171. }
  172. private bool OnEnhancementLevelUp(string eventDefine, object sender, EnhanceArgs msg)
  173. {
  174. if (!this._button1.gameObject.activeSelf && msg.Name == "bladeStorm")
  175. {
  176. this._button1.gameObject.SetActive(true);
  177. }
  178. return true;
  179. }
  180. public void UpdateRadiusAndPosition()
  181. {
  182. this._joystick.UpdateRadiusAndPosition();
  183. }
  184. [SerializeField]
  185. private UIPanel _panel;
  186. [SerializeField]
  187. private UIWidget _mainController;
  188. [SerializeField]
  189. private UIWidget _l2R2Widget;
  190. private bool _mainControllerVisiable;
  191. [SerializeField]
  192. private FBButton _button1;
  193. [SerializeField]
  194. private FBButton _button2;
  195. [SerializeField]
  196. private FBButton _button3;
  197. [SerializeField]
  198. private FBButton _button4;
  199. [SerializeField]
  200. private FBButton _button5;
  201. [SerializeField]
  202. private FBButton _button6;
  203. [SerializeField]
  204. private FBButton _options;
  205. [SerializeField]
  206. private FBButton _l2;
  207. [SerializeField]
  208. private FBButton _r2;
  209. [SerializeField]
  210. private FBTouchPad _joystick;
  211. [SerializeField]
  212. private FBSwipe _swipe;
  213. [SerializeField]
  214. private Localize _button3Sprite;
  215. [SerializeField]
  216. private UISprite _button5SHIMainSprite;
  217. [SerializeField]
  218. private UISprite _button5SHINumSprite;
  219. }