Selaa lähdekoodia

1.修改版本,
2.更换游戏页面新的跳类型算法和对应信息,senmessage

slambb 2 vuotta sitten
vanhempi
sitoutus
bec5c39257
2 muutettua tiedostoa jossa 129 lisäystä ja 93 poistoa
  1. 2 2
      manifest.json
  2. 127 91
      pages/game-page/game-play-sub/subGame/subGame.nvue

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "哔蹦",
     "appid" : "__UNI__2635DF5",
     "description" : "",
-    "versionName" : "2.5.37",
-    "versionCode" : 22081801,
+    "versionName" : "2.5.38",
+    "versionCode" : 23022701,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 127 - 91
pages/game-page/game-play-sub/subGame/subGame.nvue

@@ -216,7 +216,8 @@
 			...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
 				'gCreateFilterObj', 'gUpdateFilter', 'B_OpenRopeSkipping', 'B_CloseRopeSkipping',
 				'gStopSimulateBLEUpdate', 'gStartSimulateBLEUpdate', 'gUpdateSandbagAlgorithm',
-				'gCreateSandbagAlgorithm', 'onConvertDeviceData', 'addSandbagHitCount', 'uploadUserData_hitCount'
+				'gCreateSandbagAlgorithm', 'onConvertDeviceData', 'addSandbagHitCount', 'uploadUserData_hitCount',
+				'jumpIdenModule_onJump6AxisDataUpdate'
 			]),
 			navBack() {
 
@@ -319,7 +320,11 @@
 					/**
 					 * 卡路里消耗参数
 					 */
-					let calorieParams = null;
+					let calorieParams = {
+						hitUnit: 0,
+						runUnit:puchConfig.getRunCalorie(1),
+						jumpUnit:puchConfig.getJumpCalorie(1)
+					};
 
 					if (this.BLEConnectDevice) {
 						// device = {
@@ -337,9 +342,7 @@
 							name: this.BLEConnectDevice.name
 						};
 
-						calorieParams = {
-							hitUnit: puchConfig.getBoxingCalorie(1)
-						};
+						calorieParams.hitUnit = puchConfig.getBoxingCalorie(1);
 
 					} else if (this.ConnectBindingDevice) {
 						device = {
@@ -347,10 +350,7 @@
 							ename: this.ConnectBindingDevice.ename,
 							name: this.ConnectBindingDevice.name
 						};
-
-						calorieParams = {
-							hitUnit: puchConfig.getBoxingCalorie(1)
-						};
+						calorieParams.hitUnit=puchConfig.getBoxingCalorie(1);
 					}
 					//到时候可能要区分是什么类型
 					let item = {
@@ -683,7 +683,7 @@
 					} else if (this.BLEConnectDevice.deviceType == "BLERope") {
 						//todo 开启跳绳模式
 						this.B_OpenRopeSkipping();
-						this._createActionJumpOnBoxingPostHit();
+						// this._createActionJumpOnBoxingPostHit();
 						//监听蓝牙回调
 						uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
 						uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
@@ -858,7 +858,10 @@
 									ename: res.ename,
 									value: res.hit,
 									mass: 10, //质量
-									hitPower: res.hit //计算的力
+									hitPower: res.hit ,//计算的力
+									//新增类型
+									sendType:"ConnectBindingDevice",
+									type:"none"
 								}
 								this.sendMessage("onBoxingPostHit", temp);
 							}
@@ -884,26 +887,6 @@
 					})
 				} else if (this.BLEConnectDevice.usageMode == "hotman") {
 					//hotman 沙袋情景 todo
-					// this.gUpdateFilter({
-					// 	data: data,
-					// 	callback: (res) => {
-					// 		// console.log(res);
-					// 		if (res.type == 'hit') {
-					// 			// console.log('gUpdateFilter callback:',res)
-
-					// 			let temp = {
-					// 				direction: res.direction,
-					// 				angle: res.angle,
-					// 				name: res.name,
-					// 				ename: res.ename,
-					// 				value: res.hit,
-					// 				mass: 10, //质量
-					// 				hitPower: res.hit //计算的力
-					// 			}
-					// 			this.sendMessage("onBoxingPostHit", temp);
-					// 		}
-					// 	}
-					// });
 					this.gUpdateSandbagAlgorithm({
 						data: data,
 						callback: (res) => {
@@ -921,37 +904,16 @@
 									ename: res.ename,
 									value: res.hit,
 									mass: 10, //质量
-									hitPower: res.hit //计算的力
+									hitPower: res.hit ,//计算的力
+									//新增类型
+									sendType:"hotman",
+									type:"none"
 								}
 								this.sendMessage("onBoxingPostHit", temp);
 							}
 						}
 					});
 				} else if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
