PlayerController.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. // Learn cc.Class:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/class.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. cc.Class({
  8. extends: cc.Component,
  9. properties: {
  10. left: {
  11. // ATTRIBUTES:
  12. default: null, // The default value will be used only when the component attaching
  13. // to a node for the first time
  14. type: cc.Label, // optional, default is typeof default
  15. serializable: true, // optional, default is true
  16. },
  17. mid: {
  18. // ATTRIBUTES:
  19. default: null, // The default value will be used only when the component attaching
  20. // to a node for the first time
  21. type: cc.Label, // optional, default is typeof default
  22. serializable: true, // optional, default is true
  23. },
  24. right: {
  25. // ATTRIBUTES:
  26. default: null, // The default value will be used only when the component attaching
  27. // to a node for the first time
  28. type: cc.Label, // optional, default is typeof default
  29. serializable: true, // optional, default is true
  30. },
  31. front: {
  32. // ATTRIBUTES:
  33. default: null, // The default value will be used only when the component attaching
  34. // to a node for the first time
  35. type: cc.Label, // optional, default is typeof default
  36. serializable: true, // optional, default is true
  37. },
  38. back: {
  39. // ATTRIBUTES:
  40. default: null, // The default value will be used only when the component attaching
  41. // to a node for the first time
  42. type: cc.Label, // optional, default is typeof default
  43. serializable: true, // optional, default is true
  44. },
  45. limitLabel: {
  46. // ATTRIBUTES:
  47. default: null, // The default value will be used only when the component attaching
  48. // to a node for the first time
  49. type: cc.Label, // optional, default is typeof default
  50. serializable: true, // optional, default is true
  51. },
  52. limitDirectionLabel: {
  53. // ATTRIBUTES:
  54. default: null, // The default value will be used only when the component attaching
  55. // to a node for the first time
  56. type: cc.Label, // optional, default is typeof default
  57. serializable: true, // optional, default is true
  58. },
  59. x: {
  60. default: null,
  61. type: cc.Label,
  62. serializable: true,
  63. },
  64. y: {
  65. default: null,
  66. type: cc.Label,
  67. serializable: true,
  68. },
  69. z: {
  70. default: null,
  71. type: cc.Label,
  72. serializable: true,
  73. },
  74. sqrt: {
  75. default: null,
  76. type: cc.Label,
  77. serializable: true,
  78. },
  79. ox: {
  80. default: null,
  81. type: cc.Label,
  82. serializable: true,
  83. },
  84. oy: {
  85. default: null,
  86. type: cc.Label,
  87. serializable: true,
  88. },
  89. oz: {
  90. default: null,
  91. type: cc.Label,
  92. serializable: true,
  93. },
  94. oriSqrt: {
  95. default: null,
  96. type: cc.Label,
  97. serializable: true,
  98. },
  99. hitCountL: {
  100. default: null,
  101. type: cc.Label,
  102. serializable: true,
  103. },
  104. hitCountZ: {
  105. default: null,
  106. type: cc.Label,
  107. serializable: true,
  108. },
  109. //调用测试次数
  110. phoneIndex: {
  111. default: null,
  112. type: cc.Label,
  113. serializable: true,
  114. },
  115. BLEIndex: {
  116. default: null,
  117. type: cc.Label,
  118. serializable: true,
  119. },
  120. avePhoneIndex: {
  121. default: null,
  122. type: cc.Label,
  123. serializable: true,
  124. },
  125. aveBLEIndex: {
  126. default: null,
  127. type: cc.Label,
  128. serializable: true,
  129. },
  130. writeValue: {
  131. default: '',
  132. visible: false,
  133. serializable: true,
  134. },
  135. jumpCount: {
  136. default: null,
  137. type: cc.Label,
  138. serializable: true,
  139. },
  140. runCount: {
  141. default: null,
  142. type: cc.Label,
  143. serializable: true,
  144. },
  145. moveState: {
  146. default: null,
  147. type: cc.Label,
  148. serializable: true,
  149. },
  150. handleState: {
  151. default: null,
  152. type: cc.Label,
  153. serializable: true,
  154. },
  155. min: {
  156. default: null,
  157. type: cc.Label,
  158. serializable: true,
  159. },
  160. s: {
  161. default: null,
  162. type: cc.Label,
  163. serializable: true,
  164. },
  165. ms: {
  166. default: null,
  167. type: cc.Label,
  168. serializable: true,
  169. }
  170. },
  171. // LIFE-CYCLE CALLBACKS:
  172. // onLoad () {},
  173. start() {
  174. this.leftCount = 0;
  175. this.rightCount = 0;
  176. this.midCount = 0;
  177. this.backCount = 0;
  178. this.onJumpCount(0);
  179. this.onRunCount(0);
  180. this.onResetState();
  181. },
  182. leftHook() {
  183. console.log("左勾拳");
  184. this.leftCount++;
  185. this.left.string = "左勾拳:" + this.leftCount;
  186. },
  187. jar() {
  188. console.log("直拳");
  189. this.midCount++;
  190. this.mid.string = "直拳:" + this.midCount;
  191. },
  192. rightHook() {
  193. console.log("右勾拳");
  194. this.rightCount++;
  195. this.right.string = "右勾拳: " + this.rightCount;
  196. },
  197. leftJump() {
  198. this.leftCount++;
  199. this.left.string = "左:" + this.leftCount;
  200. },
  201. frontJump() {
  202. this.midCount++;
  203. this.mid.string = "前:" + this.midCount;
  204. },
  205. rightJump() {
  206. this.rightCount++;
  207. this.right.string = "右: " + this.rightCount;
  208. },
  209. backJump() {
  210. this.backCount++;
  211. this.back.string = "后: " + this.backCount;
  212. },
  213. onSlide(e, customEventData) {
  214. // console.log(e.progress);
  215. window.webView.currentLimitValue = Math.floor(e.progress * 15);
  216. console.log("webview.currentLimitValue:", window.webView.currentLimitValue);
  217. this.limitLabel.string = window.webView.currentLimitValue;
  218. },
  219. onSlideDirection(e, customEventData) {
  220. // console.log(e.progress);
  221. window.webView.currentLimitDireValue = Math.floor(e.progress * 1000) / 100;
  222. console.log("webview.currentLimitDireValue:", window.webView.currentLimitDireValue);
  223. this.limitDirectionLabel.string = window.webView.currentLimitDireValue;
  224. },
  225. updateLMR(acc) {
  226. this.left.string = "x:" + acc.xAxis.toFixed(5);
  227. this.mid.string = "y:" + acc.yAxis.toFixed(5);
  228. this.right.string = "z:" + acc.zAxis.toFixed(5);
  229. },
  230. updateAcc(acc) {
  231. this.x.string = "x:" + acc.xAxis.toFixed(5);
  232. this.y.string = "y:" + acc.yAxis.toFixed(5);
  233. this.z.string = "z:" + acc.zAxis.toFixed(5);
  234. },
  235. updateStr(data) {
  236. this.sqrt.string = "d:" + data;
  237. },
  238. updateSqrt(value) {
  239. this.sqrt.string = "sqrt:" + value.toFixed(5);
  240. },
  241. updateOriSqrt(value) {
  242. this.oriSqrt.string = "oriS:" + value.toFixed(5);
  243. },
  244. updateOri(ori) {
  245. this.ox.string = " ox:" + ori.beta;
  246. this.oy.string = " oy:" + ori.gamma;
  247. this.oz.string = " oz:" + ori.alpha;
  248. },
  249. updateOriBeta(ori) {
  250. this.ox.string = "ox:" + ori.beta;
  251. },
  252. updateOriGamma(ori) {
  253. this.oy.string = "oy:" + ori.gamma;
  254. },
  255. updateOriAlpha(ori) {
  256. this.oz.string = "oz:" + ori.alpha;
  257. },
  258. updateHitCountL(data) {
  259. this.hitCountL.string = "hitx:" + data;
  260. },
  261. updateHitCountZ(data) {
  262. this.hitCountZ.string = "hitz:" + data.toFixed(2);
  263. },
  264. updatePhoneIndex(data) {
  265. this.phoneIndex.string = "p:" + data;
  266. },
  267. updateBLEIndex(data) {
  268. this.BLEIndex.string = "b:" + data;
  269. },
  270. onAvePhoneIndex(data) {
  271. this.avePhoneIndex.string = "ap:" + data;
  272. },
  273. onAveBLEIndex(data) {
  274. this.aveBLEIndex.string = "ab:" + data;
  275. },
  276. onWriteValueChange(data) {
  277. console.log(data);
  278. this.writeValue = data;
  279. },
  280. onJumpCount(data) {
  281. this.jumpCount.string = "jump:" + data;
  282. },
  283. onRunCount(data) {
  284. if (this.runCount)
  285. this.runCount.string = "run:" + data;
  286. },
  287. onMoveState(data) {
  288. this.moveState.string = "state:" + data;
  289. },
  290. onResetState() {
  291. this.moveState.string = "state: 无";
  292. },
  293. onHandleState(data) {
  294. this.handleState.string = "手柄:" + data;
  295. },
  296. updateTime(data) {
  297. this.min.string = "min:" + data.min.toFixed(1);
  298. this.s.string = "s:" + data.s.toFixed(1);
  299. this.ms.string = "ms:" + data.ms.toFixed(1);
  300. },
  301. onLeftCount(data) {
  302. this.left.string = "jump:" + data;
  303. }
  304. });