变速公式

搞了半天才发现正确的修改时间的公式应该是


本次调整时间 = 上次时间 + (当前获取时间 - 上次获取时间) * speed(调速倍率)


	private uint StoredTime =0;
		private  uint timeGetTime_Hooked(){
			//Debug.WriteLine("timeGetTime_Hooked :"+ this.trackBar1.Value);
			
			uint current = NativeSocketMethod.timeGetTime();
			
			if(StoredTime ==0){
			 	StoredTime = current;
			 	return StoredTime;
			}
		
			int speed = this.trackBar1.Value;
			if(speed==0){
				StoredTime =(uint)(StoredTime+(NativeSocketMethod.timeGetTime()- StoredTime));
				return StoredTime;
			}
			
			if(isJINENGAtt){
				Thread setAttStatusThread = new Thread(setAttStatus);
					setAttStatusThread.Start();
//					isAttStatus = false;
//					isJINENGAtt = false;
					StoredTime =(uint)(StoredTime +  ((NativeSocketMethod.timeGetTime() - StoredTime) * 0.6f));
					return StoredTime;
//					return (uint)(StoredTime +  ((NativeSocketMethod.timeGetTime() * 2.3f )));
//					return (uint)(StoredTime +  ((NativeSocketMethod.timeGetTime() - StoredTime)* 2.3f ));
			}
		
			
			float add = 0;
			switch(this.trackBar1.Value){
				case 1:
					add = 0.35f;
					break;
				case 2:
					add = 0.45f;
					break;
				case 3:
					add = 0.65f;
					break;
				case 4:
					add = 0.75f;
					break;
				case 5:
					add = 0.85f;
//					add = 2f;
					break;
			}
				
			if(isAttStatus){
//				Thread setAttStatusThread = new Thread(setAttStatus);
//				setAttStatusThread.Start();
				
				isAttStatus = false;
				isJINENGAtt = false;
//				return StoredTime+NativeSocketMethod.timeGetTime();
//				StoredTime=  (uint)(StoredTime +  ((NativeSocketMethod.timeGetTime() - StoredTime) * add));
//				return StoredTime;
			}
			
	//		uint lastTime = NativeSocketMethod.timeGetTime();
			StoredTime = (uint)(StoredTime +  ((NativeSocketMethod.timeGetTime() - StoredTime) * add));
			return StoredTime;
//			return (uint)(StoredTime +  ((NativeSocketMethod.timeGetTime() - StoredTime) ));
		}


你可能感兴趣的:(变速公式)