action-hit.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650
  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(['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 && 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. } 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. console.log("onControllerPlay:",this.bJumpPlay)
  1003. if (this.bJumpPlay) {
  1004. //仅仅暂停,没有清空数据
  1005. this._changePlay(false);
  1006. this.$emit("actionJumpControllerPlay", false);
  1007. } else {
  1008. this.$emit("actionJumpCheck",{
  1009. bStartCountDown: true
  1010. });
  1011. }
  1012. },
  1013. onContinueGame() {
  1014. this._changePlay(true);
  1015. },
  1016. onClearActionJumpData() {
  1017. console.log("onClearActionJumpData");
  1018. this.onClear();
  1019. this.onClearData();
  1020. },
  1021. //修改状态
  1022. _changePlay(bPlaying) {
  1023. if (bPlaying) {
  1024. this.bJumpPlay = bPlaying;
  1025. } else {
  1026. this.bJumpPlay = !this.bJumpPlay;
  1027. }
  1028. },
  1029. onActionPlay() {
  1030. this.onClear();
  1031. this.onClearData();
  1032. this.startJumpGame();
  1033. this._changePlay(true);
  1034. console.log("onActionPlay:",this.bJumpPlay)
  1035. //reset 对应计算数据
  1036. this.taskSignCurCount = 0;
  1037. this.showCurCount = 0;
  1038. this.roundingCount = 0;
  1039. this.faultCount = 0;
  1040. this.eliminationCount = 0;
  1041. },
  1042. /**
  1043. * 停止并清空数据
  1044. */
  1045. onStopAndClearAction() {
  1046. console.log("onStopAndClearAction")
  1047. this.onClear();
  1048. this.onClearData();
  1049. this.bJumpPlay = false;
  1050. //reset 对应计算数据
  1051. this.taskSignCurCount = 0;
  1052. this.showCurCount = 0;
  1053. this.roundingCount = 0;
  1054. this.faultCount = 0;
  1055. this.eliminationCount = 0;
  1056. this.jumpCalorie = 0;
  1057. },
  1058. getCurrentJumpType() {
  1059. let _temp = this.spawnArray[2];
  1060. return _temp.jumpCode;
  1061. },
  1062. //监听跳的状态数据
  1063. listenStateDataOfJump(data) {
  1064. if (this.spawnArray.length < 3) return;
  1065. let _jumpType = this.getCurrentJumpType();
  1066. //初始全部默认状态
  1067. let _tempState = [{
  1068. jumpName: 'NORMAL',
  1069. jumpCode: 0,
  1070. bTrigger: false,
  1071. describe: '正常跳'
  1072. },
  1073. {
  1074. jumpName: 'LEFT',
  1075. jumpCode: 1,
  1076. bTrigger: false,
  1077. describe: '左直跳'
  1078. },
  1079. {
  1080. jumpName: 'RIGHT',
  1081. jumpCode: 2,
  1082. bTrigger: false,
  1083. describe: '右直跳'
  1084. },
  1085. {
  1086. jumpName: 'LEFT_ROTATE',
  1087. jumpCode: 3,
  1088. bTrigger: false,
  1089. describe: '左旋转跳'
  1090. },
  1091. {
  1092. jumpName: 'RIGHT_ROTATE',
  1093. jumpCode: 4,
  1094. bTrigger: false,
  1095. describe: '右旋转跳'
  1096. }
  1097. ];
  1098. let {
  1099. currentMaxValue,
  1100. oGyroValue,
  1101. peakOfWaveMaxValue,
  1102. valleyOfWaveMinValue
  1103. } = data
  1104. // console.log('stateDataOfJump:');
  1105. // console.log(JSON.stringify(data));
  1106. this.onLogData = data;
  1107. let _rotateLimit = 4;
  1108. let _jumpLimit = 0;
  1109. switch (_jumpType) {
  1110. case 0:
  1111. //JumpType.NORMAL = 0
  1112. _tempState[0].bTrigger = true;
  1113. this.eliminateJumpPrefabFormTemp(_tempState);
  1114. break;
  1115. case 1:
  1116. if (currentMaxValue < -_jumpLimit) {
  1117. //left jump
  1118. _tempState[1].bTrigger = true;
  1119. }
  1120. this.eliminateJumpPrefabFormTemp(_tempState);
  1121. break;
  1122. case 2:
  1123. if (currentMaxValue > _jumpLimit) {
  1124. //right jump
  1125. _tempState[2].bTrigger = true;
  1126. }
  1127. this.eliminateJumpPrefabFormTemp(_tempState);
  1128. break;
  1129. case 4:
  1130. if (oGyroValue > _rotateLimit) {
  1131. _tempState[4].bTrigger = true;
  1132. }
  1133. this.eliminateJumpPrefabFormTemp(_tempState);
  1134. break;
  1135. case 3:
  1136. if (oGyroValue < -_rotateLimit) {
  1137. _tempState[3].bTrigger = true;
  1138. }
  1139. this.eliminateJumpPrefabFormTemp(_tempState);
  1140. break;
  1141. default:
  1142. console.log('没有对应的_jumpType', _jumpType);
  1143. break;
  1144. }
  1145. },
  1146. eliminateJumpPrefabFormTemp(_tempState) {
  1147. //只触发第三个
  1148. if (this.spawnArray.length < 3) {
  1149. return;
  1150. }
  1151. let _temp = this.spawnArray[2];
  1152. let bSuccess = false;
  1153. for (let i = 0; i < _tempState.length; i++) {
  1154. let _state = _tempState[i];
  1155. if (_state.bTrigger) {
  1156. console.log(this.eliminationCount + ',识别跳的类型:' + _state.describe + ',当前预制类型:' + _temp
  1157. .jumpName +
  1158. "\n直跳判断值:" + this.onLogData.currentMaxValue + ",旋转跳值:" + this.onLogData.oGyroValue);
  1159. }
  1160. //如果当前的跳类型和预制目标一样
  1161. if (_state.jumpCode == _temp.jumpCode && _state.bTrigger) {
  1162. //成功
  1163. bSuccess = true;
  1164. break;
  1165. }
  1166. }
  1167. //如果存在其中一个为true
  1168. if (bSuccess) {
  1169. _temp.bTrigger = true;
  1170. this.canSpawnTemp = _temp;
  1171. setTimeout(() => {
  1172. //这里更新特效
  1173. this.onDrawEffect(this.canSpawnTemp);
  1174. }, 150);
  1175. this.deleteSpawn = this.spawnArray.splice(0, 1);
  1176. if (this.index < this.templatePool.length) {
  1177. this.spawnArray.push(this.templatePool[this.index]);
  1178. this.index++;
  1179. }
  1180. //成功
  1181. this.setEliminationCount(1);
  1182. //替换数组
  1183. // console.log(this.index + " == " + this.spawnArray.length);
  1184. if (this.spawnArray.length < 3 && this.index > 3) {
  1185. clearInterval(this.countdownInterval);
  1186. this.countdownInterval = null;
  1187. //绘制新触发状态
  1188. this.canGoNext = true;
  1189. } else {
  1190. //绘制新触发状态
  1191. this.canOnDraw = true;
  1192. }
  1193. } else {
  1194. //失误
  1195. this.setFaultCount(1);
  1196. }
  1197. },
  1198. /**
  1199. * @param {Object} gameData
  1200. * 识别跳部分数据处理
  1201. */
  1202. onBLEHitUpdate(gameData) {
  1203. // console.log("gameData:", gameData);
  1204. if (!this.bJumpPlay || this.isGameOver || this.spawnAnimation != null) return;
  1205. // if (curAngleCeil < 30) {
  1206. // directionPunch = "straightPunch";
  1207. // name = "正向的直拳";
  1208. // ename = "front-straight";
  1209. // } else if (direction.x < 0) {
  1210. // directionPunch = "rightPunch";
  1211. // name = "正向的右拳";
  1212. // ename = "front-right";
  1213. // } else if (direction.x > 0) {
  1214. // directionPunch = "leftPunch";
  1215. // name = "正向的左拳";
  1216. // ename = "front-left";
  1217. // }
  1218. if (gameData.direction == "straightPunch") {
  1219. this.eliminateJumpPrefab(0);
  1220. } else if (gameData.direction == "leftPunch") {
  1221. this.eliminateJumpPrefab(1);
  1222. } else if (gameData.direction == "rightPunch") {
  1223. this.eliminateJumpPrefab(2);
  1224. }
  1225. this.BLEAccIndex++;
  1226. },
  1227. onClearData() {
  1228. this.BLEAccIndex = 0;
  1229. },
  1230. onChangeY() {
  1231. this.isY = true;
  1232. },
  1233. onChangeX() {
  1234. this.isY = false;
  1235. },
  1236. onGetActionJumpPlayView(callback) {
  1237. let view = uni.createSelectorQuery().select('#ActionJumpPlay');
  1238. view.boundingClientRect(data => {
  1239. if (callback)
  1240. callback(data);
  1241. }).exec();
  1242. },
  1243. onTipLevel() {
  1244. this.$emit("tipLevel", {
  1245. hiddenType: 'normal'
  1246. });
  1247. console.log("**************22");
  1248. }
  1249. }
  1250. }
  1251. </script>
  1252. <style lang="scss">
  1253. .mid-absolute {
  1254. position: absolute;
  1255. top: 0;
  1256. bottom: 0;
  1257. right: 0;
  1258. left: 0;
  1259. margin: auto;
  1260. }
  1261. .action-jump-timer {
  1262. position: absolute;
  1263. top: -150rpx;
  1264. }
  1265. .grid-progress-vertical-container {
  1266. min-height: 376rpx;
  1267. }
  1268. .grid-progress-vertical-bar {
  1269. max-height: 376rpx;
  1270. }
  1271. .grid-progress-vertical-child {
  1272. width: 35px;
  1273. height: 7.36px;
  1274. margin: 7.36px 0 0 0;
  1275. position: relative;
  1276. }
  1277. .grid-progress-vertical-active {
  1278. width: 28rpx;
  1279. }
  1280. .grid-progress-vertical-inactive {
  1281. width: 28rpx;
  1282. }
  1283. .sprite-yellow-arrow {
  1284. display: inline-block;
  1285. overflow: hidden;
  1286. background-repeat: no-repeat;
  1287. width: 194px;
  1288. height: 232px;
  1289. background-image: url('@/static/modal/action-jump/yellow-arrow.png');
  1290. // border: 1rpx solid #00CE47;
  1291. }
  1292. .animation-play-state-play {
  1293. animation: yellowArrowRun 1s steps(1, end); // infinite
  1294. animation-play-state: running;
  1295. }
  1296. .animation-play-state-paused {
  1297. animation-play-state: paused;
  1298. }
  1299. /**
  1300. * 箭头动画
  1301. */
  1302. @keyframes yellowArrowRun {
  1303. 0% {
  1304. background-position: -0px -0px;
  1305. }
  1306. 5% {
  1307. background-position: -0px -0px;
  1308. }
  1309. 10% {
  1310. background-position: -194px -0px;
  1311. }
  1312. 15% {
  1313. background-position: -388px -0px;
  1314. }
  1315. 20% {
  1316. background-position: -582px -0px;
  1317. }
  1318. 25% {
  1319. background-position: -776px -0px;
  1320. }
  1321. 30% {
  1322. background-position: -0px -232px;
  1323. }
  1324. 35% {
  1325. background-position: -194px -232px;
  1326. }
  1327. 40% {
  1328. background-position: -388px -232px;
  1329. }
  1330. 45% {
  1331. background-position: -582px -232px;
  1332. }
  1333. 50% {
  1334. background-position: -776px -232px;
  1335. }
  1336. 55% {
  1337. background-position: -0px -464px;
  1338. }
  1339. 60% {
  1340. background-position: -194px -464px;
  1341. }
  1342. 65% {
  1343. background-position: -388px -464px;
  1344. }
  1345. 70% {
  1346. background-position: -582px -464px;
  1347. }
  1348. 75% {
  1349. background-position: -776px -464px;
  1350. }
  1351. 80% {
  1352. background-position: -0px -696px;
  1353. }
  1354. 85% {
  1355. background-position: -194px -696px;
  1356. }
  1357. 90% {
  1358. background-position: -388px -696px;
  1359. }
  1360. 95% {
  1361. background-position: -582px -696px;
  1362. }
  1363. 100% {
  1364. background-position: -776px -696px;
  1365. }
  1366. }
  1367. .sprite-rightToLeftArrow {
  1368. display: inline-block;
  1369. overflow: hidden;
  1370. background-repeat: no-repeat;
  1371. width: 317px;
  1372. height: 42px;
  1373. background-image: url('@/static/modal/action-jump/rightToLeftArrow.png');
  1374. // border: 1rpx solid #00CE47;
  1375. }
  1376. .sprite-rightToLeftArrow-play {
  1377. animation: rightToLeftArrowRun 1s steps(1, end) infinite;
  1378. }
  1379. @keyframes rightToLeftArrowRun {
  1380. 0% {
  1381. background-position: -0px -0px;
  1382. }
  1383. 3.33% {
  1384. background-position: -0px -0px;
  1385. }
  1386. 6.66% {
  1387. background-position: -317px -0px;
  1388. }
  1389. 9.99% {
  1390. background-position: -0px -42px;
  1391. }
  1392. 13.33% {
  1393. background-position: -317px -42px;
  1394. }
  1395. 16.66% {
  1396. background-position: -0px -84px;
  1397. }
  1398. 19.99% {
  1399. background-position: -317px -84px;
  1400. }
  1401. 23.33% {
  1402. background-position: -0px -126px;
  1403. }
  1404. 26.66% {
  1405. background-position: -317px -126px;
  1406. }
  1407. 29.99% {
  1408. background-position: -0px -168px;
  1409. }
  1410. 33.33% {
  1411. background-position: -317px -168px;
  1412. }
  1413. 36.66% {
  1414. background-position: -0px -210px;
  1415. }
  1416. 39.99% {
  1417. background-position: -317px -210px;
  1418. }
  1419. 43.33% {
  1420. background-position: -0px -252px;
  1421. }
  1422. 46.66% {
  1423. background-position: -317px -252px;
  1424. }
  1425. 49.99% {
  1426. background-position: -0px -294px;
  1427. }
  1428. 53.33% {
  1429. background-position: -317px -294px;
  1430. }
  1431. 56.66% {
  1432. background-position: -0px -336px;
  1433. }
  1434. 59.99% {
  1435. background-position: -317px -336px;
  1436. }
  1437. 63.33% {
  1438. background-position: -0px -378px;
  1439. }
  1440. 66.66% {
  1441. background-position: -317px -378px;
  1442. }
  1443. 69.99% {
  1444. background-position: -0px -420px;
  1445. }
  1446. 73.33% {
  1447. background-position: -317px -420px;
  1448. }
  1449. 76.66% {
  1450. background-position: -0px -462px;
  1451. }
  1452. 79.99% {
  1453. background-position: -317px -462px;
  1454. }
  1455. 83.33% {
  1456. background-position: -0px -504px;
  1457. }
  1458. 86.66% {
  1459. background-position: -317px -504px;
  1460. }
  1461. 89.99% {
  1462. background-position: -0px -546px;
  1463. }
  1464. 93.33% {
  1465. background-position: -317px -546px;
  1466. }
  1467. 96.66% {
  1468. background-position: -0px -588px;
  1469. }
  1470. 100% {
  1471. background-position: -317px -588px;
  1472. }
  1473. }
  1474. </style>