-					//跳绳模式场景,简单更新触发
-					//看看是否反馈一个角度,180 ,360
-					// let temp = {
-					// 	direction: "all",
-					// 	angle: 0,
-					// 	name: "击中", // this.BLEConnectDevice.name,
-					// 	ename: "hit", //this.BLEConnectDevice.ename,
-					// 	value: 10,
-					// 	mass: 10, //质量
-					// 	hitPower: 10 //计算的力
-					// }
-					// this.sendMessage("onBoxingPostHit", temp);
-
-					//转换*********
-					// this.onConvertDeviceData({
-					// 	data: data,
-					// 	callback: (outData) => {
-					// 		data.acc = outData.convertAcc;
-					// 		data.gyro = outData.convertGyro;
-					// 		//跳绳蓝牙反馈
-					// 		this.onBLERopeUpdate(data);
-					// 	}
-					// });
-
 					//跳绳蓝牙反馈
 					this.onBLERopeUpdate(data);
 				}
@@ -1020,7 +982,10 @@
 					ename: ename,
 					value: direValue,
 					mass: this.mass, //质量
-					hitPower: power //计算的力
+					hitPower: power ,//计算的力
+					//新增类型
+					sendType:"BindBoxingPost",
+					type:"none"
 				}
 
 				this.sendMessage("onBoxingPostHit", temp);
@@ -1046,13 +1011,19 @@
 						ename: "hit",
 						value: e.acc,
 						mass: e.mass, //质量
-						hitPower: e.power //计算的力
+						hitPower: e.power ,//计算的力
+						//新增类型
+						sendType:"EquipmentActionObj",
+						type:"none"
 					}
 					this.sendMessage("onBoxingPostHit", temp);
 				})
 			},
 
-			//创建一个 跳识别对象
+			/**
+			 * 创建一个 跳识别对象
+			 * @deprecated  此方法废弃,将使用c语音识别算法。
+			 */
 			_createActionJumpOnBoxingPostHit() {
 				this.actionJumpObj = new ActionJump();
 				this.actionJumpObj.addEventListener('resultant', (e) => {
@@ -1063,7 +1034,10 @@
 						ename: "hit", //this.BLEConnectDevice.ename,
 						value: 10,
 						mass: 10, //质量
-						hitPower: 10 //计算的力
+						hitPower: 10 ,//计算的力
+						//新增类型
+						sendType:"ActionJumpObj",
+						type:"none"
 					}
 					if (e.type == 'stateDataOfJump') {
 						// console.log("game stateDataOfJump");
@@ -1071,7 +1045,6 @@
 					} else if (e.type == 'stop') {
 						// console.log("game stop");
 						this.onClearData();
-						// this.sendMessage("onBoxingPostHit", temp);
 					}
 				})
 			},
@@ -1080,6 +1053,69 @@
 			 * 识别跳部分数据处理
 			 */
 			onBLERopeUpdate(gameData) {
+				//调用识别算法
+				this.jumpIdenModule_onJump6AxisDataUpdate({
+					data: {
+						hex: gameData.hex
+					},
+					callback: (res) => {
+						if (res.code == 0) {
+							if (res.tag != -1) {
+								// this.jumpIdenModule_listenStateDataOfJump(res);
+								/**
+								 * @deprecated
+								 */
+								let temp = {
+									direction: "all",
+									angle: 0,
+									name: "跳", // this.BLEConnectDevice.name,
+									ename: "hit", //this.BLEConnectDevice.ename,
+									value: 0, //
+									mass: 0, //质量
+									hitPower: 0 ,//计算的力
+									//新增类型
+									sendType:"RopeSkipping",
+									type:"none",
+									angle:res.tag, //返回一个 tag方向
+								}
+								switch (res.tag) {
+									case 0:
+										//JumpType.NORMAL = 0
+										temp.type = "normal";
+										break;
+									case 1:
+										//right jump
+										temp.type = "right";
+										break;
+									case 2:
+										//left jump
+										temp.type = "left";
+										break;
+									case 3:
+										//right rotate jump
+										temp.type = "right_rotate";
+										break;
+									case 4:
+										//left rotate jump
+										temp.type = "left_rotate";
+										break;
+									default:
+
+										break;
+								}
+								this.sendMessage("onBoxingPostHit", temp);
+
+
+								// uni.showToast({
+								// 	title: res.tag + ',' + res.msg,
+								// 	icon: 'none',
+								// 	duration: 1000,
+								// 	mask: true
+								// })
+							}
+						}
+					}
+				});
 				//********陀螺仪角速度********
 				let {
 					gx,
@@ -1106,36 +1142,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() {