소스 검색

1.替换新手图标
2.替换判断跳逻辑 jump-0.2.js

slambb 3 년 전
부모
커밋
f13453bfef

+ 19 - 12
components/modal/action-jump/action-jump.vue

@@ -140,7 +140,7 @@
 </template>
 
 <script>
-	import ActionJump from "@/util/util-js/action/jump-0.1.js"
+	import ActionJump from "@/util/util-js/action/jump-0.2.js"
 	import {
 		CONDITIONPASSED
 	} from "@/util/util-js/enum.js"
@@ -457,6 +457,14 @@
 						}
 						// 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);
+						}
 					}
 				})
 			},
@@ -988,7 +996,7 @@
 			//模拟测试调用
 			eliminateJumpPrefab(_jumpType) {
 				//只触发第二个
-				if (this.spawnArray.length < 3) {
+				if (this.spawnArray.length < 3 || this.spawnAnimation != null) {
 					return;
 				}
 				let _temp = this.spawnArray[2];
@@ -1191,7 +1199,6 @@
 
 			//监听跳的状态数据
 			listenStateDataOfJump(data) {
-				if (this.isGameOver || !this.bJumpPlay) return;
 
 				if (this.spawnArray.length < 3) return;
 				let _jumpType = this.getCurrentJumpType();
@@ -1199,7 +1206,7 @@
 				let _tempState = [{
 						jumpName: 'NORMAL',
 						jumpCode: 0,
-						bTrigger: true,
+						bTrigger: false,
 						describe: '正常跳'
 					},
 					{
@@ -1239,7 +1246,7 @@
 				// console.log(JSON.stringify(data));
 				this.onLogData = data;
 				let _rotateLimit = 4;
-				let _jumpLimit = 8;
+				let _jumpLimit = 0;
 
 				switch (_jumpType) {
 					case 0:
@@ -1248,14 +1255,14 @@
 						this.eliminateJumpPrefabFormTemp(_tempState);
 						break;
 					case 1:
-						if (currentMaxValue < -_jumpLimit || valleyOfWaveMinValue < -20) {
+						if (currentMaxValue < -_jumpLimit) {
 							//left jump
 							_tempState[1].bTrigger = true;
 						}
 						this.eliminateJumpPrefabFormTemp(_tempState);
 						break;
 					case 2:
-						if (currentMaxValue > _jumpLimit || peakOfWaveMaxValue > 20) {
+						if (currentMaxValue > _jumpLimit) {
 							//right jump
 							_tempState[2].bTrigger = true;
 						}
@@ -1329,10 +1336,9 @@
 				let bSuccess = false;
 				for (let i = 0; i < _tempState.length; i++) {
 					let _state = _tempState[i];
-					if (_state.bTrigger)
-					{
-						console.log('识别跳的类型:' +_state.describe + ',当前预制类型:'+_temp.jumpName + 
-						"\n直跳判断值:"+this.onLogData.currentMaxValue+",旋转跳值:"+this.onLogData.oGyroValue);
+					if (_state.bTrigger) {
+						console.log(this.eliminationCount + ',识别跳的类型:' + _state.describe + ',当前预制类型:' + _temp.jumpName +
+							"\n直跳判断值:" + this.onLogData.currentMaxValue + ",旋转跳值:" + this.onLogData.oGyroValue);
 					}
 					//如果当前的跳类型和预制目标一样
 					if (_state.jumpCode == _temp.jumpCode && _state.bTrigger) {
@@ -1383,7 +1389,8 @@
 			 * 识别跳部分数据处理
 			 */
 			onBLERopeUpdate(gameData) {
-				if (!this.bJumpPlay || this.isGameOver) return;
+				if (!this.bJumpPlay || this.isGameOver || this.spawnAnimation != null) return;
+
 				//********陀螺仪角速度********
 				let {
 					gx,

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "哔蹦",
     "appid" : "__UNI__2635DF5",
     "description" : "",
-    "versionName" : "2.4.23",
-    "versionCode" : 21101301,
+    "versionName" : "2.4.28",
+    "versionCode" : 21101902,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 1 - 1
pages/game-page/game-play-sub/subGame/subGame.nvue

@@ -23,7 +23,7 @@
 	import puchConfig from "@/util/util-js/puchConfig.js"
 
 	import EquipmentAction from "@/util/util-js/EquipmentAction.js"
-	import ActionJump from "@/util/util-js/action/jump-0.1.js"
+	import ActionJump from "@/util/util-js/action/jump-0.2.js"
 
 
 	var currentWebview;

+ 3 - 3
pages/personal-page/personal/personal.vue

@@ -496,8 +496,8 @@
 			updateData(newValue, oldValue, ownerInstance, instance) {
 				// newValue: 新数据
 				// oldValue: 老数据
-				// var log = console.log.bind(console);
-				// log(newValue)
+				var log = console.log.bind(console);
+				log(newValue)
 			}
 		}
 	}
@@ -1414,7 +1414,7 @@
 				if (0 == this.currentModeIndex) {
 					//蓝牙断开连接后,直接关闭
 					this.$refs.boxingPostRef.onCloseDevices();
-				}
+				} 
 			},
 			//蓝牙状态回调
 			callbackBLEState(res) {

+ 4 - 4
pages/platform-page/guide/guide-level-scroll.vue

@@ -77,7 +77,7 @@
 						title: '解锁左右跳',
 						firstText: '此为左跳图标,通过向左跳的方式消除标志块',
 						firstImage: '../../../static/modal/action-jump/directionJumpWhite-left.png',
-						firstDirection: -1,
+						firstDirection: 1,
 						firstWidth: 68,
 						firstHeight: 68,
 						secondText: '此为右跳图标,通过向右跳的方式消除标志块',
@@ -90,12 +90,12 @@
 					{
 						title: '解锁左右旋跳',
 						firstText: '此为左旋跳图标,通过向左旋跳的方式消除标志块',
-						firstImage: '../../../static/modal/action-jump/directionJumpWhite-left.png',
-						firstDirection: -1,
+						firstImage: '../../../static/modal/action-jump/rotateJumpWhite-left.png',
+						firstDirection: 1,
 						firstWidth: 68,
 						firstHeight: 68,
 						secondText: '此为右旋跳图标,通过向右旋跳的方式消除标志块',
-						secondImage: '../../../static/modal/action-jump/directionJumpWhite-right.png',
+						secondImage: '../../../static/modal/action-jump/rotateJumpWhite-right.png',
 						secondDirection: 1,
 						secondWidth: 68,
 						secondHeight: 68,

+ 4 - 4
platform/app-plus/subNVue/guide.nvue

@@ -259,7 +259,7 @@
 					title: '解锁左右跳',
 					firstText: '此为左跳图标,通过向左跳的方式消除标志块',
 					firstImage: '../../../static/modal/action-jump/directionJumpWhite-left.png',
-					firstDirection: -1,
+					firstDirection: 1,
 					firstWidth: 68,
 					firstHeight: 68,
 					secondText: '此为右跳图标,通过向右跳的方式消除标志块',
@@ -273,12 +273,12 @@
 				rotationJumpInfo: {
 					title: '解锁左右旋跳',
 					firstText: '此为左旋跳图标,通过向左旋跳的方式消除标志块',
-					firstImage: '../../../static/modal/action-jump/directionJumpWhite-left.png',
-					firstDirection: -1,
+					firstImage: '../../../static/modal/action-jump/rotateJumpWhite-left.png',
+					firstDirection: 1,
 					firstWidth: 68,
 					firstHeight: 68,
 					secondText: '此为右旋跳图标,通过向右旋跳的方式消除标志块',
-					secondImage: '../../../static/modal/action-jump/directionJumpWhite-right.png',
+					secondImage: '../../../static/modal/action-jump/rotateJumpWhite-right.png',
 					secondDirection: 1,
 					secondWidth: 68,
 					secondHeight: 68,

+ 314 - 0
util/util-js/action/jump-0.2.js

@@ -0,0 +1,314 @@
+/**
+ * 跳判断相关脚本代码
+ */
+
+function Event() {
+	this.events = {};
+}
+Event.prototype.addEventListener = function(type, listener) {
+	this.events[type] = this.events[type] || [];
+	this.events[type].push(listener);
+};
+Event.prototype.trigger = function() {
+	for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+		args[_key] = arguments[_key];
+	}
+
+	var type = args[0];
+	var params = args.slice(1);
+	if (!!this.events[type]) {
+		// console.log("type:",type);
+		this.events[type].forEach(function(listener) {
+			try {
+				listener.apply(null, params);
+			} catch (e) {
+				console.error(e);
+			}
+		});
+	}
+};
+var jumpOpts = {
+	//是否上升的标志位
+	isDirectionUp: false,
+	//持续上升次数
+	continueUpCount: 0,
+	//上一点的持续上升的次数,为了记录波峰的上升次数
+	continueUpFormerCount: 0,
+
+	continueDownCount: 0,
+	continueDownFormerCount: 0,
+
+	//上一点的状态,上升还是下降
+	lastStatus: false,
+	//波峰值
+	peakOfWave: 0,
+	//波谷值
+	valleyOfWave: 0,
+	//检测到极快的波动的次数
+	timeOfPeakCount: 0,
+	//开始添加
+	bUpdateTimeOfPeakCount: false,
+	//开始更新的次数
+	startCount: 0,
+	//停止跳
+	bStopJump: false,
+	//上次传感器的值
+	gravityOld: 0,
+
+	bUpState: false,
+
+	//开始时间
+	startTime: 0,
+	endTime: 0
+}
+var ActionJump = function ActionJump() {
+
+	this.jumpOpts = jumpOpts;
+	//其他波峰波谷参数相关数组记录
+	this.peakOfWaveArray = [];
+	this.peakOfWaveMaxValue = 0;
+	this.valleyOfWaveArray = [];
+	this.valleyOfWaveMinValue = 0;
+
+	this.peakOfWaveArrayValue = [];
+	this.valleyOfWaveArrayValue = [];
+
+	this.peakOfWaveArrayValueLinear = [];
+	this.valleyOfWaveArrayValueLinear = [];
+
+
+	this.highestCount = 0;
+	//陀螺仪
+	this.oriGyroYArray = [];
+
+	this.isJumpTop = false;
+
+	this.event = new Event();
+
+
+	this.frameCapacity = 6;
+	this.frame = [];
+	this.frameLength = 5;
+	this.frameOffset = 0;
+
+	this.frameHitCapacity = 11;
+	this.frameHit = []; //打击后的n帧
+
+	for (var i = 0; i < this.frameCapacity; ++i) {
+		var o = new Object();
+		// o.acc = [0, 0, 0];
+		// o.gyr = [0, 0, 0];
+		o.maxValue = 0;
+		o.gyroValue = 0;
+		o.resultant = 0;
+		this.frame.push(o);
+	}
+
+
+}
+ActionJump.prototype.addEventListener = function(type, listener) {
+	this.event.addEventListener(type, listener);
+};
+
+
+ActionJump.prototype.updateJump = function() {
+	let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+	//使用三个轴的数据,计算重力轴的加速度。最后减去重力的加速度值
+	//********加速计********
+	let {
+		lAccX,
+		lAccY,
+		lAccZ
+	} = data.linearAcc;
+	let {
+		oAccX,
+		oAccY,
+		oAccZ
+	} = data.oriAcc;
+	let {
+		oGyroX,
+		oGyroY,
+		oGyroZ
+	} = data.oriGyro;
+	let {
+		bYAxis
+	} = data;
+	let _tempAxisData = bYAxis ? oGyroY : oGyroX;
+	this.detectorNewStep(data.resultant, lAccX, lAccY, lAccZ, oAccX, oAccY, oAccZ, data.runIndex, _tempAxisData);
+};
+
+
+
+/*
+ * 检测步子,并开始计步
+ * 1.传入数据
+ * 2.如果检测到了波峰,并且符合时间差以及阈值的条件,则判定为1步
+ * 3.符合时间差条件,波峰波谷差值大于initialValue,则将该差值纳入阈值的计算中
+ * */
+ActionJump.prototype.detectorNewStep = function(resultant, linearX, linearY, linearZ, oriX, oriY, oriZ, _runIndex,
+	_oGyroY) {
+	let _judgmentValue = oriZ;
+	//判断resultant 一个阀值
+	let limitResultant = 20;
+	if (!this.jumpOpts.bStopJump) {
+		if (resultant > limitResultant && !this.jumpOpts.bUpState) {
+			// console.log("开始判断时候:" + resultant);
+			this.jumpOpts.bUpState = true;
+			this.isJumpTop = false;
+			this.highestCount = 0;
+			//陀螺仪部分
+			this.oriGyroYArray = [];
+			this.peakOfWaveArrayValue = [];
+			this.valleyOfWaveArrayValue = [];
+			this.peakOfWaveArrayValueLinear = [];
+			this.valleyOfWaveArrayValueLinear = [];
+			this.jumpOpts.startCount = 0;
+			//开始更新。加入时间判断
+			this.jumpOpts.startTime = new Date().getTime();
+			this.event.trigger('resultant', {
+				type: "log",
+				logType:'normal',
+				data: "开始时间:"+this.jumpOpts.startTime
+			});
+		}
+		if (this.jumpOpts.bUpState) {
+			let newFrame = this.frame[(this.frameOffset + this.frameLength) % this.frameCapacity];
+			
+			if (_judgmentValue > 2) {
+				newFrame.maxValue = _judgmentValue;
+				if (_judgmentValue > this.peakOfWaveMaxValue)
+					this.peakOfWaveMaxValue += _judgmentValue;
+			} else if (_judgmentValue < -2) {
+				newFrame.maxValue = _judgmentValue;
+				if (_judgmentValue < this.valleyOfWaveMinValue)
+					this.valleyOfWaveMinValue += _judgmentValue;
+			}
+			if (Math.abs(_oGyroY) > 5){
+				this.oriGyroYArray.push(_oGyroY);
+				newFrame.gyroValue = _oGyroY;
+			}
+			newFrame.resultant = resultant;
+				
+			let currTime = new Date().getTime(); //当前时间
+			let diffTime = currTime - this.jumpOpts.startTime; //当前时间减最初时间,得到当前时间差
+			// if (diffTime > 200){
+			// 	this.jumpOpts.bUpState = false;
+			// 	this.event.trigger('resultant', {
+			// 		type: "log",
+			// 		logType:'normal',
+			// 		data: "超时:"+diffTime
+			// 	});
+			// 	return;
+			// };
+			//出现极值后
+			// Math.abs(linearZ) < 7 &&
+			if (Math.abs(resultant) < 7) {
+				this.event.trigger('resultant', {
+					type: "log",
+					logType:'normal',
+					data: '出现极值后:'+ resultant+",时间:"+diffTime
+				});
+				// if (diffTime < 150){
+					// this.jumpOpts.bUpState = false;
+					// return;
+				// };
+				// this.event.trigger('resultant', {
+				// 	type: "log",
+				// 	logType:'normal',
+				// 	data: "************触发成功************"
+				// });
+				
+				this.highestCount++;
+				if (this.highestCount >= 1) {
+					//达到最高点,
+					this.jumpOpts.bStopJump = true;
+					this.jumpOpts.bUpdateTimeOfPeakCount = true;
+
+					let _currentMaxValue = 0;
+
+					if (Math.abs(this.peakOfWaveMaxValue) > Math.abs(this.valleyOfWaveMinValue)) {
+						_currentMaxValue = this.peakOfWaveMaxValue;
+					} else {
+						_currentMaxValue = this.valleyOfWaveMinValue;
+					}
+
+					let allOGyroValue = 0;
+					for (let i = 0; i < this.oriGyroYArray.length; i++) {
+						allOGyroValue += this.oriGyroYArray[i];
+					}
+					allOGyroValue /= this.oriGyroYArray.length;
+					
+					let _frameMaxValue = 0,_frameGyroValue = 0;
+					for (let i = 0; i < this.frame.length; i++) {
+						_frameMaxValue += this.frame[i].maxValue;
+						_frameGyroValue += this.frame[i].gyroValue;
+					}
+					console.log("frame:"+_frameMaxValue + " == "+ _frameGyroValue);
+
+					//后面通用使用这个类型传输数据
+					this.event.trigger('resultant', {
+						type: "stateDataOfJump",
+						currentMaxValue: _frameMaxValue,
+						peakOfWaveMaxValue: this.peakOfWaveMaxValue,
+						valleyOfWaveMinValue: this.valleyOfWaveMinValue,
+						oGyroValue: _frameGyroValue/this.frame.length,
+						resultant: resultant,
+						name: "highestCountEnd"
+					});
+					// this.jumpOpts.bUpState = false;
+					
+					
+					// this.jumpOpts.bStopJump = false;
+					this.event.trigger('resultant', {
+						type: "stop"
+					});
+					this.resetAll();
+				}
+			}
+			if ((this.frameOffset += 1) >= this.frameCapacity) {
+				this.frameOffset -= this.frameCapacity;
+			}
+		}
+	}else if (this.jumpOpts.bUpdateTimeOfPeakCount ) {
+		// console.log("结束判断时候:" + resultant);
+		this.jumpOpts.timeOfPeakCount++;
+		//todo 如果直跳,可以调节更小的 limitTimeOfPeakCount 30
+		let limitTimeOfPeakCount = 10;
+		if (this.jumpOpts.timeOfPeakCount >= limitTimeOfPeakCount) {
+			this.jumpOpts.timeOfPeakCount = 0;
+			this.jumpOpts.bStopJump = false;
+			this.jumpOpts.bUpState = false;
+			// this.event.trigger('resultant', {
+			// 	type: "stop"
+			// });
+			// this.resetAll();
+			this.jumpOpts.bUpdateTimeOfPeakCount = false;
+			// console.log("timeOfPeakCount >= " + limitTimeOfPeakCount);
+		}
+	}
+}
+
+ActionJump.prototype.setBUpState = function(value){
+	this.jumpOpts.bUpState = value;
+}
+
+
+//重置对应的参数
+ActionJump.prototype.resetAll = function() {
+	// console.log('******************* resetAll ******************');
+	this.peakOfWaveArray = [];
+	this.peakOfWaveMaxValue = 0;
+	this.valleyOfWaveArray = [];
+	this.valleyOfWaveMinValue = 0;
+	this.highestCount = 0;
+
+
+	this.jumpOpts.continueDownFormerCount = 0;
+	this.jumpOpts.continueDownCount = 0;
+	this.jumpOpts.continueUpFormerCount = 0;
+	this.jumpOpts.continueUpCount = 0;
+}
+
+if (typeof module === "object" && typeof module.exports === "object") {
+	module.exports = ActionJump;
+}

+ 3 - 3
util/util-js/store.js

@@ -2338,8 +2338,7 @@ const store = new Vuex.Store({
 				if (!res.connected) {
 
 					//要在连接的状态下 ,并且获取过匹配列表有参数的情况下,才提示重连
-					if (!state.bShowBLEConnectModal && state.bVerifiedConnection && state
-						.bPhoneMatched) {
+					if (!state.bShowBLEConnectModal && state.bVerifiedConnection) {
 						state.bShowBLEConnectModal = true;
 						let _connectItem = Object.assign({}, state.BLEConnectDevice);
 						let _cIndex = state.cIndex;
@@ -2463,7 +2462,8 @@ const store = new Vuex.Store({
 					}
 				},
 				fail: failRes => {
-					console.log('device services:', failRes.services)
+					console.log('device services:', failRes.services);
+					uni.hideToast();
 					uni.showModal({
 						title: '连接错误',
 						content: '请尝试重新连接设备。'