action-hit.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652
  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. let _self = this;
  372. if (_self.hookAudioContext)
  373. _self.hookAudioContext.destroy();
  374. },
  375. methods: {
  376. ...mapMutations(['onHitOpenBLELight']),
  377. //更新新手状态提示
  378. onUpdateTipLevelValue(value) {
  379. this.bTipLevel = value;
  380. },
  381. //load 相关图片
  382. onLoadImage() {
  383. let _self = this;
  384. uni.getImageInfo({
  385. src: "../../../static/modal/boxing-post/left-hook-m@2x.png",
  386. success: function(image) {
  387. _self.directionJumpLeft = image;
  388. }
  389. });
  390. uni.getImageInfo({
  391. src: "../../../static/modal/boxing-post/right-hook-m@2x.png",
  392. success: function(image) {
  393. _self.directionJumpRight = image;
  394. }
  395. });
  396. uni.getImageInfo({
  397. src: "../../../static/modal/boxing-post/straight-m@2x.png",
  398. success: function(image) {
  399. _self.midJump = image;
  400. }
  401. });
  402. uni.getImageInfo({
  403. src: "../../../static/modal/boxing-post/right-hook-h@2x.png",
  404. success: function(image) {
  405. _self.directionJumpWhiteRight = image;
  406. }
  407. });
  408. uni.getImageInfo({
  409. src: "../../../static/modal/boxing-post/left-hook-h@2x.png",
  410. success: function(image) {
  411. _self.directionJumpWhiteLeft = image;
  412. }
  413. });
  414. uni.getImageInfo({
  415. src: "../../../static/modal/boxing-post/straight-h@2x.png",
  416. success: function(image) {
  417. _self.midJumpWhite = image;
  418. }
  419. });
  420. uni.getImageInfo({
  421. src: "../../../static/modal/action-jump/jumpTip.png",
  422. success: function(image) {
  423. _self.jumpTipImage = image;
  424. }
  425. });
  426. uni.getImageInfo({
  427. src: "../../../static/modal/action-jump/jump-tip-orange@2x.png",
  428. success: function(image) {
  429. _self.JumpTipOrange = image;
  430. }
  431. })
  432. uni.getImageInfo({
  433. src: "../../../static/modal/action-jump/progress-tip.png",
  434. success: function(image) {
  435. _self.jumpProgressTip = image;
  436. }
  437. })
  438. uni.getImageInfo({
  439. src: "../../../static/modal/action-jump/jumpNormal-line.png",
  440. success: function(image) {
  441. _self.jumpNormalLine = image;
  442. }
  443. });
  444. uni.getImageInfo({
  445. src: "../../../static/modal/action-jump/jumpNormal-rect.png",
  446. success: function(image) {
  447. _self.jumpNormalRect = image;
  448. _self.onDrawBg(true);
  449. }
  450. });
  451. uni.getImageInfo({
  452. src: "../../../static/modal/action-jump/cankao.png",
  453. success: function(image) {
  454. _self.cankao = image;
  455. }
  456. });
  457. /**
  458. * 烟花照片
  459. */
  460. uni.getImageInfo({
  461. src: "../../../static/modal/action-jump/boom.png",
  462. success: function(image) {
  463. _self.fireworkImage = image;
  464. }
  465. });
  466. },
  467. /**
  468. * 重置生成数组,重置倒计时
  469. */
  470. resetJumpGame() {
  471. this.spawnArray = [];
  472. this.templatePool = [];
  473. if (this.countdownInterval) {
  474. clearInterval(this.countdownInterval);
  475. this.countdownInterval = null;
  476. }
  477. // this.resetCountdown(60);
  478. },
  479. startJumpGame() {
  480. this.isGameOver = false;
  481. this.resetJumpGame();
  482. //开始游戏
  483. this.index = 0;
  484. // this.levelType = 5;
  485. let spawnCount = 7;
  486. let _ranType = Math.floor(Math.random() * 2);
  487. //生成二个占位
  488. this.addTemplatePoolFromType(false, this.template[0].spawnList[0][0]);
  489. this.addTemplatePoolFromType(false, this.template[0].spawnList[0][0]);
  490. if (this.levelType == 0) {
  491. //随便生成一组跳的数据
  492. let _spawnList = this.template[0].spawnList;
  493. for (let i = 0; i < 30; i++) {
  494. //再对象池里面生成一组对象
  495. this.addTemplatePoolFromType(true, _spawnList[0][0]);
  496. }
  497. //先生成spawnCount个
  498. for (let i = 0; i < spawnCount; i++) {
  499. this.spawnArray.push(this.templatePool[this.index]);
  500. this.index++;
  501. }
  502. } else if (this.levelType == 1) {
  503. //生成一组 左跳右跳
  504. let _spawnList = this.template[1].spawnList;
  505. for (let i = 0; i < 30; i++) {
  506. let ran = Math.floor(Math.random() * 2);
  507. for (let j = 0; j < _spawnList[ran].length; j++) {
  508. //再对象池里面生成一组对象
  509. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  510. }
  511. }
  512. //先生成spawnCount个
  513. for (let i = 0; i < spawnCount; i++) {
  514. this.spawnArray.push(this.templatePool[this.index]);
  515. this.index++;
  516. }
  517. console.log(this.spawnArray)
  518. } else if (this.levelType == 2) {
  519. //生成一组 左跳右跳原地
  520. let _spawnList = this.template[2].spawnList;
  521. for (let i = 0; i < 30; i++) {
  522. let ran = Math.floor(Math.random() * 2);
  523. for (let j = 0; j < _spawnList[ran].length; j++) {
  524. //再对象池里面生成一组对象
  525. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  526. }
  527. }
  528. //先生成spawnCount个
  529. for (let i = 0; i < spawnCount; i++) {
  530. this.spawnArray.push(this.templatePool[this.index]);
  531. this.index++;
  532. }
  533. } else if (this.levelType == 3) {
  534. //生成一组 左旋跳右旋跳
  535. let _spawnList = this.template[1].spawnList;
  536. for (let i = 0; i < 30; i++) {
  537. let ran = Math.floor(Math.random() * 2) + 2;
  538. for (let j = 0; j < _spawnList[ran].length; j++) {
  539. //再对象池里面生成一组对象
  540. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  541. }
  542. }
  543. //先生成spawnCount个
  544. for (let i = 0; i < spawnCount; i++) {
  545. this.spawnArray.push(this.templatePool[this.index]);
  546. this.index++;
  547. }
  548. } else if (this.levelType == 4) {
  549. //生成一组 左旋跳右旋跳
  550. let _spawnList = this.template[2].spawnList;
  551. for (let i = 0; i < 30; i++) {
  552. let ran = Math.floor(Math.random() * 2) + 2;
  553. for (let j = 0; j < _spawnList[ran].length; j++) {
  554. //再对象池里面生成一组对象
  555. this.addTemplatePoolFromType(true, _spawnList[ran][j]);
  556. }
  557. }
  558. //先生成spawnCount个
  559. for (let i = 0; i < spawnCount; i++) {
  560. this.spawnArray.push(this.templatePool[this.index]);
  561. this.index++;
  562. }
  563. } else if (this.levelType == 5) {
  564. for (let i = 0; i < 20; i++) {
  565. //随便生成三组数据
  566. let _newArray = [];
  567. let _spawnList2 = this.template[2].spawnList;
  568. let ran2 = Math.floor(Math.random() * 2);
  569. let ran3 = Math.floor(Math.random() * 2);
  570. if (_ranType >= 1) {
  571. ran2 += 2;
  572. ran3 += 2;
  573. }
  574. _newArray = _newArray.concat(_spawnList2[ran2]);
  575. _newArray = _newArray.concat(_spawnList2[ran3]);
  576. for (let j = 0; j < _newArray.length; j++) {
  577. this.addTemplatePoolFromType(true, _newArray[j]);
  578. }
  579. }
  580. //先生成spawnCount个
  581. for (let i = 0; i < spawnCount; i++) {
  582. this.spawnArray.push(this.templatePool[this.index]);
  583. this.index++;
  584. }
  585. }
  586. this.onDraw("tipHit", false);
  587. },
  588. /**
  589. * 生成对应预制对象
  590. * @param {Object} bShow
  591. * @param {Object} _jumpType
  592. */
  593. addTemplatePoolFromType(bShow, _jumpType) {
  594. for (let i = 0; i < this.jumpTypeArray.length; i++) {
  595. if (this.jumpTypeArray[i].jumpCode == _jumpType) {
  596. let _jumpPrefab = Object.assign({}, this.jumpTypeArray[i], {
  597. bShow: bShow,
  598. bInit: true,
  599. position: 0,
  600. animation: null, //动画
  601. });
  602. this.templatePool.push(_jumpPrefab);
  603. break;
  604. }
  605. }
  606. },
  607. //单纯的绘制八个背景
  608. onDrawBg(bDraw) {
  609. this.spawnPos = [];
  610. if (bDraw) {
  611. this.actionHitCanvas.clearRect(0, 0, this.canvasW, this.canvasH);
  612. }
  613. let _currentBgStartX = this.canvasW / 2;
  614. let count = 7;
  615. let _currentPos = -12,
  616. _addPos = 0;
  617. for (let i = 0; i < count; i++) {
  618. if (0 !== i) {
  619. _currentPos += this.jumpNormalWidth;
  620. } else {
  621. _currentPos -= this.jumpNormalWidth;
  622. }
  623. if (2 === i) {
  624. //结尾时候快消除完绘制一次大图背景。不然会为空白
  625. if (this.spawnArray.length < 3)
  626. this.actionHitCanvas.drawImage(this.jumpTipImage.path, _currentPos, 0, 120, this
  627. .canvasH);
  628. if (bDraw) {
  629. this.actionHitCanvas.drawImage(this.JumpTipOrange.path, _currentPos + 3, 7, 113, this
  630. .canvasH -
  631. 14);
  632. }
  633. //添加对应生成点
  634. this.spawnPos.push({
  635. center: _currentPos + 30
  636. })
  637. _currentPos += 50;
  638. } else {
  639. this.actionHitCanvas.drawImage(this.jumpNormalLine.path, _currentPos, 0, this
  640. .jumpNormalWidth,
  641. this.canvasH);
  642. if (bDraw) {
  643. this.actionHitCanvas.drawImage(this.jumpNormalRect.path, _currentPos, 0, this
  644. .jumpNormalWidth,
  645. this.canvasH);
  646. }
  647. //添加对应生成点
  648. this.spawnPos.push({
  649. center: _currentPos + 16
  650. })
  651. }
  652. }
  653. if (bDraw) {
  654. this.actionHitCanvas.draw();
  655. }
  656. },
  657. onDraw(type, bAnimation) {
  658. // console.log(type + "="+ bAnimation);
  659. let _self = this;
  660. //控制大图标区域音乐播放,发出一次提示音
  661. let bPlayAudio = true;
  662. if(type = 'tipHit' && _self.spawnAnimation == null){
  663. bPlayAudio = false;
  664. }
  665. if (bAnimation && _self.spawnAnimation == null) {
  666. _self.spawnProcess = 0;
  667. _self.spawnAnimation = new Animation({
  668. timing: 'linear',
  669. duration: 200,
  670. onProcess: function onProcess(process) {
  671. _self.spawnProcess = process;
  672. _self.onDraw('normal', true);
  673. // console.log("process=" + process);
  674. },
  675. onAnimationFinish: function onAnimationFinish() {
  676. // console.log("finish animation");
  677. _self.spawnAnimation = null;
  678. }
  679. })
  680. }
  681. this.actionHitCanvas.clearRect(0, 0, this.canvasW, this.canvasH);
  682. //单纯绘制背景
  683. this.onDrawBg(false);
  684. //计算一个节点数组
  685. // let _oldRectMoveDis = 1;
  686. for (let i = 0; i < this.spawnArray.length; i++) {
  687. //默认 mid 图标
  688. let _temp = this.spawnArray[i].bTrigger ? this.midJump : this.midJumpWhite;
  689. if (this.spawnArray[i].icon == 'directionJump') {
  690. if (this.spawnArray[i].jumpName == "RIGHT") {
  691. _temp = this.spawnArray[i].bTrigger ? this.directionJumpRight : this
  692. .directionJumpWhiteRight;
  693. } else {
  694. _temp = this.spawnArray[i].bTrigger ? this.directionJumpLeft : this
  695. .directionJumpWhiteLeft;
  696. }
  697. }
  698. this.actionHitCanvas.save();
  699. let _currentPos = this.spawnPos[i].center;
  700. let _currentCenterPos = 0;
  701. if (2 === i) {
  702. if(!bPlayAudio && this.bJumpPlay){
  703. // console.log("play video2 = "+i);
  704. bPlayAudio = true;
  705. //声音播放
  706. if (this.spawnArray[i].jumpName == "RIGHT") {
  707. this.hookAudioContext.stop();
  708. this.hookAudioContext.src = this.rightHookUrl;
  709. this.hookAudioContext.play();
  710. } else if(this.spawnArray[i].jumpName == "LEFT") {
  711. this.hookAudioContext.stop();
  712. this.hookAudioContext.src = this.leftHookUrl;
  713. this.hookAudioContext.play();
  714. } else{
  715. this.hookAudioContext.stop();
  716. this.hookAudioContext.src = this.straightHookUrl;
  717. this.hookAudioContext.play();
  718. }
  719. }
  720. //这里分两部分走,从小图走到大图
  721. let _spawnBiggerToLeft = this.spawnArray[i];
  722. //这里记录一个生成点,后面用于生成特效
  723. this.effectSpawnPosX = _currentPos;
  724. //大图
  725. let tempPosition = _currentPos;
  726. if (!bAnimation || _spawnBiggerToLeft.bInit) {
  727. _spawnBiggerToLeft.position = _currentPos;
  728. _spawnBiggerToLeft.bInit = false;
  729. } else {
  730. tempPosition = _spawnBiggerToLeft.position - Math.abs(_currentPos - _spawnBiggerToLeft
  731. .position) * _self.spawnProcess;
  732. }
  733. if (1 === this.spawnProcess) {
  734. _spawnBiggerToLeft.position = tempPosition;
  735. } else {
  736. //绘制一次前面方块背景前移
  737. this.actionHitCanvas.drawImage(this.jumpNormalRect.path, tempPosition - 16, 0, this
  738. .jumpNormalWidth,
  739. this.canvasH);
  740. this.actionHitCanvas.clearRect(this.spawnPos[i].center - 30, 0, 120, this.canvasH);
  741. }
  742. let _width = 40 + 20 * _self.spawnProcess;
  743. this.actionHitCanvas.drawImage(_temp.path, tempPosition, 55 - 9 * _self.spawnProcess,
  744. _width,
  745. _width);
  746. //绘制多一次背景
  747. this.actionHitCanvas.drawImage(this.jumpTipImage.path, this.spawnPos[i].center - 30, 0,
  748. 120, this
  749. .canvasH);
  750. this.actionHitCanvas.drawImage(this.JumpTipOrange.path, this.spawnPos[i].center - 27, 7,
  751. 113, this
  752. .canvasH -
  753. 14);
  754. } else {
  755. //小图
  756. let _otherObj = this.spawnArray[i];
  757. let tempPosition = _currentPos;
  758. if (!bAnimation || _otherObj.bInit) {
  759. _otherObj.position = _currentPos;
  760. _otherObj.bInit = false;
  761. } else {
  762. tempPosition = _otherObj.position - Math.abs(_currentPos - _otherObj.position) * _self
  763. .spawnProcess;
  764. }
  765. if (1 === this.spawnProcess) {
  766. _otherObj.position = tempPosition;
  767. }
  768. this.actionHitCanvas.drawImage(this.jumpNormalRect.path, tempPosition - 16, 0, this
  769. .jumpNormalWidth,
  770. this.canvasH);
  771. if (this.spawnArray[i].bShow) {
  772. this.actionHitCanvas.drawImage(_temp.path, tempPosition, 55, 40, 40);
  773. }
  774. }
  775. this.actionHitCanvas.restore();
  776. }
  777. this.actionHitCanvas.draw();
  778. },
  779. /**
  780. * 消除时候显示的特效
  781. * @param {Object} _temp
  782. */
  783. onDrawEffect(_temp) {
  784. if (!this.bRuning) {
  785. this.bRuning = true;
  786. if (this.yellowRuningTimeout) {
  787. clearTimeout(this.yellowRuningTimeout)
  788. this.yellowRuningTimeout = null;
  789. }
  790. this.yellowRuningTimeout = setTimeout(() => {
  791. this.bRuning = false;
  792. }, 1000)
  793. }
  794. //根据当前消除的生成一个
  795. let spawnTemp = this.midJump;
  796. let offest = 5;
  797. if (_temp.icon == 'directionJump') {
  798. spawnTemp = _temp.jumpName == "RIGHT" ? this.directionJumpRight : this.directionJumpLeft;
  799. }
  800. let tempFirework = new Firework(this.fireworkImage,
  801. spawnTemp, _temp.scaleX, this.effectSpawnPosX, 0, this.canvasW, 164, offest, true);
  802. this.fireworks.push(tempFirework);
  803. this.bDrawBoomEffect = true;
  804. this.onInitFirework();
  805. },
  806. onClear() {
  807. this.resetJumpGame();
  808. this.onDrawBg(true);
  809. this.xA = 0;
  810. this.yA = 0;
  811. this.zA = 0;
  812. },
  813. /**
  814. * 统一绘制 效果 背景,交互,烟花
  815. */
  816. onInitFirework() {
  817. if (this.loop != null) {
  818. return;
  819. }
  820. this.loop = setInterval(() => {
  821. if (!this.bDrawBoomEffect) {
  822. clearInterval(this.loop);
  823. this.loop = null;
  824. // console.log("结束绘制");
  825. this.effectHitCanvas.clearRect(0, 0, this.canvasW, 164);
  826. this.effectHitCanvas.draw();
  827. return;
  828. }
  829. this.effectHitCanvas.clearRect(0, 0, this.canvasW, 164);
  830. if (this.bDrawBoomEffect) {
  831. // loop over each firework, draw it, update it
  832. var i = this.fireworks.length;
  833. while (i--) {
  834. this.fireworks[i].draw(this.effectHitCanvas, () => {
  835. this.fireworks.splice(i, 1);
  836. if (this.fireworks.length == 0) {
  837. this.bDrawBoomEffect = false;
  838. }
  839. });
  840. }
  841. }
  842. this.effectHitCanvas.draw();
  843. }, 30)
  844. },
  845. onJumpType(event) {
  846. // console.log("onJumpType:", event);
  847. if (this.isGameOver || !this.bJumpPlay) return;
  848. this.eliminateJumpPrefab(event);
  849. },
  850. // update (dt) {}
  851. //模拟测试调用
  852. eliminateJumpPrefab(_jumpType) {
  853. //只触发第二个
  854. if (this.spawnArray.length < 3 || this.spawnAnimation != null) {
  855. return;
  856. }
  857. let _temp = this.spawnArray[2];
  858. //如果当前的跳类型和预制目标一样
  859. if (_jumpType == _temp.jumpCode) {
  860. _temp.bTrigger = true;
  861. this.deleteSpawn = this.spawnArray.splice(0, 1);
  862. if (this.index < this.templatePool.length) {
  863. this.spawnArray.push(this.templatePool[this.index]);
  864. this.index++;
  865. }
  866. //这里更新特效
  867. let _endTemp = Object.assign({}, _temp);
  868. this.onDrawEffect(_endTemp);
  869. //绘制新触发状态
  870. this.onDraw('tipHit', true);
  871. //成功
  872. this.setEliminationCount(1);
  873. //替换数组
  874. // console.log(this.index + " == " + this.spawnArray.length);
  875. if (this.spawnArray.length < 3 && this.index > 3) {
  876. clearInterval(this.countdownInterval);
  877. this.countdownInterval = null;
  878. //绘制新触发状态
  879. this.onDraw("normal", false);
  880. setTimeout(() => {
  881. this.startJumpGame();
  882. }, 2000)
  883. }
  884. // this.onHitOpenBLELight();
  885. } else {
  886. //失误
  887. this.setFaultCount(1);
  888. }
  889. },
  890. //设置倒计时
  891. setCountdown(value) {
  892. this.countdown -= value;
  893. // this.countdownLabel.string = '倒计时:' + this.countdown;
  894. this.$emit('actionJumpCountDownUpdate', {
  895. countDown: this.countdown
  896. });
  897. },
  898. resetCountdown(value) {
  899. this.countdown = value;
  900. // this.countdownLabel.string = '倒计时:' + this.countdown;
  901. this.$emit('actionJumpCountDownUpdate', {
  902. countDown: this.countdown
  903. });
  904. },
  905. //设置ui信息
  906. setEliminationCount(value) {
  907. this.tempHitCount++;
  908. this.taskSignCurCount++;
  909. this.roundingCount += this.addShowCountUnit;
  910. this.eliminationCount += value;
  911. // this.eliminationLabel.string = '消除数量:' + this.eliminationCount.toString();
  912. this.$emit('actionJumpDataUpdate', {
  913. eliminationCount: this.eliminationCount,
  914. faultCount: this.faultCount
  915. });
  916. this.jumpCalorie += puchConfig.getJumpCalorie(this.eliminationCount + this.faultCount);
  917. //如果是pk模式。不走下面判断
  918. // if (this.currentMode == 'pkMode') return;
  919. if (CONDITIONPASSED.ENERGYBARFULL == this.taskConditionPassed.limitType) {
  920. //能量条的条件下才显示能量条动
  921. //取两位后计算Math floor,不然会有偏差值问题 Math.floor(39.9999999+ 0.1111111) = 39
  922. this.showCurCount = Math.floor(this.roundingCount.toFixed(2));
  923. //1.能量槽满的时候,说明踩中次数到达
  924. if (this.taskSignCurCount >= this.taskSignCount)
  925. this.onGameOver("energyBarFull");
  926. } else if (CONDITIONPASSED.SKIPALLFLAGWITHINTIME == this.taskConditionPassed.limitType) {
  927. //规定时间下也给显示能量条
  928. this.showCurCount = Math.floor(this.roundingCount.toFixed(2));
  929. //2.规定时间内跳完所有标志块
  930. if (this.taskSignCurCount >= this.taskSignCount)
  931. this.onGameOver("skipAllFlagWithinTime");
  932. } else if (this.taskConditionPassed.isScore) {
  933. //3.达到一定分数
  934. //如果是用分数判断
  935. //分数是 跳对的加1分,错的扣1分,0不扣分。
  936. let curScore = this.eliminationCount - this.faultCount;
  937. curScore = curScore < 0 ? 0 : curScore;
  938. //当前分数达到,胜利
  939. if (curScore >= this.taskConditionPassed.limitScore)
  940. this.onGameOver("score");
  941. }
  942. },
  943. onGameOver(type) {
  944. this.isGameOver = true;
  945. //处理参数
  946. this.onClear();
  947. this.onClearData();
  948. this.bJumpPlay = false;
  949. /**
  950. * 判断胜利和失败
  951. */
  952. let myWin = false; //默认失败
  953. //比如, 1.充满左右两边蓄能槽.2.规定时间内跳完所有标志块.
  954. if (type == "energyBarFull") {
  955. //1.能量槽满的时候,说明踩中次数到达
  956. if (this.taskSignCurCount >= this.taskSignCount) {
  957. myWin = true;
  958. }
  959. } else if (type == 'skipAllFlagWithinTime') {
  960. myWin = true;
  961. } else if (type == "timeUp") {
  962. //2.规定时间内跳完所有标志块
  963. //查看消除数量是否到达总数,未达成就是未完成
  964. if (this.taskSignCurCount >= this.taskSignCount) {
  965. myWin = true;
  966. }
  967. } else if (type == "score") {
  968. myWin = true;
  969. }
  970. console.log(type, {
  971. myWin: myWin
  972. });
  973. this.$emit('gameOver', {
  974. myWin: myWin,
  975. type: 'calorieMode',
  976. isOffEvent: true
  977. });
  978. },
  979. //pk模式下结束游戏关卡
  980. onPKModeGameOver(type) {
  981. this.isGameOver = true;
  982. //处理参数
  983. this.onClear();
  984. this.onClearData();
  985. this.bJumpPlay = false;
  986. this.$emit('gameOver', {
  987. type: 'pkMode',
  988. isOffEvent: true
  989. });
  990. },
  991. setFaultCount(value) {
  992. this.tempHitCount++;
  993. this.faultCount += value;
  994. // this.faultLabel.string = '失误:' + this.faultCount;
  995. this.$emit('actionJumpDataUpdate', {
  996. eliminationCount: this.eliminationCount,
  997. faultCount: this.faultCount
  998. });
  999. this.jumpCalorie += puchConfig.getJumpCalorie(this.eliminationCount + this.faultCount);
  1000. },
  1001. //控制播放
  1002. onControllerPlay() {
  1003. console.log("onControllerPlay:",this.bJumpPlay)
  1004. if (this.bJumpPlay) {
  1005. //仅仅暂停,没有清空数据
  1006. this._changePlay(false);
  1007. this.$emit("actionJumpControllerPlay", false);
  1008. } else {
  1009. this.$emit("actionJumpCheck",{
  1010. bStartCountDown: true
  1011. });
  1012. }
  1013. },
  1014. onContinueGame() {
  1015. this._changePlay(true);
  1016. },
  1017. onClearActionJumpData() {
  1018. console.log("onClearActionJumpData");
  1019. this.onClear();
  1020. this.onClearData();
  1021. },
  1022. //修改状态
  1023. _changePlay(bPlaying) {
  1024. if (bPlaying) {
  1025. this.bJumpPlay = bPlaying;
  1026. } else {
  1027. this.bJumpPlay = !this.bJumpPlay;
  1028. }
  1029. },
  1030. onActionPlay() {
  1031. this.onClear();
  1032. this.onClearData();
  1033. this.startJumpGame();
  1034. this._changePlay(true);
  1035. console.log("onActionPlay:",this.bJumpPlay)
  1036. //reset 对应计算数据
  1037. this.taskSignCurCount = 0;
  1038. this.showCurCount = 0;
  1039. this.roundingCount = 0;
  1040. this.faultCount = 0;
  1041. this.eliminationCount = 0;
  1042. },
  1043. /**
  1044. * 停止并清空数据
  1045. */
  1046. onStopAndClearAction() {
  1047. console.log("onStopAndClearAction")
  1048. this.onClear();
  1049. this.onClearData();
  1050. this.bJumpPlay = false;
  1051. //reset 对应计算数据
  1052. this.taskSignCurCount = 0;
  1053. this.showCurCount = 0;
  1054. this.roundingCount = 0;
  1055. this.faultCount = 0;
  1056. this.eliminationCount = 0;
  1057. this.jumpCalorie = 0;
  1058. },
  1059. getCurrentJumpType() {
  1060. let _temp = this.spawnArray[2];
  1061. return _temp.jumpCode;
  1062. },
  1063. //监听跳的状态数据
  1064. listenStateDataOfJump(data) {
  1065. if (this.spawnArray.length < 3) return;
  1066. let _jumpType = this.getCurrentJumpType();
  1067. //初始全部默认状态
  1068. let _tempState = [{
  1069. jumpName: 'NORMAL',
  1070. jumpCode: 0,
  1071. bTrigger: false,
  1072. describe: '正常跳'
  1073. },
  1074. {
  1075. jumpName: 'LEFT',
  1076. jumpCode: 1,
  1077. bTrigger: false,
  1078. describe: '左直跳'
  1079. },
  1080. {
  1081. jumpName: 'RIGHT',
  1082. jumpCode: 2,
  1083. bTrigger: false,
  1084. describe: '右直跳'
  1085. },
  1086. {
  1087. jumpName: 'LEFT_ROTATE',
  1088. jumpCode: 3,
  1089. bTrigger: false,
  1090. describe: '左旋转跳'
  1091. },
  1092. {
  1093. jumpName: 'RIGHT_ROTATE',
  1094. jumpCode: 4,
  1095. bTrigger: false,
  1096. describe: '右旋转跳'
  1097. }
  1098. ];
  1099. let {
  1100. currentMaxValue,
  1101. oGyroValue,
  1102. peakOfWaveMaxValue,
  1103. valleyOfWaveMinValue
  1104. } = data
  1105. // console.log('stateDataOfJump:');
  1106. // console.log(JSON.stringify(data));
  1107. this.onLogData = data;
  1108. let _rotateLimit = 4;
  1109. let _jumpLimit = 0;
  1110. switch (_jumpType) {
  1111. case 0:
  1112. //JumpType.NORMAL = 0
  1113. _tempState[0].bTrigger = true;
  1114. this.eliminateJumpPrefabFormTemp(_tempState);
  1115. break;
  1116. case 1:
  1117. if (currentMaxValue < -_jumpLimit) {
  1118. //left jump
  1119. _tempState[1].bTrigger = true;
  1120. }
  1121. this.eliminateJumpPrefabFormTemp(_tempState);
  1122. break;
  1123. case 2:
  1124. if (currentMaxValue > _jumpLimit) {
  1125. //right jump
  1126. _tempState[2].bTrigger = true;
  1127. }
  1128. this.eliminateJumpPrefabFormTemp(_tempState);
  1129. break;
  1130. case 4:
  1131. if (oGyroValue > _rotateLimit) {
  1132. _tempState[4].bTrigger = true;
  1133. }
  1134. this.eliminateJumpPrefabFormTemp(_tempState);
  1135. break;
  1136. case 3:
  1137. if (oGyroValue < -_rotateLimit) {
  1138. _tempState[3].bTrigger = true;
  1139. }
  1140. this.eliminateJumpPrefabFormTemp(_tempState);
  1141. break;
  1142. default:
  1143. console.log('没有对应的_jumpType', _jumpType);
  1144. break;
  1145. }
  1146. },
  1147. eliminateJumpPrefabFormTemp(_tempState) {
  1148. //只触发第三个
  1149. if (this.spawnArray.length < 3) {
  1150. return;
  1151. }
  1152. let _temp = this.spawnArray[2];
  1153. let bSuccess = false;
  1154. for (let i = 0; i < _tempState.length; i++) {
  1155. let _state = _tempState[i];
  1156. if (_state.bTrigger) {
  1157. console.log(this.eliminationCount + ',识别跳的类型:' + _state.describe + ',当前预制类型:' + _temp
  1158. .jumpName +
  1159. "\n直跳判断值:" + this.onLogData.currentMaxValue + ",旋转跳值:" + this.onLogData.oGyroValue);
  1160. }
  1161. //如果当前的跳类型和预制目标一样
  1162. if (_state.jumpCode == _temp.jumpCode && _state.bTrigger) {
  1163. //成功
  1164. bSuccess = true;
  1165. break;
  1166. }
  1167. }
  1168. //如果存在其中一个为true
  1169. if (bSuccess) {
  1170. _temp.bTrigger = true;
  1171. this.canSpawnTemp = _temp;
  1172. setTimeout(() => {
  1173. //这里更新特效
  1174. this.onDrawEffect(this.canSpawnTemp);
  1175. }, 150);
  1176. this.deleteSpawn = this.spawnArray.splice(0, 1);
  1177. if (this.index < this.templatePool.length) {
  1178. this.spawnArray.push(this.templatePool[this.index]);
  1179. this.index++;
  1180. }
  1181. //成功
  1182. this.setEliminationCount(1);
  1183. //替换数组
  1184. // console.log(this.index + " == " + this.spawnArray.length);
  1185. if (this.spawnArray.length < 3 && this.index > 3) {
  1186. clearInterval(this.countdownInterval);
  1187. this.countdownInterval = null;
  1188. //绘制新触发状态
  1189. this.canGoNext = true;
  1190. } else {
  1191. //绘制新触发状态
  1192. this.canOnDraw = true;
  1193. }
  1194. } else {
  1195. //失误
  1196. this.setFaultCount(1);
  1197. }
  1198. },
  1199. /**
  1200. * @param {Object} gameData
  1201. * 识别跳部分数据处理
  1202. */
  1203. onBLEHitUpdate(gameData) {
  1204. // console.log("gameData:", gameData);
  1205. if (!this.bJumpPlay || this.isGameOver || this.spawnAnimation != null) return;
  1206. // if (curAngleCeil < 30) {
  1207. // directionPunch = "straightPunch";
  1208. // name = "正向的直拳";
  1209. // ename = "front-straight";
  1210. // } else if (direction.x < 0) {
  1211. // directionPunch = "rightPunch";
  1212. // name = "正向的右拳";
  1213. // ename = "front-right";
  1214. // } else if (direction.x > 0) {
  1215. // directionPunch = "leftPunch";
  1216. // name = "正向的左拳";
  1217. // ename = "front-left";
  1218. // }
  1219. if (gameData.direction == "straightPunch") {
  1220. this.eliminateJumpPrefab(0);
  1221. } else if (gameData.direction == "leftPunch") {
  1222. this.eliminateJumpPrefab(1);
  1223. } else if (gameData.direction == "rightPunch") {
  1224. this.eliminateJumpPrefab(2);
  1225. }
  1226. this.BLEAccIndex++;
  1227. },
  1228. onClearData() {
  1229. this.BLEAccIndex = 0;
  1230. },
  1231. onChangeY() {
  1232. this.isY = true;
  1233. },
  1234. onChangeX() {
  1235. this.isY = false;
  1236. },
  1237. onGetActionJumpPlayView(callback) {
  1238. let view = uni.createSelectorQuery().select('#ActionJumpPlay');
  1239. view.boundingClientRect(data => {
  1240. if (callback)
  1241. callback(data);
  1242. }).exec();
  1243. },
  1244. onTipLevel() {
  1245. this.$emit("tipLevel", {
  1246. hiddenType: 'normal'
  1247. });
  1248. console.log("**************22");
  1249. }
  1250. }
  1251. }
  1252. </script>
  1253. <style lang="scss">
  1254. .mid-absolute {
  1255. position: absolute;
  1256. top: 0;
  1257. bottom: 0;
  1258. right: 0;
  1259. left: 0;
  1260. margin: auto;
  1261. }
  1262. .action-jump-timer {
  1263. position: absolute;
  1264. top: -150rpx;
  1265. }
  1266. .grid-progress-vertical-container {
  1267. min-height: 376rpx;
  1268. }
  1269. .grid-progress-vertical-bar {
  1270. max-height: 376rpx;
  1271. }
  1272. .grid-progress-vertical-child {
  1273. width: 35px;
  1274. height: 7.36px;
  1275. margin: 7.36px 0 0 0;
  1276. position: relative;
  1277. }
  1278. .grid-progress-vertical-active {
  1279. width: 28rpx;
  1280. }
  1281. .grid-progress-vertical-inactive {
  1282. width: 28rpx;
  1283. }
  1284. .sprite-yellow-arrow {
  1285. display: inline-block;
  1286. overflow: hidden;
  1287. background-repeat: no-repeat;
  1288. width: 194px;
  1289. height: 232px;
  1290. background-image: url('@/static/modal/action-jump/yellow-arrow.png');
  1291. // border: 1rpx solid #00CE47;
  1292. }
  1293. .animation-play-state-play {
  1294. animation: yellowArrowRun 1s steps(1, end); // infinite
  1295. animation-play-state: running;
  1296. }
  1297. .animation-play-state-paused {
  1298. animation-play-state: paused;
  1299. }
  1300. /**
  1301. * 箭头动画
  1302. */
  1303. @keyframes yellowArrowRun {
  1304. 0% {
  1305. background-position: -0px -0px;
  1306. }
  1307. 5% {
  1308. background-position: -0px -0px;
  1309. }
  1310. 10% {
  1311. background-position: -194px -0px;
  1312. }
  1313. 15% {
  1314. background-position: -388px -0px;
  1315. }
  1316. 20% {
  1317. background-position: -582px -0px;
  1318. }
  1319. 25% {
  1320. background-position: -776px -0px;
  1321. }
  1322. 30% {
  1323. background-position: -0px -232px;
  1324. }
  1325. 35% {
  1326. background-position: -194px -232px;
  1327. }
  1328. 40% {
  1329. background-position: -388px -232px;
  1330. }
  1331. 45% {
  1332. background-position: -582px -232px;
  1333. }
  1334. 50% {
  1335. background-position: -776px -232px;
  1336. }
  1337. 55% {
  1338. background-position: -0px -464px;
  1339. }
  1340. 60% {
  1341. background-position: -194px -464px;
  1342. }
  1343. 65% {
  1344. background-position: -388px -464px;
  1345. }
  1346. 70% {
  1347. background-position: -582px -464px;
  1348. }
  1349. 75% {
  1350. background-position: -776px -464px;
  1351. }
  1352. 80% {
  1353. background-position: -0px -696px;
  1354. }
  1355. 85% {
  1356. background-position: -194px -696px;
  1357. }
  1358. 90% {
  1359. background-position: -388px -696px;
  1360. }
  1361. 95% {
  1362. background-position: -582px -696px;
  1363. }
  1364. 100% {
  1365. background-position: -776px -696px;
  1366. }
  1367. }
  1368. .sprite-rightToLeftArrow {
  1369. display: inline-block;
  1370. overflow: hidden;
  1371. background-repeat: no-repeat;
  1372. width: 317px;
  1373. height: 42px;
  1374. background-image: url('@/static/modal/action-jump/rightToLeftArrow.png');
  1375. // border: 1rpx solid #00CE47;
  1376. }
  1377. .sprite-rightToLeftArrow-play {
  1378. animation: rightToLeftArrowRun 1s steps(1, end) infinite;
  1379. }
  1380. @keyframes rightToLeftArrowRun {
  1381. 0% {
  1382. background-position: -0px -0px;
  1383. }
  1384. 3.33% {
  1385. background-position: -0px -0px;
  1386. }
  1387. 6.66% {
  1388. background-position: -317px -0px;
  1389. }
  1390. 9.99% {
  1391. background-position: -0px -42px;
  1392. }
  1393. 13.33% {
  1394. background-position: -317px -42px;
  1395. }
  1396. 16.66% {
  1397. background-position: -0px -84px;
  1398. }
  1399. 19.99% {
  1400. background-position: -317px -84px;
  1401. }
  1402. 23.33% {
  1403. background-position: -0px -126px;
  1404. }
  1405. 26.66% {
  1406. background-position: -317px -126px;
  1407. }
  1408. 29.99% {
  1409. background-position: -0px -168px;
  1410. }
  1411. 33.33% {
  1412. background-position: -317px -168px;
  1413. }
  1414. 36.66% {
  1415. background-position: -0px -210px;
  1416. }
  1417. 39.99% {
  1418. background-position: -317px -210px;
  1419. }
  1420. 43.33% {
  1421. background-position: -0px -252px;
  1422. }
  1423. 46.66% {
  1424. background-position: -317px -252px;
  1425. }
  1426. 49.99% {
  1427. background-position: -0px -294px;
  1428. }
  1429. 53.33% {
  1430. background-position: -317px -294px;
  1431. }
  1432. 56.66% {
  1433. background-position: -0px -336px;
  1434. }
  1435. 59.99% {
  1436. background-position: -317px -336px;
  1437. }
  1438. 63.33% {
  1439. background-position: -0px -378px;
  1440. }
  1441. 66.66% {
  1442. background-position: -317px -378px;
  1443. }
  1444. 69.99% {
  1445. background-position: -0px -420px;
  1446. }
  1447. 73.33% {
  1448. background-position: -317px -420px;
  1449. }
  1450. 76.66% {
  1451. background-position: -0px -462px;
  1452. }
  1453. 79.99% {
  1454. background-position: -317px -462px;
  1455. }
  1456. 83.33% {
  1457. background-position: -0px -504px;
  1458. }
  1459. 86.66% {
  1460. background-position: -317px -504px;
  1461. }
  1462. 89.99% {
  1463. background-position: -0px -546px;
  1464. }
  1465. 93.33% {
  1466. background-position: -317px -546px;
  1467. }
  1468. 96.66% {
  1469. background-position: -0px -588px;
  1470. }
  1471. 100% {
  1472. background-position: -317px -588px;
  1473. }
  1474. }
  1475. </style>