action-hit.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644
  1. 11
  2. <!-- 新版本拳击区域部分文件 -->
  3. <template>
  4. <view style="width: 750rpx;">
  5. <view class="flex justify-center" style="margin-top: 68rpx;">
  6. <!-- 目前格子数量不代表数字,显示完成度而已 -460rpx;-->
  7. <view class="grid-progress-vertical-container" style="top:-376rpx;">
  8. <view class="grid-progress-vertical-bar">
  9. <view class="grid-progress-vertical-child" v-for="(item, index) in maxShowCount +1" :key="index"
  10. v-if="index!==0">
  11. <view
  12. :class="showCurCount>=index? 'grid-progress-vertical-active':'grid-progress-vertical-inactive'">
  13. </view>
  14. <view :class="(index%5 == 0||index == 1)?'':'grid-progress-text-hidden'"
  15. class="grid-progress-vertical-text" style="position: absolute;right: 0;top: -4px;">
  16. {{Math.floor(taskSignCount / 26 * index)}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="grid-progress-vertical-bar">
  21. <view class="grid-progress-vertical-child" v-for="(item, index) in maxShowCount +1" :key="index"
  22. v-if="index!==0">
  23. <view :class="(index%5 == 0||index == 1)?'':'grid-progress-text-hidden'"
  24. class="grid-progress-vertical-text" style="position: absolute;left: 0;top: -4px;">
  25. {{Math.floor(taskSignCount / 26 * index)+taskSignCount/2}}
  26. </view>
  27. <!-- 设置空位 -->
  28. <view></view>
  29. <view
  30. :class="showCurCount>=index+13? 'grid-progress-vertical-active':'grid-progress-vertical-inactive'">
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- class="position-relative" -->
  37. <view style="position: relative;">
  38. <view class="position-absolute-left-top flex justify-center align-center " style="width: 86.12px;height:55.96px;
  39. left: 146rpx;top:-90rpx; ">
  40. <view style="transform: scale(0.5);">
  41. <view class="sprite-yellow-arrow " :class="bRuning?'animation-play-state-play':''"></view>
  42. </view>
  43. </view>
  44. <view class="position-absolute-right-bottom flex justify-center align-center "
  45. style="width: 317rpx; height:138px; right: 46rpx; bottom: 15rpx;">
  46. <view class="flex flex-direction justify-between" style="transform: scale(0.5); height: 276px; ">
  47. <block v-if="bJumpPlay">
  48. <view class="sprite-rightToLeftArrow" :class="bJumpPlay?'sprite-rightToLeftArrow-play':''">
  49. </view>
  50. <view class="sprite-rightToLeftArrow" :class="bJumpPlay?'sprite-rightToLeftArrow-play':''">
  51. </view>
  52. </block>
  53. <block v-else>
  54. <image style="width: 317px; height: 42px;"
  55. src="../../../static/modal/action-jump/progress-tip.png"></image>
  56. <image style="width: 317px; height: 42px;"
  57. src="../../../static/modal/action-jump/progress-tip.png"></image>
  58. </block>
  59. </view>
  60. </view>
  61. <canvas canvas-id="actionHitCanvas" :style="{ width: canvasW + 'px', height: canvasH + 'px' }"></canvas>
  62. </view>
  63. <view style="position: absolute;
  64. top: 30px;
  65. bottom: 0;
  66. left: 0;
  67. right: 0;
  68. justify-content: center;
  69. align-items: center;">
  70. <!-- class="position-absolute-center" -->
  71. <canvas canvas-id="effectHitCanvas" :style="{ width: canvasW + 'px', height: '164px' }"></canvas>
  72. </view>
  73. <view class="flex align-center justify-center" style="font-size: 14px; width:750rpx;">
  74. <view style="position: relative;">
  75. <image style="width: 135px;height: 75px;" src="../../../static/modal/action-jump/Fill.png"></image>
  76. <view class="mid-absolute flex flex-direction align-center justify-center text-white">
  77. <view class="flex align-center">
  78. <image style="width: 22rpx;height: 28rpx;"
  79. src="../../../static/modal/action-jump/jumpSpeed.png"></image>
  80. <view style="margin-left: 6rpx;">平均速度</view>
  81. </view>
  82. <view style="margin-top: 12rpx;">{{averageSpeed}}</view>
  83. </view>
  84. </view>
  85. <view id="ActionJumpPlay" class="flex" style="position: relative;" @click="onControllerPlay">
  86. <image style="width: 110px;height: 110px;"
  87. src="../../../static/modal/action-jump/mid-button-orange@2x.png">
  88. </image>
  89. <image v-if="!bJumpPlay" class="mid-absolute" style="left:12rpx; width: 56rpx;height: 70rpx;"
  90. src="../../../static/play.png">
  91. </image>
  92. <image v-else class="mid-absolute" style="width: 100rpx;height: 100rpx;"
  93. src="../../../static/e-pause.png">
  94. </image>
  95. </view>
  96. <view style="position: relative;">
  97. <image style="width: 135px;height: 75px; transform: scaleX(-1);"
  98. src="../../../static/modal/action-jump/Fill.png"></image>
  99. <view class="mid-absolute flex flex-direction align-center justify-center text-white">
  100. <view class="flex align-center">
  101. <image style="width: 22rpx;height: 28rpx;"
  102. src="../../../static/modal/action-jump/jumpCalorie.png"></image>
  103. <view style="margin-left: 6rpx;">卡路里</view>
  104. </view>
  105. <view style="margin-top: 12rpx;">{{Math.floor(jumpCalorie)}}</view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="flex align-center justify-center" style="width: 750rpx;margin-top: 16rpx;">
  110. <view class="flex justify-center align-center" style="height: 120rpx; width: 444rpx; ">
  111. <view class="text-12px text-white text-center">
  112. {{taskDescribe}}
  113. </view>
  114. </view>
  115. </view>
  116. <!-- #ifdef H5 -->
  117. <view style="display: flex;justify-content: space-between;" class="margin-top margin-bottom">
  118. <button @click="onJumpType(0)">middle</button>
  119. <button @click="onJumpType(1)">left</button>
  120. <button @click="onJumpType(2)">right</button>
  121. </view>
  122. <!-- #endif -->
  123. </view>
  124. </template>
  125. <script>
  126. import {
  127. CONDITIONPASSED
  128. } from "@/util/util-js/enum.js"
  129. import Firework from "@/util/util-js/effect/firework.js"
  130. import Animation from "@/util/util-js/Animation.js"
  131. import puchConfig from "@/util/util-js/puchConfig.js"
  132. import {
  133. mapState,
  134. mapMutations
  135. } from 'vuex';
  136. export default {
  137. computed: mapState(['systemInfo', 'bOldDeviceType']),
  138. components: {
  139. },
  140. props: {
  141. showTime: {
  142. type: Number,
  143. default: 0
  144. },
  145. levelData: {
  146. type: Object,
  147. default: null
  148. },
  149. currentMode: {
  150. type: String,
  151. default: ''
  152. }
  153. },
  154. data() {
  155. return {
  156. isY: true,
  157. canvasW: 0, // 画布宽
  158. canvasH: 0, // 画布高
  159. // SystemInfo: {}, // 设备信息
  160. directionJumpRight: null,
  161. directionJumpLeft: null,
  162. midJump: null,
  163. rotateJumpRight: null,
  164. rotateJumpLeft: null,
  165. directionJumpWhiteRight: null,
  166. directionJumpWhiteLeft: null,
  167. midJumpWhite: null,
  168. rotateJumpWhiteRight: null,
  169. rotateJumpWhiteLeft: null,
  170. //参考图片
  171. cankao: null,
  172. jumpTipImage: null,
  173. JumpTipOrange: null,
  174. jumpNormalLine: null,
  175. jumpNormalRect: null,
  176. jumpNormalWidth: 70,
  177. jumpNormalHeight: 164,
  178. jumpProgressTip: null,
  179. jumpTypeArray: [{
  180. jumpName: 'NORMAL',
  181. jumpCode: 0,
  182. icon: 'midJump',
  183. scaleX: 1,
  184. bTrigger: false,
  185. bShow: true,
  186. }, {
  187. jumpName: 'LEFT',
  188. jumpCode: 1,
  189. icon: 'directionJump',
  190. scaleX: 1,
  191. bTrigger: false,
  192. bShow: true,
  193. }, {
  194. jumpName: 'RIGHT',
  195. jumpCode: 2,
  196. icon: 'directionJump',
  197. scaleX: 1,
  198. bTrigger: false,
  199. bShow: true,
  200. }],
  201. spawnArray: [],
  202. deleteSpawn: null, //已删除的对象
  203. deleteImage: null,
  204. /**
  205. * 生成的背景位置
  206. */
  207. spawnPos: [],
  208. spawnAnimation: null,
  209. spawnProcess: 1,
  210. //下一个生成是相反的方向
  211. bNextSpawnRightDirection: false,
  212. bNextSpawnRightRotateDirection: false,
  213. //生成预制的模板,用count 来判断生成哪一种
  214. template: [{ //原地
  215. count: 1,
  216. spawnList: [
  217. [0]
  218. ]
  219. }, {
  220. count: 2,
  221. spawnList: [
  222. [2, 1],
  223. [1, 2],
  224. [3, 4],
  225. [4, 3]
  226. ]
  227. }, {
  228. count: 3,
  229. spawnList: [
  230. [2, 0, 1],
  231. [1, 0, 2],
  232. [3, 0, 4],
  233. [4, 0, 3]
  234. ]
  235. }, ],
  236. //模板对象池,管理生成对象
  237. templatePool: [],
  238. levelType: 0,
  239. countdown: 60,
  240. countdownInterval: null,
  241. faultCount: 0,
  242. eliminationCount: 0,
  243. bJumpPlay: false,
  244. jumpCalorie: 0,
  245. averageSpeedInterval: null,
  246. averageSpeed: 0,
  247. tempHitCount: 0,
  248. //硬件设备处理
  249. BLEAccIndex: 0,
  250. xA: 0,
  251. yA: 0,
  252. zA: 0,
  253. /**
  254. * 交互数据处理
  255. */
  256. //当前选择的关卡信息
  257. selfLevelData: null,
  258. // 双人模式下 数据
  259. //标记块数量
  260. taskSignCount: 0, //总数
  261. taskSignCurCount: 0, //当前计数
  262. //{"type":1,"explain":"规定时间内跳完所有标志块","limitType":1}
  263. taskConditionPassed: null,
  264. taskDescribe: '',
  265. //满格的数值是 25
  266. maxShowCount: 13,
  267. addShowCountUnit: 0,
  268. showCurCount: 0,
  269. roundingCount: 0,
  270. //游戏结束
  271. isGameOver: false,
  272. //pk模式下操作
  273. leftShowCurCount: 0,
  274. rightShowCurCount: 0,
  275. isleftPlayer: true,
  276. /**
  277. * 是否允许绘制
  278. */
  279. canOnDraw: false,
  280. /**
  281. * 是否去到下一个关卡
  282. */
  283. canGoNext: false,
  284. /**
  285. * 生成的特效
  286. */
  287. canSpawnTemp: null,
  288. onLogData: '',
  289. /**
  290. * 是否显示关卡提示
  291. */
  292. bTipLevel: false,
  293. /**
  294. * 烟花相关
  295. */
  296. // firework collection
  297. fireworks: [],
  298. fireworkImage: null,
  299. loop: null,
  300. count: 100,
  301. effectHitCanvas: null,
  302. effectCurrentSpawn: null,
  303. effectSpawnPosX: 0,
  304. /**
  305. * 烟花特效
  306. */
  307. bDrawBoomEffect: false,
  308. //绘制箭头效果
  309. bRuning: false,
  310. bRuningInfinite: false,
  311. yellowRuningTimeout: null,
  312. //音效
  313. leftHookUrl: "/static/modal/boxing-post/left-hook.mp3",
  314. rightHookUrl: "/static/modal/boxing-post/right-hook.mp3",
  315. straightHookUrl: "/static/modal/boxing-post/straight-hook.mp3",
  316. hookAudioContext: null,
  317. }
  318. },
  319. watch: {
  320. levelData(val) {
  321. //更新数据
  322. // console.log("levelData ============>"+JSON.stringify(val));
  323. if (val) {
  324. this.taskSignCount = val.signCount;
  325. this.taskConditionPassed = val.conditionPassed;
  326. this.taskDescribe = val.describe;
  327. this.addShowCountUnit = (this.maxShowCount * 2) / this.taskSignCount;
  328. // console.log("this.addShowCountUnit:", this.addShowCountUnit, this.maxShowCount * 2, this
  329. // .taskSignCount);
  330. this.showCount = 0;
  331. //用signType 做等级类型
  332. this.levelType = val.signType;
  333. console.log(JSON.stringify(this.taskConditionPassed));
  334. }
  335. },
  336. currentMode(val) {
  337. // console.log('==========> action jump currentMode:', val);
  338. }
  339. },
  340. created() {
  341. let _self = this;
  342. //初始化一个音效
  343. _self.hookAudioContext = uni.createInnerAudioContext();
  344. _self.hookAudioContext.autoplay = false;
  345. _self.hookAudioContext.src = _self.straightHookUrl;
  346. _self.hookAudioContext.volume = 0.5;
  347. this.actionHitCanvas = uni.createCanvasContext("actionHitCanvas", this);
  348. this.effectHitCanvas = uni.createCanvasContext("effectHitCanvas", this);
  349. // this.SystemInfo = this.systemInfo; // uni.getSystemInfoSync();
  350. this.canvasW = this.systemInfo.windowWidth; // 画布宽度
  351. this.canvasH = 147.68;
  352. this.onLoadImage();
  353. //更新一次状态
  354. const value = uni.getStorageSync('levelButtonPrompt');
  355. if (value) {
  356. _self.bTipLevel = !value.isSelected;
  357. } else {
  358. _self.bTipLevel = true;
  359. }
  360. if (this.averageSpeedInterval) {
  361. clearInterval(this.averageSpeedInterval);
  362. this.averageSpeedInterval = null;
  363. }
  364. //计算平均速度
  365. this.averageSpeedInterval = setInterval(() => {
  366. this.averageSpeed = this.tempHitCount;
  367. this.tempHitCount = 0;
  368. }, 3000)
  369. console.log("组件创建")
  370. },
  371. beforeDestroy() {
  372. if (_self.hookAudioContext)
  373. _self.hookAudioContext.destroy();
  374. },
  375. methods: {
  376. ...mapMutations(['onWriteBLEConnectionValue', 'onConvertDeviceData']),
  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){
  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. } else {
  885. //失误
  886. this.setFaultCount(1);
  887. }
  888. },
  889. //设置倒计时
  890. setCountdown(value) {
  891. this.countdown -= value;
  892. // this.countdownLabel.string = '倒计时:' + this.countdown;
  893. this.$emit('actionJumpCountDownUpdate', {
  894. countDown: this.countdown
  895. });
  896. },
  897. resetCountdown(value) {
  898. this.countdown = value;
  899. // this.countdownLabel.string = '倒计时:' + this.countdown;
  900. this.$emit('actionJumpCountDownUpdate', {
  901. countDown: this.countdown
  902. });
  903. },
  904. //设置ui信息
  905. setEliminationCount(value) {
  906. this.tempHitCount++;
  907. this.taskSignCurCount++;
  908. this.roundingCount += this.addShowCountUnit;
  909. this.eliminationCount += value;
  910. // this.eliminationLabel.string = '消除数量:' + this.eliminationCount.toString();
  911. this.$emit('actionJumpDataUpdate', {
  912. eliminationCount: this.eliminationCount,
  913. faultCount: this.faultCount
  914. });
  915. this.jumpCalorie += puchConfig.getJumpCalorie(this.eliminationCount + this.faultCount);
  916. //如果是pk模式。不走下面判断
  917. if (this.currentMode == 'pkMode') return;
  918. if (CONDITIONPASSED.ENERGYBARFULL == this.taskConditionPassed.limitType) {
  919. //能量条的条件下才显示能量条动
  920. //取两位后计算Math floor,不然会有偏差值问题 Math.floor(39.9999999+ 0.1111111) = 39
  921. this.showCurCount = Math.floor(this.roundingCount.toFixed(2));
  922. //1.能量槽满的时候,说明踩中次数到达
  923. if (this.taskSignCurCount >= this.taskSignCount)
  924. this.onGameOver("energyBarFull");
  925. } else if (CONDITIONPASSED.SKIPALLFLAGWITHINTIME == this.taskConditionPassed.limitType) {
  926. //规定时间下也给显示能量条
  927. this.showCurCount = Math.floor(this.roundingCount.toFixed(2));
  928. //2.规定时间内跳完所有标志块
  929. if (this.taskSignCurCount >= this.taskSignCount)
  930. this.onGameOver("skipAllFlagWithinTime");
  931. } else if (this.taskConditionPassed.isScore) {
  932. //3.达到一定分数
  933. //如果是用分数判断
  934. //分数是 跳对的加1分,错的扣1分,0不扣分。
  935. let curScore = this.eliminationCount - this.faultCount;
  936. curScore = curScore < 0 ? 0 : curScore;
  937. //当前分数达到,胜利
  938. if (curScore >= this.taskConditionPassed.limitScore)
  939. this.onGameOver("score");
  940. }
  941. },
  942. onGameOver(type) {
  943. this.isGameOver = true;
  944. //处理参数
  945. this.onClear();
  946. this.onClearData();
  947. this.bJumpPlay = false;
  948. /**
  949. * 判断胜利和失败
  950. */
  951. let myWin = false; //默认失败
  952. //比如, 1.充满左右两边蓄能槽.2.规定时间内跳完所有标志块.
  953. if (type == "energyBarFull") {
  954. //1.能量槽满的时候,说明踩中次数到达
  955. if (this.taskSignCurCount >= this.taskSignCount) {
  956. myWin = true;
  957. }
  958. } else if (type == 'skipAllFlagWithinTime') {
  959. myWin = true;
  960. } else if (type == "timeUp") {
  961. //2.规定时间内跳完所有标志块
  962. //查看消除数量是否到达总数,未达成就是未完成
  963. if (this.taskSignCurCount >= this.taskSignCount) {
  964. myWin = true;
  965. }
  966. } else if (type == "score") {
  967. myWin = true;
  968. }
  969. console.log(type, {
  970. myWin: myWin
  971. });
  972. this.$emit('gameOver', {
  973. myWin: myWin,
  974. type: 'calorieMode',
  975. isOffEvent: true
  976. });
  977. },
  978. //pk模式下结束游戏关卡
  979. onPKModeGameOver(type) {
  980. this.isGameOver = true;
  981. //处理参数
  982. this.onClear();
  983. this.onClearData();
  984. this.bJumpPlay = false;
  985. this.$emit('gameOver', {
  986. type: 'pkMode',
  987. isOffEvent: true
  988. });
  989. },
  990. setFaultCount(value) {
  991. this.tempHitCount++;
  992. this.faultCount += value;
  993. // this.faultLabel.string = '失误:' + this.faultCount;
  994. this.$emit('actionJumpDataUpdate', {
  995. eliminationCount: this.eliminationCount,
  996. faultCount: this.faultCount
  997. });
  998. this.jumpCalorie += puchConfig.getJumpCalorie(this.eliminationCount + this.faultCount);
  999. },
  1000. //控制播放
  1001. onControllerPlay() {
  1002. if (this.bJumpPlay) {
  1003. //仅仅暂停,没有清空数据
  1004. this._changePlay(false);
  1005. this.$emit("actionJumpControllerPlay", false);
  1006. } else {
  1007. this.$emit("actionJumpCheck");
  1008. }
  1009. },
  1010. onContinueGame() {
  1011. this._changePlay(true);
  1012. },
  1013. onClearActionJumpData() {
  1014. console.log("onClearActionJumpData");
  1015. this.onClear();
  1016. this.onClearData();
  1017. },
  1018. //修改状态
  1019. _changePlay(bPlaying) {
  1020. if (bPlaying) {
  1021. this.bJumpPlay = bPlaying;
  1022. } else {
  1023. this.bJumpPlay = !this.bJumpPlay;
  1024. }
  1025. },
  1026. onActionPlay() {
  1027. this.onClear();
  1028. this.onClearData();
  1029. this.startJumpGame();
  1030. this._changePlay(true);
  1031. //reset 对应计算数据
  1032. this.taskSignCurCount = 0;
  1033. this.showCurCount = 0;
  1034. this.roundingCount = 0;
  1035. this.faultCount = 0;
  1036. this.eliminationCount = 0;
  1037. },
  1038. /**
  1039. * 停止并清空数据
  1040. */
  1041. onStopAndClearAction() {
  1042. this.onClear();
  1043. this.onClearData();
  1044. this.bJumpPlay = false;
  1045. //reset 对应计算数据
  1046. this.taskSignCurCount = 0;
  1047. this.showCurCount = 0;
  1048. this.roundingCount = 0;
  1049. this.faultCount = 0;
  1050. this.eliminationCount = 0;
  1051. this.jumpCalorie = 0;
  1052. },
  1053. getCurrentJumpType() {
  1054. let _temp = this.spawnArray[2];
  1055. return _temp.jumpCode;
  1056. },
  1057. //监听跳的状态数据
  1058. listenStateDataOfJump(data) {
  1059. if (this.spawnArray.length < 3) return;
  1060. let _jumpType = this.getCurrentJumpType();
  1061. //初始全部默认状态
  1062. let _tempState = [{
  1063. jumpName: 'NORMAL',
  1064. jumpCode: 0,
  1065. bTrigger: false,
  1066. describe: '正常跳'
  1067. },
  1068. {
  1069. jumpName: 'LEFT',
  1070. jumpCode: 1,
  1071. bTrigger: false,
  1072. describe: '左直跳'
  1073. },
  1074. {
  1075. jumpName: 'RIGHT',
  1076. jumpCode: 2,
  1077. bTrigger: false,
  1078. describe: '右直跳'
  1079. },
  1080. {
  1081. jumpName: 'LEFT_ROTATE',
  1082. jumpCode: 3,
  1083. bTrigger: false,
  1084. describe: '左旋转跳'
  1085. },
  1086. {
  1087. jumpName: 'RIGHT_ROTATE',
  1088. jumpCode: 4,
  1089. bTrigger: false,
  1090. describe: '右旋转跳'
  1091. }
  1092. ];
  1093. let {
  1094. currentMaxValue,
  1095. oGyroValue,
  1096. peakOfWaveMaxValue,
  1097. valleyOfWaveMinValue
  1098. } = data
  1099. // console.log('stateDataOfJump:');
  1100. // console.log(JSON.stringify(data));
  1101. this.onLogData = data;
  1102. let _rotateLimit = 4;
  1103. let _jumpLimit = 0;
  1104. switch (_jumpType) {
  1105. case 0:
  1106. //JumpType.NORMAL = 0
  1107. _tempState[0].bTrigger = true;
  1108. this.eliminateJumpPrefabFormTemp(_tempState);
  1109. break;
  1110. case 1:
  1111. if (currentMaxValue < -_jumpLimit) {
  1112. //left jump
  1113. _tempState[1].bTrigger = true;
  1114. }
  1115. this.eliminateJumpPrefabFormTemp(_tempState);
  1116. break;
  1117. case 2:
  1118. if (currentMaxValue > _jumpLimit) {
  1119. //right jump
  1120. _tempState[2].bTrigger = true;
  1121. }
  1122. this.eliminateJumpPrefabFormTemp(_tempState);
  1123. break;
  1124. case 4:
  1125. if (oGyroValue > _rotateLimit) {
  1126. _tempState[4].bTrigger = true;
  1127. }
  1128. this.eliminateJumpPrefabFormTemp(_tempState);
  1129. break;
  1130. case 3:
  1131. if (oGyroValue < -_rotateLimit) {
  1132. _tempState[3].bTrigger = true;
  1133. }
  1134. this.eliminateJumpPrefabFormTemp(_tempState);
  1135. break;
  1136. default:
  1137. console.log('没有对应的_jumpType', _jumpType);
  1138. break;
  1139. }
  1140. },
  1141. eliminateJumpPrefabFormTemp(_tempState) {
  1142. //只触发第三个
  1143. if (this.spawnArray.length < 3) {
  1144. return;
  1145. }
  1146. let _temp = this.spawnArray[2];
  1147. let bSuccess = false;
  1148. for (let i = 0; i < _tempState.length; i++) {
  1149. let _state = _tempState[i];
  1150. if (_state.bTrigger) {
  1151. console.log(this.eliminationCount + ',识别跳的类型:' + _state.describe + ',当前预制类型:' + _temp
  1152. .jumpName +
  1153. "\n直跳判断值:" + this.onLogData.currentMaxValue + ",旋转跳值:" + this.onLogData.oGyroValue);
  1154. }
  1155. //如果当前的跳类型和预制目标一样
  1156. if (_state.jumpCode == _temp.jumpCode && _state.bTrigger) {
  1157. //成功
  1158. bSuccess = true;
  1159. break;
  1160. }
  1161. }
  1162. //如果存在其中一个为true
  1163. if (bSuccess) {
  1164. _temp.bTrigger = true;
  1165. this.canSpawnTemp = _temp;
  1166. setTimeout(() => {
  1167. //这里更新特效
  1168. this.onDrawEffect(this.canSpawnTemp);
  1169. }, 150);
  1170. this.deleteSpawn = this.spawnArray.splice(0, 1);
  1171. if (this.index < this.templatePool.length) {
  1172. this.spawnArray.push(this.templatePool[this.index]);
  1173. this.index++;
  1174. }
  1175. //成功
  1176. this.setEliminationCount(1);
  1177. //替换数组
  1178. // console.log(this.index + " == " + this.spawnArray.length);
  1179. if (this.spawnArray.length < 3 && this.index > 3) {
  1180. clearInterval(this.countdownInterval);
  1181. this.countdownInterval = null;
  1182. //绘制新触发状态
  1183. this.canGoNext = true;
  1184. } else {
  1185. //绘制新触发状态
  1186. this.canOnDraw = true;
  1187. }
  1188. } else {
  1189. //失误
  1190. this.setFaultCount(1);
  1191. }
  1192. },
  1193. /**
  1194. * @param {Object} gameData
  1195. * 识别跳部分数据处理
  1196. */
  1197. onBLEHitUpdate(gameData) {
  1198. // console.log("gameData:", gameData);
  1199. if (!this.bJumpPlay || this.isGameOver || this.spawnAnimation != null) return;
  1200. // if (curAngleCeil < 30) {
  1201. // directionPunch = "straightPunch";
  1202. // name = "正向的直拳";
  1203. // ename = "front-straight";
  1204. // } else if (direction.x < 0) {
  1205. // directionPunch = "rightPunch";
  1206. // name = "正向的右拳";
  1207. // ename = "front-right";
  1208. // } else if (direction.x > 0) {
  1209. // directionPunch = "leftPunch";
  1210. // name = "正向的左拳";
  1211. // ename = "front-left";
  1212. // }
  1213. if (gameData.direction == "straightPunch") {
  1214. this.eliminateJumpPrefab(0);
  1215. } else if (gameData.direction == "leftPunch") {
  1216. this.eliminateJumpPrefab(1);
  1217. } else if (gameData.direction == "rightPunch") {
  1218. this.eliminateJumpPrefab(2);
  1219. }
  1220. this.BLEAccIndex++;
  1221. },
  1222. onClearData() {
  1223. this.BLEAccIndex = 0;
  1224. },
  1225. onChangeY() {
  1226. this.isY = true;
  1227. },
  1228. onChangeX() {
  1229. this.isY = false;
  1230. },
  1231. onGetActionJumpPlayView(callback) {
  1232. let view = uni.createSelectorQuery().select('#ActionJumpPlay');
  1233. view.boundingClientRect(data => {
  1234. if (callback)
  1235. callback(data);
  1236. }).exec();
  1237. },
  1238. onTipLevel() {
  1239. this.$emit("tipLevel", {
  1240. hiddenType: 'normal'
  1241. });
  1242. console.log("**************22");
  1243. }
  1244. }
  1245. }
  1246. </script>
  1247. <style lang="scss">
  1248. .mid-absolute {
  1249. position: absolute;
  1250. top: 0;
  1251. bottom: 0;
  1252. right: 0;
  1253. left: 0;
  1254. margin: auto;
  1255. }
  1256. .action-jump-timer {
  1257. position: absolute;
  1258. top: -150rpx;
  1259. }
  1260. .grid-progress-vertical-container {
  1261. min-height: 376rpx;
  1262. }
  1263. .grid-progress-vertical-bar {
  1264. max-height: 376rpx;
  1265. }
  1266. .grid-progress-vertical-child {
  1267. width: 35px;
  1268. height: 7.36px;
  1269. margin: 7.36px 0 0 0;
  1270. position: relative;
  1271. }
  1272. .grid-progress-vertical-active {
  1273. width: 28rpx;
  1274. }
  1275. .grid-progress-vertical-inactive {
  1276. width: 28rpx;
  1277. }
  1278. .sprite-yellow-arrow {
  1279. display: inline-block;
  1280. overflow: hidden;
  1281. background-repeat: no-repeat;
  1282. width: 194px;
  1283. height: 232px;
  1284. background-image: url('@/static/modal/action-jump/yellow-arrow.png');
  1285. // border: 1rpx solid #00CE47;
  1286. }
  1287. .animation-play-state-play {
  1288. animation: yellowArrowRun 1s steps(1, end); // infinite
  1289. animation-play-state: running;
  1290. }
  1291. .animation-play-state-paused {
  1292. animation-play-state: paused;
  1293. }
  1294. /**
  1295. * 箭头动画
  1296. */
  1297. @keyframes yellowArrowRun {
  1298. 0% {
  1299. background-position: -0px -0px;
  1300. }
  1301. 5% {
  1302. background-position: -0px -0px;
  1303. }
  1304. 10% {
  1305. background-position: -194px -0px;
  1306. }
  1307. 15% {
  1308. background-position: -388px -0px;
  1309. }
  1310. 20% {
  1311. background-position: -582px -0px;
  1312. }
  1313. 25% {
  1314. background-position: -776px -0px;
  1315. }
  1316. 30% {
  1317. background-position: -0px -232px;
  1318. }
  1319. 35% {
  1320. background-position: -194px -232px;
  1321. }
  1322. 40% {
  1323. background-position: -388px -232px;
  1324. }
  1325. 45% {
  1326. background-position: -582px -232px;
  1327. }
  1328. 50% {
  1329. background-position: -776px -232px;
  1330. }
  1331. 55% {
  1332. background-position: -0px -464px;
  1333. }
  1334. 60% {
  1335. background-position: -194px -464px;
  1336. }
  1337. 65% {
  1338. background-position: -388px -464px;
  1339. }
  1340. 70% {
  1341. background-position: -582px -464px;
  1342. }
  1343. 75% {
  1344. background-position: -776px -464px;
  1345. }
  1346. 80% {
  1347. background-position: -0px -696px;
  1348. }
  1349. 85% {
  1350. background-position: -194px -696px;
  1351. }
  1352. 90% {
  1353. background-position: -388px -696px;
  1354. }
  1355. 95% {
  1356. background-position: -582px -696px;
  1357. }
  1358. 100% {
  1359. background-position: -776px -696px;
  1360. }
  1361. }
  1362. .sprite-rightToLeftArrow {
  1363. display: inline-block;
  1364. overflow: hidden;
  1365. background-repeat: no-repeat;
  1366. width: 317px;
  1367. height: 42px;
  1368. background-image: url('@/static/modal/action-jump/rightToLeftArrow.png');
  1369. // border: 1rpx solid #00CE47;
  1370. }
  1371. .sprite-rightToLeftArrow-play {
  1372. animation: rightToLeftArrowRun 1s steps(1, end) infinite;
  1373. }
  1374. @keyframes rightToLeftArrowRun {
  1375. 0% {
  1376. background-position: -0px -0px;
  1377. }
  1378. 3.33% {
  1379. background-position: -0px -0px;
  1380. }
  1381. 6.66% {
  1382. background-position: -317px -0px;
  1383. }
  1384. 9.99% {
  1385. background-position: -0px -42px;
  1386. }
  1387. 13.33% {
  1388. background-position: -317px -42px;
  1389. }
  1390. 16.66% {
  1391. background-position: -0px -84px;
  1392. }
  1393. 19.99% {
  1394. background-position: -317px -84px;
  1395. }
  1396. 23.33% {
  1397. background-position: -0px -126px;
  1398. }
  1399. 26.66% {
  1400. background-position: -317px -126px;
  1401. }
  1402. 29.99% {
  1403. background-position: -0px -168px;
  1404. }
  1405. 33.33% {
  1406. background-position: -317px -168px;
  1407. }
  1408. 36.66% {
  1409. background-position: -0px -210px;
  1410. }
  1411. 39.99% {
  1412. background-position: -317px -210px;
  1413. }
  1414. 43.33% {
  1415. background-position: -0px -252px;
  1416. }
  1417. 46.66% {
  1418. background-position: -317px -252px;
  1419. }
  1420. 49.99% {
  1421. background-position: -0px -294px;
  1422. }
  1423. 53.33% {
  1424. background-position: -317px -294px;
  1425. }
  1426. 56.66% {
  1427. background-position: -0px -336px;
  1428. }
  1429. 59.99% {
  1430. background-position: -317px -336px;
  1431. }
  1432. 63.33% {
  1433. background-position: -0px -378px;
  1434. }
  1435. 66.66% {
  1436. background-position: -317px -378px;
  1437. }
  1438. 69.99% {
  1439. background-position: -0px -420px;
  1440. }
  1441. 73.33% {
  1442. background-position: -317px -420px;
  1443. }
  1444. 76.66% {
  1445. background-position: -0px -462px;
  1446. }
  1447. 79.99% {
  1448. background-position: -317px -462px;
  1449. }
  1450. 83.33% {
  1451. background-position: -0px -504px;
  1452. }
  1453. 86.66% {
  1454. background-position: -317px -504px;
  1455. }
  1456. 89.99% {
  1457. background-position: -0px -546px;
  1458. }
  1459. 93.33% {
  1460. background-position: -317px -546px;
  1461. }
  1462. 96.66% {
  1463. background-position: -0px -588px;
  1464. }
  1465. 100% {
  1466. background-position: -317px -588px;
  1467. }
  1468. }
  1469. </style>