PlayerInput.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. using System;
  2. using Core;
  3. public class PlayerInput : BaseBehaviour
  4. {
  5. private void Awake()
  6. {
  7. this.pab = base.GetComponent<PlayerAbilities>();
  8. this.pAttr = R.Player.Attribute;
  9. }
  10. private void Update()
  11. {
  12. if (!R.SceneData.isPausing)
  13. {
  14. this.UpdateInput();
  15. }
  16. }
  17. private void UpdateInput()
  18. {
  19. if (this.pAttr.isDead)
  20. {
  21. return;
  22. }
  23. if (!this.battlePause)
  24. {
  25. if (Input.Game.JumpDown.OnPressed)
  26. {
  27. this.pab.jumpDown.JumpDown();
  28. return;
  29. }
  30. if (Input.Game.BladeStorm.OnPressed)
  31. {
  32. this.pab.skill.BladeStorm();
  33. return;
  34. }
  35. if (Input.Game.ShadeAtk.OnPressed)
  36. {
  37. this.pab.skill.ShadeAtk();
  38. return;
  39. }
  40. if (PlayerInput.Setting.CanFlash)
  41. {
  42. if (Input.Game.Flash.RightUp.OnPressed)
  43. {
  44. this.pab.flash.FlashRightUp();
  45. return;
  46. }
  47. if (Input.Game.Flash.RightDown.OnPressed)
  48. {
  49. this.pab.flash.FlashRightDown();
  50. return;
  51. }
  52. if (Input.Game.Flash.LeftUp.OnPressed)
  53. {
  54. this.pab.flash.FlashLeftUp();
  55. return;
  56. }
  57. if (Input.Game.Flash.LeftDown.OnPressed)
  58. {
  59. this.pab.flash.FlashLeftDown();
  60. return;
  61. }
  62. if (Input.Game.Flash.Left.OnPressed)
  63. {
  64. this.pab.flash.FlashLeft();
  65. return;
  66. }
  67. if (Input.Game.Flash.Right.OnPressed)
  68. {
  69. this.pab.flash.FlashRight();
  70. return;
  71. }
  72. if (Input.Game.Flash.Up.OnPressed)
  73. {
  74. this.pab.flash.FlashUp();
  75. return;
  76. }
  77. if (Input.Game.Flash.Down.OnPressed)
  78. {
  79. this.pab.flash.FlashDown();
  80. return;
  81. }
  82. if (Input.Game.Flash.FaceDirection.OnPressed)
  83. {
  84. this.pab.flash.FlashFace();
  85. return;
  86. }
  87. }
  88. if (Input.Game.UpRising.OnPressed && PlayerInput.Setting.CanUpRising)
  89. {
  90. this.pab.upRising.UpJumpAttack();
  91. }
  92. if (Input.Game.HitGround.OnPressed)
  93. {
  94. this.pab.hitGround.HitGround();
  95. }
  96. if (Input.Game.FlashAttack.OnPressed && this.pab.flashAttack.PressFlashAttack())
  97. {
  98. return;
  99. }
  100. if (Input.Game.Execute.OnPressed && PlayerInput.Setting.CanExecute)
  101. {
  102. this.pab.execute.Execute();
  103. return;
  104. }
  105. if (Input.Game.Chase.OnPressed)
  106. {
  107. this.pab.chase.Chase();
  108. }
  109. if (Input.Game.Jump.OnPressed && PlayerInput.Setting.CanJump)
  110. {
  111. this.pab.jump.Jump();
  112. }
  113. if (Input.Game.Atk.OnClick && PlayerInput.Setting.CanAttack)
  114. {
  115. if (Input.Game.MoveLeft.Pressed)
  116. {
  117. this.pab.attack.PlayerAttack(-1, false);
  118. }
  119. else if (Input.Game.MoveRight.Pressed)
  120. {
  121. this.pab.attack.PlayerAttack(1, false);
  122. }
  123. else
  124. {
  125. this.pab.attack.PlayerAttack(3, false);
  126. }
  127. }
  128. if (Input.Game.CirtAtk.OnClick && PlayerInput.Setting.CanAttack)
  129. {
  130. if (Input.Game.MoveLeft.Pressed)
  131. {
  132. this.pab.attack.PlayerAttack(-1, true);
  133. }
  134. else if (Input.Game.MoveRight.Pressed)
  135. {
  136. this.pab.attack.PlayerAttack(1, true);
  137. }
  138. else
  139. {
  140. this.pab.attack.PlayerAttack(3, true);
  141. }
  142. }
  143. if (Input.Game.CirtAtk.LongPressed && PlayerInput.Setting.CanAttack)
  144. {
  145. if (Input.Game.MoveLeft.Pressed)
  146. {
  147. this.pab.attack.PlayerCirtPressAttack(-1);
  148. }
  149. else if (Input.Game.MoveRight.Pressed)
  150. {
  151. this.pab.attack.PlayerCirtPressAttack(1);
  152. }
  153. else
  154. {
  155. this.pab.attack.PlayerCirtPressAttack(3);
  156. }
  157. }
  158. if (Input.Game.CirtAtk.OnReleased && PlayerInput.Setting.CanAttack)
  159. {
  160. this.pab.attack.PlayerCirtPressAttackReleasd();
  161. }
  162. if (Input.Game.Charging.LongPressed && PlayerInput.Setting.CanCharging)
  163. {
  164. this.pab.charge.Charging();
  165. }
  166. }
  167. if (PlayerInput.Setting.CanMove)
  168. {
  169. if (Input.Game.MoveLeft.Pressed)
  170. {
  171. this.pab.move.Move(-1);
  172. }
  173. else if (Input.Game.MoveRight.Pressed)
  174. {
  175. this.pab.move.Move(1);
  176. }
  177. if (Input.Game.MoveLeft.OnReleased || Input.Game.MoveRight.OnReleased)
  178. {
  179. R.Player.Action.tempDir = 3;
  180. }
  181. }
  182. }
  183. private const int LEFT = -1;
  184. private const int RIGHT = 1;
  185. private const int CURRENT = 3;
  186. private PlayerAttribute pAttr;
  187. private PlayerAbilities pab;
  188. public bool battlePause;
  189. public class Setting
  190. {
  191. private static void SetFlag(PlayerInput.Setting.InputType inputType, bool value)
  192. {
  193. if (value)
  194. {
  195. PlayerInput.Setting.AllowInput |= inputType;
  196. }
  197. else
  198. {
  199. PlayerInput.Setting.AllowInput &= ~inputType;
  200. }
  201. }
  202. private static bool GetFlag(PlayerInput.Setting.InputType inputType)
  203. {
  204. return (inputType & PlayerInput.Setting.AllowInput) == inputType;
  205. }
  206. public static bool CanJump
  207. {
  208. get
  209. {
  210. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Jump);
  211. }
  212. set
  213. {
  214. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Jump, value);
  215. }
  216. }
  217. public static bool CanMove
  218. {
  219. get
  220. {
  221. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Move);
  222. }
  223. set
  224. {
  225. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Move, value);
  226. }
  227. }
  228. public static bool CanAttack
  229. {
  230. get
  231. {
  232. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Attack);
  233. }
  234. set
  235. {
  236. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Attack, value);
  237. }
  238. }
  239. public static bool CanFlash
  240. {
  241. get
  242. {
  243. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Flash);
  244. }
  245. set
  246. {
  247. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Flash, value);
  248. }
  249. }
  250. public static bool CanSkill
  251. {
  252. get
  253. {
  254. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Skill);
  255. }
  256. set
  257. {
  258. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Skill, value);
  259. }
  260. }
  261. public static bool CanUpRising
  262. {
  263. get
  264. {
  265. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.UpRising);
  266. }
  267. set
  268. {
  269. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.UpRising, value);
  270. }
  271. }
  272. public static bool CanHitGround
  273. {
  274. get
  275. {
  276. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.HitGround);
  277. }
  278. set
  279. {
  280. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.HitGround, value);
  281. }
  282. }
  283. public static bool CanCharging
  284. {
  285. get
  286. {
  287. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Charging);
  288. }
  289. set
  290. {
  291. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Charging, value);
  292. }
  293. }
  294. public static bool CanExecute
  295. {
  296. get
  297. {
  298. return PlayerInput.Setting.GetFlag(PlayerInput.Setting.InputType.Execute);
  299. }
  300. set
  301. {
  302. PlayerInput.Setting.SetFlag(PlayerInput.Setting.InputType.Execute, value);
  303. }
  304. }
  305. public static PlayerInput.Setting.InputType AllowInput = PlayerInput.Setting.InputType.All;
  306. [Flags]
  307. public enum InputType
  308. {
  309. None = 0,
  310. Move = 1,
  311. Attack = 2,
  312. Flash = 4,
  313. Skill = 8,
  314. HitGround = 16,
  315. UpRising = 32,
  316. Jump = 64,
  317. Charging = 128,
  318. Execute = 256,
  319. Option = 512,
  320. Map = 1024,
  321. All = 2047
  322. }
  323. }
  324. }