action-hit.vue 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645
  1. <!-- 新版本拳击区域部分文件 -->
  2. <template>
  3. <view style="width: 750rpx;">
  4. <view class="flex justify-center" style="margin-top: 68rpx;">
  5. <!-- 目前格子数量不代表数字,显示完成度而已 -460rpx;-->
  6. <view class="grid-progress-vertical-container" style="top:-376rpx;">
  7. <view class="grid-progress-vertical-bar">
  8. <view class="grid-progress-vertical-child" v-for="(item, index) in maxShowCount +1" :key="index"
  9. v-if="index!==0">
  10. <view
  11. :class="showCurCount>=index? 'grid-progress-vertical-active':'grid-progress-vertical-inactive'">
  12. </view>
  13. <view :class="(index%5 == 0||index == 1)?'':'grid-progress-text-hidden'"
  14. class="grid-progress-vertical-text" style="position: absolute;right: 0;top: -4px;">
  15. {{Math.floor(taskSignCount / 26 * index)}}
  16. </view>
  17. </view>
  18. </view>
  19. <view class="grid-progress-vertical-bar">
  20. <view class="grid-progress-vertical-child" v-for="(item, index) in maxShowCount +1" :key="index"
  21. v-if="index!==0">
  22. <view :class="(index%5 == 0||index == 1)?'':'grid-progress-text-hidden'"
  23. class="grid-progress-vertical-text" style="position: absolute;left: 0;top: -4px;">
  24. {{Math.floor(taskSignCount / 26 * index)+taskSignCount/2}}
  25. </view>
  26. <!-- 设置空位 -->
  27. <view></view>
  28. <view
  29. :class="showCurCount>=index+13? 'grid-progress-vertical-active':'grid-progress-vertical-inactive'">
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- class="position-relative" -->
  36. <view style="position: relative;">
  37. <view class="position-absolute-left-top flex justify-center align-center " style="width: 86.12px;height:55.96px;
  38. left: 146rpx;top:-90rpx; ">
  39. <view style="transform: scale(0.5);">
  40. <view class="sprite-yellow-arrow " :class="bRuning?'animation-play-state-play':''"></view>
  41. </view>
  42. </view>
  43. <view class="position-absolute-right-bottom flex justify-center align-center "
  44. style="width: 317rpx; height:138px; right: 46rpx; bottom: 15rpx;">
  45. <view class="flex flex-direction justify-between" style="transform: scale(0.5); height: 276px; ">
  46. <block v-if="bJumpPlay">
  47. <view class="sprite-rightToLeftArrow" :class="bJumpPlay?'sprite-rightToLeftArrow-play':''">
  48. </view>
  49. <view class="sprite-rightToLeftArrow" :class="bJumpPlay?'sprite-rightToLeftArrow-play':''">
  50. </view>
  51. </block>
  52. <block v-else>
  53. <image style="width: 317px; height: 42px;"
  54. src="../../../static/modal/action-jump/progress-tip.png"></image>
  55. <image style="width: 317px; height: 42px;"
  56. src="../../../static/modal/action-jump/progress-tip.png"></image>
  57. </block>
  58. </view>
  59. </view>
  60. <canvas canvas-id="actionHitCanvas" :style="{ width: canvasW + 'px', height: canvasH + 'px' }"></canvas>
  61. </view>
  62. <view style="position: absolute;
  63. top: 30px;
  64. bottom: 0;
  65. left: 0;
  66. right: 0;
  67. justify-content: center;
  68. align-items: center;">
  69. <!-- class="position-absolute-center" -->
  70. <canvas canvas-id="effectHitCanvas" :style="{ width: canvasW + 'px', height: '164px' }"></canvas>
  71. </view>
  72. <view class="flex align-center justify-center" style="font-size: 14px; width:750rpx;">
  73. <view style="position: relative;">
  74. <image style="width: 135px;height: 75px;" src="../../../static/modal/action-jump/Fill.png"></image>
  75. <view class="mid-absolute flex flex-direction align-center justify-center text-white">
  76. <view class="flex align-center">
  77. <image style="width: 22rpx;height: 28rpx;"
  78. src="../../../static/modal/action-jump/jumpSpeed.png"></image>
  79. <view style="margin-left: 6rpx;">平均速度</view>
  80. </view>
  81. <view style="margin-top: 12rpx;">{{averageSpeed}}</view>
  82. </view>
  83. </view>
  84. <view id="ActionJumpPlay" class="flex" style="position: relative;" @click="onControllerPlay">
  85. <image style="width: 110px;height: 110px;"
  86. src="../../../static/modal/action-jump/mid-button-orange@2x.png">
  87. </image>
  88. <image v-if="!bJumpPlay" class="mid-absolute" style="left:12rpx; width: 56rpx;height: 70rpx;"
  89. src="../../../static/play.png">
  90. </image>
  91. <image v-else class="mid-absolute" style="width: 100rpx;height: 100rpx;"
  92. src="../../../static/e-pause.png">
  93. </image>
  94. </view>
  95. <view style="position: relative;">
  96. <image style="width: 135px;height: 75px; transform: scaleX(-1);"
  97. src="../../../static/modal/action-jump/Fill.png"></image>
  98. <view class="mid-absolute flex flex-direction align-center justify-center text-white">
  99. <view class="flex align-center">
  100. <image style="width: 22rpx;height: 28rpx;"
  101. src="../../../static/modal/action-jump/jumpCalorie.png"></image>
  102. <view style="margin-left: 6rpx;">卡路里</view>
  103. </view>
  104. <view style="margin-top: 12rpx;">{{Math.floor(jumpCalorie)}}</view>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="flex align-center justify-center" style="width: 750rpx;margin-top: 16rpx;">
  109. <view class="flex justify-center align-center" style="height: 120rpx; width: 444rpx; ">
  110. <view class="text-12px text-white text-center">
  111. {{taskDescribe}}
  112. </view>
  113. </view>
  114. </view>
  115. <!-- #ifdef H5 -->
  116. <view style="display: flex;justify-content: space-between;" class="margin-top margin-bottom">
  117. <button @click="onJumpType(0)">middle</button>
  118. <button @click="onJumpType(1)">left</button>
  119. <button @click="onJumpType(2)">right</button>
  120. </view>
  121. <!-- #endif -->
  122. </view>
  123. </template>
  124. <script>
  125. import {
  126. CONDITIONPASSED
  127. } from "@/util/util-js/enum.js"
  128. import Firework from "@/util/util-js/effect/firework.js"
  129. import Animation from "@/util/util-js/Animation.js"
  130. import puchConfig from "@/util/util-js/puchConfig.js"
  131. import {
  132. mapState,
  133. mapMutations
  134. } from 'vuex';
  135. export default {
  136. computed: mapState(['systemInfo', 'bOldDeviceType']),
  137. components: {
  138. },
  139. props: {
  140. showTime: {
  141. type: Number,
  142. default: 0
  143. },
  144. levelData: {
  145. type: Object,
  146. default: null
  147. },
  148. currentMode: {
  149. type: String,
  150. default: ''
  151. }
  152. },
  153. data() {
  154. return {
  155. isY: true,
  156. canvasW: 0, // 画布宽
  157. canvasH: 0, // 画布高
  158. // SystemInfo: {}, // 设备信息
  159. directionJumpRight: null,
  160. directionJumpLeft: null,
  161. midJump: null,
  162. rotateJumpRight: null,
  163. rotateJumpLeft: null,
  164. directionJumpWhiteRight: null,
  165. directionJumpWhiteLeft: null,
  166. midJumpWhite: null,
  167. rotateJumpWhiteRight: null,
  168. rotateJumpWhiteLeft: null,
  169. //参考图片
  170. cankao: null,
  171. jumpTipImage: null,
  172. JumpTipOrange: null,
  173. jumpNormalLine: null,
  174. jumpNormalRect: null,
  175. jumpNormalWidth: 70,
  176. jumpNormalHeight: 164,
  177. jumpProgressTip: null,
  178. jumpTypeArray: [{
  179. jumpName: 'NORMAL',
  180. jumpCode: 0,
  181. icon: 'midJump',
  182. scaleX: 1,
  183. bTrigger: false,
  184. bShow: true,
  185. }, {
  186. jumpName: 'LEFT',
  187. jumpCode: 1,
  188. icon: 'directionJump',
  189. scaleX: 1,
  190. bTrigger: false,
  191. bShow: true,
  192. }, {
  193. jumpName: 'RIGHT',
  194. jumpCode: 2,
  195. icon: 'directionJump',
  196. scaleX: 1,
  197. bTrigger: false,
  198. bShow: true,
  199. }],
  200. spawnArray: [],
  201. deleteSpawn: null, //已删除的对象
  202. deleteImage: null,
  203. /**
  204. * 生成的背景位置
  205. */
  206. spawnPos: [],
  207. spawnAnimation: null,
  208. spawnProcess: 1,
  209. //下一个生成是相反的方向
  210. bNextSpawnRightDirection: false,
  211. bNextSpawnRightRotateDirection: false,
  212. //生成预制的模板,用count 来判断生成哪一种
  213. template: [{ //原地
  214. count: 1,
  215. spawnList: [
  216. [0]
  217. ]
  218. }, {
  219. count: 2,
  220. spawnList: [
  221. [2, 1],
  222. [1, 2],
  223. [3, 4],
  224. [4, 3]
  225. ]
  226. }, {
  227. count: 3,
  228. spawnList: [
  229. [2, 0, 1],
  230. [1, 0, 2],
  231. [3, 0, 4],
  232. [4, 0, 3]
  233. ]
  234. }, ],
  235. //模板对象池,管理生成对象
  236. templatePool: [],
  237. levelType: 0,
  238. countdown: 60,
  239. countdownInterval: null,
  240. faultCount: 0,
  241. eliminationCount: 0,
  242. bJumpPlay: false,
  243. jumpCalorie: 0,
  244. averageSpeedInterval: null,
  245. averageSpeed: 0,
  246. tempHitCount: 0,
  247. //硬件设备处理
  248. BLEAccIndex: 0,
  249. xA: 0,
  250. yA: 0,
  251. zA: 0,
  252. /**
  253. * 交互数据处理
  254. */
  255. //当前选择的关卡信息
  256. selfLevelData: null,
  257. // 双人模式下 数据
  258. //标记块数量
  259. taskSignCount: 0, //总数
  260. taskSignCurCount: 0, //当前计数
  261. //{"type":1,"explain":"规定时间内跳完所有标志块","limitType":1}
  262. taskConditionPassed: null,
  263. taskDescribe: '',
  264. //满格的数值是 25
  265. maxShowCount: 13,
  266. addShowCountUnit: 0,
  267. showCurCount: 0,
  268. roundingCount: 0,
  269. //游戏结束
  270. isGameOver: false,
  271. //pk模式下操作
  272. leftShowCurCount: 0,
  273. rightShowCurCount: 0,
  274. isleftPlayer: true,
  275. /**
  276. * 是否允许绘制
  277. */
  278. canOnDraw: false,
  279. /**
  280. * 是否去到下一个关卡
  281. */
  282. canGoNext: false,
  283. /**
  284. * 生成的特效
  285. */
  286. canSpawnTemp: null,
  287. onLogData: '',
  288. /**
  289. * 是否显示关卡提示
  290. */
  291. bTipLevel: false,
  292. /**
  293. * 烟花相关
  294. */
  295. // firework collection
  296. fireworks: [],
  297. fireworkImage: null,
  298. loop: null,
  299. count: 100,
  300. effectHitCanvas: null,
  301. effectCurrentSpawn: null,
  302. effectSpawnPosX: 0,
  303. /**
  304. * 烟花特效
  305. */
  306. bDrawBoomEffect: false,
  307. //绘制箭头效果
  308. bRuning: false,
  309. bRuningInfinite: false,
  310. yellowRuningTimeout: null,
  311. //音效
  312. leftHookUrl: "/static/modal/boxing-post/left-hook.mp3",
  313. rightHookUrl: "/static/modal/boxing-post/right-hook.mp3",
  314. straightHookUrl: "/static/modal/boxing-post/straight-hook.mp3",
  315. hookAudioContext: null,
  316. }
  317. },
  318. watch: {
  319. levelData(val) {
  320. //更新数据
  321. // console.log("levelData ============>"+JSON.stringify(val));
  322. if (val) {
  323. this.taskSignCount = val.signCount;
  324. this.taskConditionPassed = val.conditionPassed;
  325. this.taskDescribe = val.describe;
  326. this.addShowCountUnit = (this.maxShowCount * 2) / this.taskSignCount;
  327. // console.log("this.addShowCountUnit:", this.addShowCountUnit, this.maxShowCount * 2, this
  328. // .taskSignCount);
  329. this.showCount = 0;
  330. //用signType 做等级类型
  331. this.levelType = val.signType;
  332. console.log(JSON.stringify(this.taskConditionPassed));
  333. }
  334. },
  335. currentMode(val) {
  336. // console.log('==========> action jump currentMode:', val);
  337. }
  338. },
  339. created() {
  340. let _self = this;
  341. //初始化一个音效
  342. _self.hookAudioContext = uni.createInnerAudioContext();
  343. _self.hookAudioContext.autoplay = false;
  344. _self.hookAudioContext.src = _self.straightHookUrl;
  345. _self.hookAudioContext.volume = 0.5;
  346. this.actionHitCanvas = uni.createCanvasContext("actionHitCanvas", this);
  347. this.effectHitCanvas = uni.createCanvasContext("effectHitCanvas", this);
  348. // this.SystemInfo = this.systemInfo; // uni.getSystemInfoSync();
  349. this.canvasW = this.systemInfo.windowWidth; // 画布宽度
  350. this.canvasH = 147.68;
  351. this.onLoadImage();
  352. //更新一次状态
  353. const value = uni.getStorageSync('levelButtonPrompt');
  354. if (value) {
  355. _self.bTipLevel = !value.isSelected;
  356. } else {
  357. _self.bTipLevel = true;
  358. }
  359. if (this.averageSpeedInterval) {
  360. clearInterval(this.averageSpeedInterval);
  361. this.averageSpeedInterval = null;
  362. }
  363. //计算平均速度
  364. this.averageSpeedInterval = setInterval(() => {
  365. this.averageSpeed = this.tempHitCount;
  366. this.tempHitCount = 0;
  367. }, 3000)
  368. console.log("组件创建")
  369. },
  370. beforeDestroy() {
  371. if (_self.hookAudioContext)
  372. _self.hookAudioContext.destroy();
  373. },
  374. methods: {
  375. ...mapMutations(['onWriteBLEConnectionValue', 'onConvertDeviceData']),
  376. //更新新手状态提示
  377. onUpdateTipLevelValue(value) {
  378. this.bTipLevel = value;
  379. },
  380. //load 相关图片
  381. onLoadImage() {
  382. let _self = this;
  383. uni.getImageInfo({
  384. src: "../../../static/modal/boxing-post/left-hook-m@2x.png",
  385. success: function(image) {
  386. _self.directionJumpLeft = image;
  387. }
  388. });
  389. uni.getImageInfo({
  390. src: "../../../static/modal/boxing-post/right-hook-m@2x.png",
  391. success: function(image) {
  392. _self.directionJumpRight = image;
  393. }
  394. });
  395. uni.getImageInfo({
  396. src: "../../../static/modal/boxing-post/straight-m@2x.png",
  397. success: function(image) {
  398. _self.midJump = image;
  399. }
  400. });
  401. uni.getImageInfo({
  402. src: "../../../static/modal/boxing-post/right-hook-h@2x.png",
  403. success: function(image) {
  404. _self.directionJumpWhiteRight = image;
  405. }
  406. });
  407. uni.getImageInfo({
  408. src: "../../../static/modal/boxing-post/left-hook-h@2x.png",
  409. success: function(image) {
  410. _self.directionJumpWhiteLeft = image;
  411. }
  412. });
  413. uni.getImageInfo({
  414. src: "../../../static/modal/boxing-post/straight-h@2x.png",
  415. success: function(image) {
  416. _self.midJumpWhite = image;
  417. }
  418. });
  419. uni.getImageInfo({
  420. src: "../../../static/modal/action-jump/jumpTip.png",
  421. success: function(image) {
  422. _self.jumpTipImage = image;
  423. }
  424. });
  425. uni.getImageInfo({
  426. src: "../../../static/modal/action-jump/jump-tip-orange@2x.png",
  427. success: function(image) {
  428. _self.JumpTipOrange = image;
  429. }
  430. })
  431. uni.getImageInfo({
  432. src: "../../../static/modal/action-jump/progress-tip.png",
  433. success: function(image) {
  434. _self.jumpProgressTip = image;
  435. }
  436. })
  437. uni.getImageInfo({
  438. src: "../../../static/modal/action-jump/jumpNormal-line.png",
  439. success: function(image) {
  440. _self.jumpNormalLine = image;
  441. }
  442. });
  443. uni.getImageInfo({
  444. src: "../../../static/modal/action-jump/jumpNormal-rect.png",
  445. success: function(image) {
  446. _self.jumpNormalRect = image;
  447. _self.onDrawBg(true);
  448. }
  449. });
  450. uni.getImageInfo({
  451. src: "../../../static/modal/action-jump/cankao.png",
  452. success: function(image) {
  453. _self.cankao = image;
  454. }
  455. });
  456. /**
  457. * 烟花照片
  458. */
  459. uni.getImageInfo({
  460. src: "../../../static/modal/action-jump/boom.png",
  461. success: function(image) {
  462. _self.fireworkImage = image;
  463. }
  464. });
  465. },
  466. /**
  467. * 重置生成数组,重置倒计时
  468. */
  469. resetJumpGame() {
  470. this.spawnArray = [];
  471. this.templatePool = [];
  472. if (this.countdownInterval) {
  473. clearInterval(this.countdownInterval);
  474. this.countdownInterval = null;
  475. }
  476. // this.resetCountdown(60);
  477. },
  478. startJumpGame() {
  479. this.isGameOver = false;
  480. this.resetJumpGame();
  481. //开始游戏
  482. this.index = 0;
  483. // this.levelType = 5;
  484. let spawnCount = 7;
  485. let _ranType = Math.floor(Math.random() * 2);
  486. //生成二个占位
  487. this.addTemplatePoolFromType(false, this.template[0].spawnList[0][0]);
  488. this.addTemplatePoolFromType(false, this.template[0].spawnList[0][0]);
  489. if (this.levelType == 0) {
  490. //随便生成一组跳的数据
  491. let _spawnList = this.template[0].spawnList;
  492. for (let i = 0; i < 30; i++) {
  493. //再对象池里面生成一组对象
  494. this.addTemplatePoolFromType(true, _spawnList[0][0]);
  495. }
  496. //先生成spawnCount个
  497. for (let i = 0; i < spawnCount; i++) {
  498. this.spawnArray.push(this.templatePool[this.index]);
  499. this.index++;
  500. }
  501. } else if (this.levelType == 1) {
  502. //生成一组 左跳右跳
  503. let _spawnList = this.template[1].spawnList;
  504. for (let i = 0; i < 30; i++) {
  505. let ran = Math.floor(Math.random() * 2);
  506. for (let j = 0; j < _spawnList[ran].length; j++) {
  507. //再对象池里面生成一组对象
  508. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  509. }
  510. }
  511. //先生成spawnCount个
  512. for (let i = 0; i < spawnCount; i++) {
  513. this.spawnArray.push(this.templatePool[this.index]);
  514. this.index++;
  515. }
  516. console.log(this.spawnArray)
  517. } else if (this.levelType == 2) {
  518. //生成一组 左跳右跳原地
  519. let _spawnList = this.template[2].spawnList;
  520. for (let i = 0; i < 30; i++) {
  521. let ran = Math.floor(Math.random() * 2);
  522. for (let j = 0; j < _spawnList[ran].length; j++) {
  523. //再对象池里面生成一组对象
  524. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  525. }
  526. }
  527. //先生成spawnCount个
  528. for (let i = 0; i < spawnCount; i++) {
  529. this.spawnArray.push(this.templatePool[this.index]);
  530. this.index++;
  531. }
  532. } else if (this.levelType == 3) {
  533. //生成一组 左旋跳右旋跳
  534. let _spawnList = this.template[1].spawnList;
  535. for (let i = 0; i < 30; i++) {
  536. let ran = Math.floor(Math.random() * 2) + 2;
  537. for (let j = 0; j < _spawnList[ran].length; j++) {
  538. //再对象池里面生成一组对象
  539. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  540. }
  541. }
  542. //先生成spawnCount个
  543. for (let i = 0; i < spawnCount; i++) {
  544. this.spawnArray.push(this.templatePool[this.index]);
  545. this.index++;
  546. }
  547. } else if (this.levelType == 4) {
  548. //生成一组 左旋跳右旋跳
  549. let _spawnList = this.template[2].spawnList;
  550. for (let i = 0; i < 30; i++) {
  551. let ran = Math.floor(Math.random() * 2) + 2;
  552. for (let j = 0; j < _spawnList[ran].length; j++) {
  553. //再对象池里面生成一组对象
  554. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  555. }
  556. }
  557. //先生成spawnCount个
  558. for (let i = 0; i < spawnCount; i++) {
  559. this.spawnArray.push(this.templatePool[this.index]);
  560. this.index++;
  561. }
  562. } else if (this.levelType == 5) {
  563. for (let i = 0; i < 20; i++) {
  564. //随便生成三组数据
  565. let _newArray = [];
  566. let _spawnList2 = this.template[2].spawnList;
  567. let ran2 = Math.floor(Math.random() * 2);
  568. let ran3 = Math.floor(Math.random() * 2);
  569. if (_ranType >= 1) {
  570. ran2 += 2;
  571. ran3 += 2;
  572. }
  573. _newArray = _newArray.concat(_spawnList2[ran2]);
  574. _newArray = _newArray.concat(_spawnList2[ran3]);
  575. for (let j = 0; j < _newArray.length; j++) {
  576. this.addTemplatePoolFromType(true, _newArray[j]);
  577. }
  578. }
  579. //先生成spawnCount个
  580. for (let i = 0; i < spawnCount; i++) {
  581. this.spawnArray.push(this.templatePool[this.index]);
  582. this.index++;
  583. }
  584. }
  585. this.onDraw("tipHit", false);
  586. },
  587. /**
  588. * 生成对应预制对象
  589. * @param {Object} bShow
  590. * @param {Object} _jumpType
  591. */
  592. addTemplatePoolFromType(bShow, _jumpType) {
  593. for (let i = 0; i < this.jumpTypeArray.length; i++) {
  594. if (this.jumpTypeArray[i].jumpCode == _jumpType) {
  595. let _jumpPrefab = Object.assign({}, this.jumpTypeArray[i], {
  596. bShow: bShow,
  597. bInit: true,
  598. position: 0,
  599. animation: null, //动画
  600. });
  601. this.templatePool.push(_jumpPrefab);
  602. break;
  603. }
  604. }
  605. },
  606. //单纯的绘制八个背景
  607. onDrawBg(bDraw) {
  608. this.spawnPos = [];
  609. if (bDraw) {
  610. this.actionHitCanvas.clearRect(0, 0, this.canvasW, this.canvasH);
  611. }
  612. let _currentBgStartX = this.canvasW / 2;
  613. let count = 7;
  614. let _currentPos = -12,
  615. _addPos = 0;
  616. for (let i = 0; i < count; i++) {
  617. if (0 !== i) {
  618. _currentPos += this.jumpNormalWidth;
  619. } else {
  620. _currentPos -= this.jumpNormalWidth;
  621. }
  622. if (2 === i) {
  623. //结尾时候快消除完绘制一次大图背景。不然会为空白
  624. if (this.spawnArray.length < 3)
  625. this.actionHitCanvas.drawImage(this.jumpTipImage.path, _currentPos, 0, 120, this
  626. .canvasH);
  627. if (bDraw) {
  628. this.actionHitCanvas.drawImage(this.JumpTipOrange.path, _currentPos + 3, 7, 113, this
  629. .canvasH -
  630. 14);
  631. }
  632. //添加对应生成点
  633. this.spawnPos.push({
  634. center: _currentPos + 30
  635. })
  636. _currentPos += 50;
  637. } else {
  638. this.actionHitCanvas.drawImage(this.jumpNormalLine.path, _currentPos, 0, this
  639. .jumpNormalWidth,
  640. this.canvasH);
  641. if (bDraw) {
  642. this.actionHitCanvas.drawImage(this.jumpNormalRect.path, _currentPos, 0, this
  643. .jumpNormalWidth,
  644. this.canvasH);
  645. }
  646. //添加对应生成点
  647. this.spawnPos.push({
  648. center: _currentPos + 16
  649. })
  650. }
  651. }
  652. if (bDraw) {
  653. this.actionHitCanvas.draw();
  654. }
  655. },
  656. onDraw(type, bAnimation) {
  657. // console.log(type + "="+ bAnimation);
  658. let _self = this;
  659. //控制大图标区域音乐播放,发出一次提示音
  660. let bPlayAudio = true;
  661. if(type = 'tipHit' && _self.spawnAnimation == null){
  662. bPlayAudio = false;
  663. }
  664. if (bAnimation && _self.spawnAnimation == null) {
  665. _self.spawnProcess = 0;
  666. _self.spawnAnimation = new Animation({
  667. timing: 'linear',
  668. duration: 200,
  669. onProcess: function onProcess(process) {
  670. _self.spawnProcess = process;
  671. _self.onDraw('normal', true);
  672. // console.log("process=" + process);
  673. },
  674. onAnimationFinish: function onAnimationFinish() {
  675. // console.log("finish animation");
  676. _self.spawnAnimation = null;
  677. }
  678. })
  679. }
  680. this.actionHitCanvas.clearRect(0, 0, this.canvasW, this.canvasH);
  681. //单纯绘制背景
  682. this.onDrawBg(false);
  683. //计算一个节点数组
  684. // let _oldRectMoveDis = 1;
  685. for (let i = 0; i < this.spawnArray.length; i++) {
  686. //默认 mid 图标
  687. let _temp = this.spawnArray[i].bTrigger ? this.midJump : this.midJumpWhite;
  688. if (this.spawnArray[i].icon == 'directionJump') {
  689. if (this.spawnArray[i].jumpName == "RIGHT") {
  690. _temp = this.spawnArray[i].bTrigger ? this.directionJumpRight : this
  691. .directionJumpWhiteRight;
  692. } else {
  693. _temp = this.spawnArray[i].bTrigger ? this.directionJumpLeft : this
  694. .directionJumpWhiteLeft;
  695. }
  696. }
  697. this.actionHitCanvas.save();
  698. let _currentPos = this.spawnPos[i].center;
  699. let _currentCenterPos = 0;
  700. if (2 === i) {
  701. if(!bPlayAudio){
  702. console.log("play video2 = "+i);
  703. bPlayAudio = true;
  704. //声音播放
  705. if (this.spawnArray[i].jumpName == "RIGHT") {
  706. this.hookAudioContext.stop();
  707. this.hookAudioContext.src = this.rightHookUrl;
  708. this.hookAudioContext.play();
  709. } else if(this.spawnArray[i].jumpName == "LEFT") {
  710. this.hookAudioContext.stop();
  711. this.hookAudioContext.src = this.leftHookUrl;
  712. this.hookAudioContext.play();
  713. } else{
  714. this.hookAudioContext.stop();
  715. this.hookAudioContext.src = this.straightHookUrl;
  716. this.hookAudioContext.play();
  717. }
  718. }
  719. //这里分两部分走,从小图走到大图
  720. let _spawnBiggerToLeft = this.spawnArray[i];
  721. //这里记录一个生成点,后面用于生成特效
  722. this.effectSpawnPosX = _currentPos;
  723. //大图
  724. let tempPosition = _currentPos;
  725. if (!bAnimation || _spawnBiggerToLeft.bInit) {
  726. _spawnBiggerToLeft.position = _currentPos;
  727. _spawnBiggerToLeft.bInit = false;
  728. } else {
  729. tempPosition = _spawnBiggerToLeft.position - Math.abs(_currentPos - _spawnBiggerToLeft
  730. .position) * _self.spawnProcess;
  731. }
  732. if (1 === this.spawnProcess) {
  733. _spawnBiggerToLeft.position = tempPosition;
  734. } else {
  735. //绘制一次前面方块背景前移
  736. this.actionHitCanvas.drawImage(this.jumpNormalRect.path, tempPosition - 16, 0, this
  737. .jumpNormalWidth,
  738. this.canvasH);
  739. this.actionHitCanvas.clearRect(this.spawnPos[i].center - 30, 0, 120, this.canvasH);
  740. }
  741. let _width = 40 + 20 * _self.spawnProcess;
  742. this.actionHitCanvas.drawImage(_temp.path, tempPosition, 55 - 9 * _self.spawnProcess,
  743. _width,
  744. _width);
  745. //绘制多一次背景
  746. this.actionHitCanvas.drawImage(this.jumpTipImage.path, this.spawnPos[i].center - 30, 0,
  747. 120, this
  748. .canvasH);
  749. this.actionHitCanvas.drawImage(this.JumpTipOrange.path, this.spawnPos[i].center - 27, 7,
  750. 113, this
  751. .canvasH -
  752. 14);
  753. } else {
  754. //小图
  755. let _otherObj = this.spawnArray[i];
  756. let tempPosition = _currentPos;
  757. if (!bAnimation || _otherObj.bInit) {
  758. _otherObj.position = _currentPos;
  759. _otherObj.bInit = false;
  760. } else {
  761. tempPosition = _otherObj.position - Math.abs(_currentPos - _otherObj.position) * _self
  762. .spawnProcess;
  763. }
  764. if (1 === this.spawnProcess) {
  765. _otherObj.position = tempPosition;
  766. }
  767. this.actionHitCanvas.drawImage(this.jumpNormalRect.path, tempPosition - 16, 0, this
  768. .jumpNormalWidth,
  769. this.canvasH);
  770. if (this.spawnArray[i].bShow) {
  771. this.actionHitCanvas.drawImage(_temp.path, tempPosition, 55, 40, 40);
  772. }
  773. }
  774. this.actionHitCanvas.restore();
  775. }
  776. this.actionHitCanvas.draw();
  777. },
  778. /**
  779. * 消除时候显示的特效
  780. * @param {Object} _temp
  781. */
  782. onDrawEffect(_temp) {
  783. if (!this.bRuning) {
  784. this.bRuning = true;
  785. if (this.yellowRuningTimeout) {
  786. clearTimeout(this.yellowRuningTimeout)
  787. this.yellowRuningTimeout = null;
  788. }
  789. this.yellowRuningTimeout = setTimeout(() => {
  790. this.bRuning = false;
  791. }, 1000)
  792. }
  793. //根据当前消除的生成一个
  794. let spawnTemp = this.midJump;
  795. let offest = 5;
  796. if (_temp.icon == 'directionJump') {
  797. spawnTemp = _temp.jumpName == "RIGHT" ? this.directionJumpRight : this.directionJumpLeft;
  798. }
  799. let tempFirework = new Firework(this.fireworkImage,
  800. spawnTemp, _temp.scaleX, this.effectSpawnPosX, 0, this.canvasW, 164, offest, true);
  801. this.fireworks.push(tempFirework);
  802. this.bDrawBoomEffect = true;
  803. this.onInitFirework();
  804. },
  805. onClear() {
  806. this.resetJumpGame();
  807. this.onDrawBg(true);
  808. this.xA = 0;
  809. this.yA = 0;
  810. this.zA = 0;
  811. },
  812. /**
  813. * 统一绘制 效果 背景,交互,烟花
  814. */
  815. onInitFirework() {
  816. if (this.loop != null) {
  817. return;
  818. }
  819. this.loop = setInterval(() => {
  820. if (!this.bDrawBoomEffect) {
  821. clearInterval(this.loop);
  822. this.loop = null;
  823. // console.log("结束绘制");
  824. this.effectHitCanvas.clearRect(0, 0, this.canvasW, 164);
  825. this.effectHitCanvas.draw();
  826. return;
  827. }
  828. this.effectHitCanvas.clearRect(0, 0, this.canvasW, 164);
  829. if (this.bDrawBoomEffect) {
  830. // loop over each firework, draw it, update it
  831. var i = this.fireworks.length;
  832. while (i--) {
  833. this.fireworks[i].draw(this.effectHitCanvas, () => {
  834. this.fireworks.splice(i, 1);
  835. if (this.fireworks.length == 0) {
  836. this.bDrawBoomEffect = false;
  837. }
  838. });
  839. }
  840. }
  841. this.effectHitCanvas.draw();
  842. }, 30)
  843. },
  844. onJumpType(event) {
  845. // console.log("onJumpType:", event);
  846. if (this.isGameOver || !this.bJumpPlay) return;
  847. this.eliminateJumpPrefab(event);
  848. },
  849. // update (dt) {}
  850. //模拟测试调用
  851. eliminateJumpPrefab(_jumpType) {
  852. //只触发第二个
  853. if (this.spawnArray.length < 3 || this.spawnAnimation != null) {
  854. return;
  855. }
  856. let _temp = this.spawnArray[2];
  857. //如果当前的跳类型和预制目标一样
  858. if (_jumpType == _temp.jumpCode) {
  859. _temp.bTrigger = true;
  860. this.deleteSpawn = this.spawnArray.splice(0, 1);
  861. if (this.index < this.templatePool.length) {
  862. this.spawnArray.push(this.templatePool[this.index]);
  863. this.index++;
  864. }
  865. //这里更新特效
  866. let _endTemp = Object.assign({}, _temp);
  867. this.onDrawEffect(_endTemp);
  868. //绘制新触发状态
  869. this.onDraw('tipHit', true);
  870. //成功
  871. this.setEliminationCount(1);
  872. //替换数组
  873. // console.log(this.index + " == " + this.spawnArray.length);
  874. if (this.spawnArray.length < 3 && this.index > 3) {
  875. clearInterval(this.countdownInterval);
  876. this.countdownInterval = null;
  877. //绘制新触发状态
  878. this.onDraw("normal", false);
  879. setTimeout(() => {
  880. this.startJumpGame();
  881. }, 2000)
  882. }
  883. } else {
  884. //失误
  885. this.setFaultCount(1);
  886. }
  887. },
  888. //设置倒计时
  889. setCountdown(value) {
  890. this.countdown -= value;
  891. // this.countdownLabel.string = '倒计时:' + this.countdown;
  892. this.$emit('actionJumpCountDownUpdate', {
  893. countDown: this.countdown
  894. });
  895. },
  896. resetCountdown(value) {
  897. this.countdown = value;
  898. // this.countdownLabel.string = '倒计时:' + this.countdown;
  899. this.$emit('actionJumpCountDownUpdate', {
  900. countDown: this.countdown
  901. });
  902. },
  903. //设置ui信息
  904. setEliminationCount(value) {
  905. this.tempHitCount++;
  906. this.taskSignCurCount++;
  907. this.roundingCount += this.addShowCountUnit;
  908. this.eliminationCount += value;
  909. // this.eliminationLabel.string = '消除数量:' + this.eliminationCount.toString();
  910. this.$emit('actionJumpDataUpdate', {
  911. eliminationCount: this.eliminationCount,
  912. faultCount: this.faultCount
  913. });
  914. this.jumpCalorie += puchConfig.getJumpCalorie(this.eliminationCount + this.faultCount);
  915. //如果是pk模式。不走下面判断
  916. if (this.currentMode == 'pkMode') return;
  917. if (CONDITIONPASSED.ENERGYBARFULL == this.taskConditionPassed.limitType) {
  918. //能量条的条件下才显示能量条动
  919. //取两位后计算Math floor,不然会有偏差值问题 Math.floor(39.9999999+ 0.1111111) = 39
  920. this.showCurCount = Math.floor(this.roundingCount.toFixed(2));
  921. //1.能量槽满的时候,说明踩中次数到达
  922. if (this.taskSignCurCount >= this.taskSignCount)
  923. this.onGameOver("energyBarFull");
  924. } else if (CONDITIONPASSED.SKIPALLFLAGWITHINTIME == this.taskConditionPassed.limitType) {
  925. //规定时间下也给显示能量条
  926. this.showCurCount = Math.floor(this.roundingCount.toFixed(2));
  927. //2.规定时间内跳完所有标志块
  928. if (this.taskSignCurCount >= this.taskSignCount)
  929. this.onGameOver("skipAllFlagWithinTime");
  930. } else if (this.taskConditionPassed.isScore) {
  931. //3.达到一定分数
  932. //如果是用分数判断
  933. //分数是 跳对的加1分,错的扣1分,0不扣分。
  934. let curScore = this.eliminationCount - this.faultCount;
  935. curScore = curScore < 0 ? 0 : curScore;
  936. //当前分数达到,胜利
  937. if (curScore >= this.taskConditionPassed.limitScore)
  938. this.onGameOver("score");
  939. }
  940. },
  941. onGameOver(type) {
  942. this.isGameOver = true;
  943. //处理参数
  944. this.onClear();
  945. this.onClearData();
  946. this.bJumpPlay = false;
  947. /**
  948. * 判断胜利和失败
  949. */
  950. let myWin = false; //默认失败
  951. //比如, 1.充满左右两边蓄能槽.2.规定时间内跳完所有标志块.
  952. if (type == "energyBarFull") {
  953. //1.能量槽满的时候,说明踩中次数到达
  954. if (this.taskSignCurCount >= this.taskSignCount) {
  955. myWin = true;
  956. }
  957. } else if (type == 'skipAllFlagWithinTime') {
  958. myWin = true;
  959. } else if (type == "timeUp") {
  960. //2.规定时间内跳完所有标志块
  961. //查看消除数量是否到达总数,未达成就是未完成
  962. if (this.taskSignCurCount >= this.taskSignCount) {
  963. myWin = true;
  964. }
  965. } else if (type == "score") {
  966. myWin = true;
  967. }
  968. console.log(type, {
  969. myWin: myWin
  970. });
  971. this.$emit('gameOver', {
  972. myWin: myWin,
  973. type: 'calorieMode',
  974. isOffEvent: true
  975. });
  976. },
  977. //pk模式下结束游戏关卡
  978. onPKModeGameOver(type) {
  979. this.isGameOver = true;
  980. //处理参数
  981. this.onClear();
  982. this.onClearData();
  983. this.bJumpPlay = false;
  984. this.$emit('gameOver', {
  985. type: 'pkMode',
  986. isOffEvent: true
  987. });
  988. },
  989. setFaultCount(value) {
  990. this.tempHitCount++;
  991. this.faultCount += value;
  992. // this.faultLabel.string = '失误:' + this.faultCount;
  993. this.$emit('actionJumpDataUpdate', {
  994. eliminationCount: this.eliminationCount,
  995. faultCount: this.faultCount
  996. });
  997. this.jumpCalorie += puchConfig.getJumpCalorie(this.eliminationCount + this.faultCount);
  998. },
  999. //控制播放
  1000. onControllerPlay() {
  1001. if (this.bJumpPlay) {
  1002. //仅仅暂停,没有清空数据
  1003. this._changePlay(false);
  1004. this.$emit("actionJumpControllerPlay", false);
  1005. } else {
  1006. this.$emit("actionJumpCheck");
  1007. }
  1008. },
  1009. onContinueGame() {
  1010. this._changePlay(true);
  1011. },
  1012. onClearActionJumpData() {
  1013. console.log("onClearActionJumpData");
  1014. this.onClear();
  1015. this.onClearData();
  1016. },
  1017. //修改状态
  1018. _changePlay(bPlaying) {
  1019. if (bPlaying) {
  1020. this.bJumpPlay = bPlaying;
  1021. } else {
  1022. this.bJumpPlay = !this.bJumpPlay;
  1023. }
  1024. },
  1025. onActionPlay() {
  1026. this.onClear();
  1027. this.onClearData();
  1028. this.startJumpGame();
  1029. this._changePlay(true);
  1030. //reset 对应计算数据
  1031. this.taskSignCurCount = 0;
  1032. this.showCurCount = 0;
  1033. this.roundingCount = 0;
  1034. this.faultCount = 0;
  1035. this.eliminationCount = 0;
  1036. },
  1037. /**
  1038. * 停止并清空数据
  1039. */
  1040. onStopAndClearAction() {
  1041. this.onClear();
  1042. this.onClearData();
  1043. this.bJumpPlay = false;
  1044. //reset 对应计算数据
  1045. this.taskSignCurCount = 0;
  1046. this.showCurCount = 0;
  1047. this.roundingCount = 0;
  1048. this.faultCount = 0;
  1049. this.eliminationCount = 0;
  1050. this.jumpCalorie = 0;
  1051. },
  1052. getCurrentJumpType() {
  1053. let _temp = this.spawnArray[2];
  1054. return _temp.jumpCode;
  1055. },
  1056. //监听跳的状态数据
  1057. listenStateDataOfJump(data) {
  1058. if (this.spawnArray.length < 3) return;
  1059. let _jumpType = this.getCurrentJumpType();
  1060. //初始全部默认状态
  1061. let _tempState = [{
  1062. jumpName: 'NORMAL',
  1063. jumpCode: 0,
  1064. bTrigger: false,
  1065. describe: '正常跳'
  1066. },
  1067. {
  1068. jumpName: 'LEFT',
  1069. jumpCode: 1,
  1070. bTrigger: false,
  1071. describe: '左直跳'
  1072. },
  1073. {
  1074. jumpName: 'RIGHT',
  1075. jumpCode: 2,
  1076. bTrigger: false,
  1077. describe: '右直跳'
  1078. },
  1079. {
  1080. jumpName: 'LEFT_ROTATE',
  1081. jumpCode: 3,
  1082. bTrigger: false,
  1083. describe: '左旋转跳'
  1084. },
  1085. {
  1086. jumpName: 'RIGHT_ROTATE',
  1087. jumpCode: 4,
  1088. bTrigger: false,
  1089. describe: '右旋转跳'
  1090. }
  1091. ];
  1092. let {
  1093. currentMaxValue,
  1094. oGyroValue,
  1095. peakOfWaveMaxValue,
  1096. valleyOfWaveMinValue
  1097. } = data
  1098. // console.log('stateDataOfJump:');
  1099. // console.log(JSON.stringify(data));
  1100. this.onLogData = data;
  1101. let _rotateLimit = 4;
  1102. let _jumpLimit = 0;
  1103. switch (_jumpType) {
  1104. case 0:
  1105. //JumpType.NORMAL = 0
  1106. _tempState[0].bTrigger = true;
  1107. this.eliminateJumpPrefabFormTemp(_tempState);
  1108. break;
  1109. case 1:
  1110. if (currentMaxValue < -_jumpLimit) {
  1111. //left jump
  1112. _tempState[1].bTrigger = true;
  1113. }
  1114. this.eliminateJumpPrefabFormTemp(_tempState);
  1115. break;
  1116. case 2:
  1117. if (currentMaxValue > _jumpLimit) {
  1118. //right jump
  1119. _tempState[2].bTrigger = true;
  1120. }
  1121. this.eliminateJumpPrefabFormTemp(_tempState);
  1122. break;
  1123. case 4:
  1124. if (oGyroValue > _rotateLimit) {
  1125. _tempState[4].bTrigger = true;
  1126. }
  1127. this.eliminateJumpPrefabFormTemp(_tempState);
  1128. break;
  1129. case 3:
  1130. if (oGyroValue < -_rotateLimit) {
  1131. _tempState[3].bTrigger = true;
  1132. }
  1133. this.eliminateJumpPrefabFormTemp(_tempState);
  1134. break;
  1135. default:
  1136. console.log('没有对应的_jumpType', _jumpType);
  1137. break;
  1138. }
  1139. },
  1140. eliminateJumpPrefabFormTemp(_tempState) {
  1141. //只触发第三个
  1142. if (this.spawnArray.length < 3) {
  1143. return;
  1144. }
  1145. let _temp = this.spawnArray[2];
  1146. let bSuccess = false;
  1147. for (let i = 0; i < _tempState.length; i++) {
  1148. let _state = _tempState[i];
  1149. if (_state.bTrigger) {
  1150. console.log(this.eliminationCount + ',识别跳的类型:' + _state.describe + ',当前预制类型:' + _temp
  1151. .jumpName +
  1152. "\n直跳判断值:" + this.onLogData.currentMaxValue + ",旋转跳值:" + this.onLogData.oGyroValue);
  1153. }
  1154. //如果当前的跳类型和预制目标一样
  1155. if (_state.jumpCode == _temp.jumpCode && _state.bTrigger) {
  1156. //成功
  1157. bSuccess = true;
  1158. break;
  1159. }
  1160. }
  1161. //如果存在其中一个为true
  1162. if (bSuccess) {
  1163. _temp.bTrigger = true;
  1164. this.canSpawnTemp = _temp;
  1165. setTimeout(() => {
  1166. //这里更新特效
  1167. this.onDrawEffect(this.canSpawnTemp);
  1168. }, 150);
  1169. this.deleteSpawn = this.spawnArray.splice(0, 1);
  1170. if (this.index < this.templatePool.length) {
  1171. this.spawnArray.push(this.templatePool[this.index]);
  1172. this.index++;
  1173. }
  1174. //成功
  1175. this.setEliminationCount(1);
  1176. //替换数组
  1177. // console.log(this.index + " == " + this.spawnArray.length);
  1178. if (this.spawnArray.length < 3 && this.index > 3) {
  1179. clearInterval(this.countdownInterval);
  1180. this.countdownInterval = null;
  1181. //绘制新触发状态
  1182. this.canGoNext = true;
  1183. } else {
  1184. //绘制新触发状态
  1185. this.canOnDraw = true;
  1186. }
  1187. } else {
  1188. //失误
  1189. this.setFaultCount(1);
  1190. }
  1191. },
  1192. /**
  1193. * @param {Object} gameData
  1194. * 识别跳部分数据处理
  1195. */
  1196. onBLEHitUpdate(gameData) {
  1197. // console.log("gameData:", gameData);
  1198. if (!this.bJumpPlay || this.isGameOver || this.spawnAnimation != null) return;
  1199. // if (curAngleCeil < 30) {
  1200. // directionPunch = "straightPunch";
  1201. // name = "正向的直拳";
  1202. // ename = "front-straight";
  1203. // } else if (direction.x < 0) {
  1204. // directionPunch = "rightPunch";
  1205. // name = "正向的右拳";
  1206. // ename = "front-right";
  1207. // } else if (direction.x > 0) {
  1208. // directionPunch = "leftPunch";
  1209. // name = "正向的左拳";
  1210. // ename = "front-left";
  1211. // }
  1212. if (gameData.direction == "straightPunch") {
  1213. this.eliminateJumpPrefab(0);
  1214. } else if (gameData.direction == "leftPunch") {
  1215. this.eliminateJumpPrefab(1);
  1216. } else if (gameData.direction == "rightPunch") {
  1217. this.eliminateJumpPrefab(2);
  1218. }
  1219. this.BLEAccIndex++;
  1220. },
  1221. onClearData() {
  1222. this.BLEAccIndex = 0;
  1223. },
  1224. onChangeY() {
  1225. this.isY = true;
  1226. },
  1227. onChangeX() {
  1228. this.isY = false;
  1229. },
  1230. onGetActionJumpPlayView(callback) {
  1231. let view = uni.createSelectorQuery().select('#ActionJumpPlay');
  1232. view.boundingClientRect(data => {
  1233. if (callback)
  1234. callback(data);
  1235. }).exec();
  1236. },
  1237. onTipLevel() {
  1238. this.$emit("tipLevel", {
  1239. hiddenType: 'normal'
  1240. });
  1241. console.log("**************22");
  1242. }
  1243. }
  1244. }
  1245. </script>
  1246. <style lang="scss">
  1247. .mid-absolute {
  1248. position: absolute;
  1249. top: 0;
  1250. bottom: 0;
  1251. right: 0;
  1252. left: 0;
  1253. margin: auto;
  1254. }
  1255. .action-jump-timer {
  1256. position: absolute;
  1257. top: -150rpx;
  1258. }
  1259. .grid-progress-vertical-container {
  1260. min-height: 376rpx;
  1261. }
  1262. .grid-progress-vertical-bar {
  1263. max-height: 376rpx;
  1264. }
  1265. .grid-progress-vertical-child {
  1266. width: 35px;
  1267. height: 7.36px;
  1268. margin: 7.36px 0 0 0;
  1269. position: relative;
  1270. }
  1271. .grid-progress-vertical-active {
  1272. width: 28rpx;
  1273. }
  1274. .grid-progress-vertical-inactive {
  1275. width: 28rpx;
  1276. }
  1277. .sprite-yellow-arrow {
  1278. display: inline-block;
  1279. overflow: hidden;
  1280. background-repeat: no-repeat;
  1281. width: 194px;
  1282. height: 232px;
  1283. background-image: url('@/static/modal/action-jump/yellow-arrow.png');
  1284. // border: 1rpx solid #00CE47;
  1285. }
  1286. .animation-play-state-play {
  1287. animation: yellowArrowRun 1s steps(1, end); // infinite
  1288. animation-play-state: running;
  1289. }
  1290. .animation-play-state-paused {
  1291. animation-play-state: paused;
  1292. }
  1293. /**
  1294. * 箭头动画
  1295. */
  1296. @keyframes yellowArrowRun {
  1297. 0% {
  1298. background-position: -0px -0px;
  1299. }
  1300. 5% {
  1301. background-position: -0px -0px;
  1302. }
  1303. 10% {
  1304. background-position: -194px -0px;
  1305. }
  1306. 15% {
  1307. background-position: -388px -0px;
  1308. }
  1309. 20% {
  1310. background-position: -582px -0px;
  1311. }
  1312. 25% {
  1313. background-position: -776px -0px;
  1314. }
  1315. 30% {
  1316. background-position: -0px -232px;
  1317. }
  1318. 35% {
  1319. background-position: -194px -232px;
  1320. }
  1321. 40% {
  1322. background-position: -388px -232px;
  1323. }
  1324. 45% {
  1325. background-position: -582px -232px;
  1326. }
  1327. 50% {
  1328. background-position: -776px -232px;
  1329. }
  1330. 55% {
  1331. background-position: -0px -464px;
  1332. }
  1333. 60% {
  1334. background-position: -194px -464px;
  1335. }
  1336. 65% {
  1337. background-position: -388px -464px;
  1338. }
  1339. 70% {
  1340. background-position: -582px -464px;
  1341. }
  1342. 75% {
  1343. background-position: -776px -464px;
  1344. }
  1345. 80% {
  1346. background-position: -0px -696px;
  1347. }
  1348. 85% {
  1349. background-position: -194px -696px;
  1350. }
  1351. 90% {
  1352. background-position: -388px -696px;
  1353. }
  1354. 95% {
  1355. background-position: -582px -696px;
  1356. }
  1357. 100% {
  1358. background-position: -776px -696px;
  1359. }
  1360. }
  1361. .sprite-rightToLeftArrow {
  1362. display: inline-block;
  1363. overflow: hidden;
  1364. background-repeat: no-repeat;
  1365. width: 317px;
  1366. height: 42px;
  1367. background-image: url('@/static/modal/action-jump/rightToLeftArrow.png');
  1368. // border: 1rpx solid #00CE47;
  1369. }
  1370. .sprite-rightToLeftArrow-play {
  1371. animation: rightToLeftArrowRun 1s steps(1, end) infinite;
  1372. }
  1373. @keyframes rightToLeftArrowRun {
  1374. 0% {
  1375. background-position: -0px -0px;
  1376. }
  1377. 3.33% {
  1378. background-position: -0px -0px;
  1379. }
  1380. 6.66% {
  1381. background-position: -317px -0px;
  1382. }
  1383. 9.99% {
  1384. background-position: -0px -42px;
  1385. }
  1386. 13.33% {
  1387. background-position: -317px -42px;
  1388. }
  1389. 16.66% {
  1390. background-position: -0px -84px;
  1391. }
  1392. 19.99% {
  1393. background-position: -317px -84px;
  1394. }
  1395. 23.33% {
  1396. background-position: -0px -126px;
  1397. }
  1398. 26.66% {
  1399. background-position: -317px -126px;
  1400. }
  1401. 29.99% {
  1402. background-position: -0px -168px;
  1403. }
  1404. 33.33% {
  1405. background-position: -317px -168px;
  1406. }
  1407. 36.66% {
  1408. background-position: -0px -210px;
  1409. }
  1410. 39.99% {
  1411. background-position: -317px -210px;
  1412. }
  1413. 43.33% {
  1414. background-position: -0px -252px;
  1415. }
  1416. 46.66% {
  1417. background-position: -317px -252px;
  1418. }
  1419. 49.99% {
  1420. background-position: -0px -294px;
  1421. }
  1422. 53.33% {
  1423. background-position: -317px -294px;
  1424. }
  1425. 56.66% {
  1426. background-position: -0px -336px;
  1427. }
  1428. 59.99% {
  1429. background-position: -317px -336px;
  1430. }
  1431. 63.33% {
  1432. background-position: -0px -378px;
  1433. }
  1434. 66.66% {
  1435. background-position: -317px -378px;
  1436. }
  1437. 69.99% {
  1438. background-position: -0px -420px;
  1439. }
  1440. 73.33% {
  1441. background-position: -317px -420px;
  1442. }
  1443. 76.66% {
  1444. background-position: -0px -462px;
  1445. }
  1446. 79.99% {
  1447. background-position: -317px -462px;
  1448. }
  1449. 83.33% {
  1450. background-position: -0px -504px;
  1451. }
  1452. 86.66% {
  1453. background-position: -317px -504px;
  1454. }
  1455. 89.99% {
  1456. background-position: -0px -546px;
  1457. }
  1458. 93.33% {
  1459. background-position: -317px -546px;
  1460. }
  1461. 96.66% {
  1462. background-position: -0px -588px;
  1463. }
  1464. 100% {
  1465. background-position: -317px -588px;
  1466. }
  1467. }
  1468. </style>