|
@@ -432,7 +432,9 @@
|
|
|
},
|
|
|
beforeDestroy() {},
|
|
|
methods: {
|
|
|
- ...mapMutations(['onWriteBLEConnectionValue', 'onConvertDeviceData', "onSendSocketMessage"]),
|
|
|
+ ...mapMutations(['onWriteBLEConnectionValue', 'onConvertDeviceData', "onSendSocketMessage",
|
|
|
+ 'jumpIdenModule_onJump6AxisDataUpdate'
|
|
|
+ ]),
|
|
|
//更新新手状态提示
|
|
|
onUpdateTipLevelValue(value) {
|
|
|
this.bTipLevel = value;
|
|
@@ -440,44 +442,44 @@
|
|
|
onListenActionJump() {
|
|
|
let _self = this;
|
|
|
console.log("*****************onListenActionHit*****************************");
|
|
|
- _self.actionJumpObj = new ActionJump();
|
|
|
- _self.actionJumpObj.addEventListener('resultant', (e) => {
|
|
|
- if (e.type == 'stateDataOfJump') {
|
|
|
- //发送给game,在game里面处理判断
|
|
|
- this.listenStateDataOfJump(e);
|
|
|
- } else if (e.type == 'stop') {
|
|
|
- console.log("stop");
|
|
|
- this.onClearData();
|
|
|
- if (this.canOnDraw) {
|
|
|
- this.canOnDraw = false;
|
|
|
- // //这里更新特效
|
|
|
- // this.onDrawEffect(this.canSpawnTemp);
|
|
|
- this.onDraw("tipHit", true);
|
|
|
- }
|
|
|
- if (this.canGoNext) {
|
|
|
- this.canGoNext = false;
|
|
|
- // //这里更新特效
|
|
|
- // this.onDrawEffect(this.canSpawnTemp);
|
|
|
- //绘制新触发状态
|
|
|
- this.onDraw("normal", false);
|
|
|
- setTimeout(() => {
|
|
|
- this.startJumpGame();
|
|
|
- }, 500)
|
|
|
- }
|
|
|
- // console.log('stop');
|
|
|
- //这里处理生成下一个
|
|
|
- } else if (e.type == 'log') {
|
|
|
- if (e.logType == 'normal') {
|
|
|
- console.log(e.data);
|
|
|
- } else if (e.logType == 'error') {
|
|
|
- console.error(e.data);
|
|
|
- } else if (e.logType == 'warn') {
|
|
|
- console.warn(e.data);
|
|
|
- } else if (e.logType == 'socket') {
|
|
|
- this.onSendSocketMessage(e.data);
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ // _self.actionJumpObj = new ActionJump();
|
|
|
+ // _self.actionJumpObj.addEventListener('resultant', (e) => {
|
|
|
+ // if (e.type == 'stateDataOfJump') {
|
|
|
+ // //发送给game,在game里面处理判断
|
|
|
+ // this.listenStateDataOfJump(e);
|
|
|
+ // } else if (e.type == 'stop') {
|
|
|
+ // console.log("stop");
|
|
|
+ // this.onClearData();
|
|
|
+ // if (this.canOnDraw) {
|
|
|
+ // this.canOnDraw = false;
|
|
|
+ // // //这里更新特效
|
|
|
+ // // this.onDrawEffect(this.canSpawnTemp);
|
|
|
+ // this.onDraw("tipHit", true);
|
|
|
+ // }
|
|
|
+ // if (this.canGoNext) {
|
|
|
+ // this.canGoNext = false;
|
|
|
+ // // //这里更新特效
|
|
|
+ // // this.onDrawEffect(this.canSpawnTemp);
|
|
|
+ // //绘制新触发状态
|
|
|
+ // this.onDraw("normal", false);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.startJumpGame();
|
|
|
+ // }, 500)
|
|
|
+ // }
|
|
|
+ // // console.log('stop');
|
|
|
+ // //这里处理生成下一个
|
|
|
+ // } else if (e.type == 'log') {
|
|
|
+ // if (e.logType == 'normal') {
|
|
|
+ // console.log(e.data);
|
|
|
+ // } else if (e.logType == 'error') {
|
|
|
+ // console.error(e.data);
|
|
|
+ // } else if (e.logType == 'warn') {
|
|
|
+ // console.warn(e.data);
|
|
|
+ // } else if (e.logType == 'socket') {
|
|
|
+ // this.onSendSocketMessage(e.data);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
//load 相关图片
|
|
|
onLoadImage() {
|
|
@@ -1361,6 +1363,89 @@
|
|
|
// this.eliminateJumpPrefabFormTemp(_tempState);
|
|
|
// }
|
|
|
},
|
|
|
+
|
|
|
+ //监听跳的状态数据
|
|
|
+ jumpIdenModule_listenStateDataOfJump(data) {
|
|
|
+
|
|
|
+ console.log(JSON.stringify(data));
|
|
|
+ if (this.spawnArray.length < 3) return;
|
|
|
+ let _jumpType = this.getCurrentJumpType();
|
|
|
+ //初始全部默认状态
|
|
|
+ let _tempState = [{
|
|
|
+ jumpName: 'NORMAL',
|
|
|
+ jumpCode: 0,
|
|
|
+ bTrigger: false,
|
|
|
+ describe: '正常跳'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ jumpName: 'LEFT',
|
|
|
+ jumpCode: 1,
|
|
|
+ bTrigger: false,
|
|
|
+ describe: '左直跳'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ jumpName: 'RIGHT',
|
|
|
+ jumpCode: 2,
|
|
|
+ bTrigger: false,
|
|
|
+ describe: '右直跳'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ jumpName: 'LEFT_ROTATE',
|
|
|
+ jumpCode: 3,
|
|
|
+ bTrigger: false,
|
|
|
+ describe: '左旋转跳'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ jumpName: 'RIGHT_ROTATE',
|
|
|
+ jumpCode: 4,
|
|
|
+ bTrigger: false,
|
|
|
+ describe: '右旋转跳'
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ let _rotateLimit = 4;
|
|
|
+ let _jumpLimit = 0;
|
|
|
+
|
|
|
+ switch (_jumpType) {
|
|
|
+ case 0:
|
|
|
+ //JumpType.NORMAL = 0
|
|
|
+ if (data.tag === 0) {
|
|
|
+ _tempState[0].bTrigger = true;
|
|
|
+ }
|
|
|
+ this.eliminateJumpPrefabFormTemp(_tempState);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ if (data.tag === 2) {
|
|
|
+ //left jump
|
|
|
+ _tempState[1].bTrigger = true;
|
|
|
+ }
|
|
|
+ this.eliminateJumpPrefabFormTemp(_tempState);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (data.tag === 1) {
|
|
|
+ //right jump
|
|
|
+ _tempState[2].bTrigger = true;
|
|
|
+ }
|
|
|
+ this.eliminateJumpPrefabFormTemp(_tempState);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ if (data.tag === 3) {
|
|
|
+ _tempState[4].bTrigger = true;
|
|
|
+ }
|
|
|
+ this.eliminateJumpPrefabFormTemp(_tempState);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if (data.tag === 4) {
|
|
|
+ _tempState[3].bTrigger = true;
|
|
|
+ }
|
|
|
+ this.eliminateJumpPrefabFormTemp(_tempState);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ console.log('没有对应的_jumpType', _jumpType);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
eliminateJumpPrefabFormTemp(_tempState) {
|
|
|
//只触发第三个
|
|
|
if (this.spawnArray.length < 3) {
|
|
@@ -1397,16 +1482,32 @@
|
|
|
}
|
|
|
//成功
|
|
|
this.setEliminationCount(1);
|
|
|
+
|
|
|
+ //去除原本算法后添加 start
|
|
|
+ console.log("stop");
|
|
|
+ this.onClearData();
|
|
|
+ //去除原本算法后添加 end
|
|
|
//替换数组
|
|
|
// console.log(this.index + " == " + this.spawnArray.length);
|
|
|
if (this.spawnArray.length < 3 && this.index > 3) {
|
|
|
clearInterval(this.countdownInterval);
|
|
|
this.countdownInterval = null;
|
|
|
//绘制新触发状态
|
|
|
- this.canGoNext = true;
|
|
|
+ //this.canGoNext = true; //去除jumpAction注销
|
|
|
+
|
|
|
+ //去除原本算法后添加 start
|
|
|
+ this.onDraw("normal", false);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.startJumpGame();
|
|
|
+ }, 500)
|
|
|
+ //去除原本算法后添加 end
|
|
|
} else {
|
|
|
//绘制新触发状态
|
|
|
- this.canOnDraw = true;
|
|
|
+ // this.canOnDraw = true; //去除jumpAction注销
|
|
|
+
|
|
|
+ //去除原本算法后添加 start
|
|
|
+ this.onDraw("tipHit", true);
|
|
|
+ //去除原本算法后添加 end
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -1425,6 +1526,26 @@
|
|
|
onBLERopeUpdate(gameData) {
|
|
|
if (!this.bJumpPlay || this.isGameOver || this.spawnAnimation != null) return;
|
|
|
|
|
|
+
|
|
|
+ //调用识别算法
|
|
|
+ this.jumpIdenModule_onJump6AxisDataUpdate({
|
|
|
+ data: {
|
|
|
+ hex: gameData.hex
|
|
|
+ },
|
|
|
+ callback: (res) => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ if (res.tag != -1) {
|
|
|
+ this.jumpIdenModule_listenStateDataOfJump(res);
|
|
|
+ uni.showToast({
|
|
|
+ title: res.tag + ',' + res.msg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1000,
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
//********陀螺仪角速度********
|
|
|
let {
|
|
|
gx,
|
|
@@ -1454,36 +1575,36 @@
|
|
|
let linear_acceleration_y = _az - this.zA;
|
|
|
let linear_acceleration_z = _ay - this.yA;
|
|
|
|
|
|
- let _temp = {
|
|
|
- linearAcc: {
|
|
|
- lAccX: linear_acceleration_x,
|
|
|
- lAccY: linear_acceleration_y,
|
|
|
- lAccZ: linear_acceleration_z
|
|
|
- }, //gameData.acc,
|
|
|
- oriAcc: {
|
|
|
- oAccX: _ax,
|
|
|
- oAccY: _ay,
|
|
|
- oAccZ: _az
|
|
|
- },
|
|
|
- gravityAcc: {
|
|
|
- gravityX: this.xA,
|
|
|
- gravityY: this.yA,
|
|
|
- gravityZ: this.zA
|
|
|
- },
|
|
|
- bLimitRebound: false,
|
|
|
- resultant: Math.sqrt(_ax * _ax +
|
|
|
- _ay * _ay + _az * _az),
|
|
|
- runIndex: this.BLEAccIndex,
|
|
|
- //陀螺仪
|
|
|
- oriGyro: {
|
|
|
- oGyroX: gx,
|
|
|
- oGyroY: gy,
|
|
|
- oGyroZ: gz
|
|
|
- },
|
|
|
- //输入当前轴,旧设备使用Y轴,即为true
|
|
|
- bYAxis: this.bOldDeviceType ? true : false,
|
|
|
- };
|
|
|
- this.actionJumpObj.updateJump(_temp);
|
|
|
+ // let _temp = {
|
|
|
+ // linearAcc: {
|
|
|
+ // lAccX: linear_acceleration_x,
|
|
|
+ // lAccY: linear_acceleration_y,
|
|
|
+ // lAccZ: linear_acceleration_z
|
|
|
+ // }, //gameData.acc,
|
|
|
+ // oriAcc: {
|
|
|
+ // oAccX: _ax,
|
|
|
+ // oAccY: _ay,
|
|
|
+ // oAccZ: _az
|
|
|
+ // },
|
|
|
+ // gravityAcc: {
|
|
|
+ // gravityX: this.xA,
|
|
|
+ // gravityY: this.yA,
|
|
|
+ // gravityZ: this.zA
|
|
|
+ // },
|
|
|
+ // bLimitRebound: false,
|
|
|
+ // resultant: Math.sqrt(_ax * _ax +
|
|
|
+ // _ay * _ay + _az * _az),
|
|
|
+ // runIndex: this.BLEAccIndex,
|
|
|
+ // //陀螺仪
|
|
|
+ // oriGyro: {
|
|
|
+ // oGyroX: gx,
|
|
|
+ // oGyroY: gy,
|
|
|
+ // oGyroZ: gz
|
|
|
+ // },
|
|
|
+ // //输入当前轴,旧设备使用Y轴,即为true
|
|
|
+ // bYAxis: this.bOldDeviceType ? true : false,
|
|
|
+ // };
|
|
|
+ //this.actionJumpObj.updateJump(_temp);
|
|
|
this.BLEAccIndex++;
|
|
|
},
|
|
|
onClearData() {
|