public void OnFreamAsyn(SCFrameNotify frameAsyn) { if (!_isGameing) { return; } // 无操作的帧, 直接跑过去 if (_nextFrameSetp < frameAsyn.CurrentFrame) { TickerManager.Instance.DriveToTickCount(frameAsyn.CurrentFrame - 1); _nextFrameSetp = frameAsyn.CurrentFrame; } // 这个是我们需要的 if (_nextFrameSetp != frameAsyn.CurrentFrame) { return; } // 按按键 foreach (CSFrameNotify frameControlList in frameAsyn.Keys) { if (_inputListeners.ContainsKey(frameControlList.Uin)) { IInputListener listener = _inputListeners[frameControlList.Uin]; foreach (var con in frameControlList.Keys) { #region 解析按键 ushort key = (ushort)con; ushort type = (byte)(key & 0x3); key >>= 2; ushort value = (ushort)(key & 0x3FF); key >>= 10; key &= 0xF; #endregion if (key == InputDefine.DIRCTION_KEY) { float ang = value; if (CommonFunction.GreatOrEqualZero(ang - 180f)) { ang -= 360f; } listener.OnMove(ang, (MoveType)type); } else { if (type > 0) { listener.OnFunctionKeyDown(key); } else { listener.OnFunctionKeyUp(key); } } } } } _nextFrameSetp = frameAsyn.NextFrame; TickerManager.Instance.DriveToTickCount(_nextFrameSetp - 1); }
public void OnFrameAsyn(SCFrameNotify frameAsyn) { if (!_isGaming) { return; } //无操作的帧直接跑 if (_nextFrameStep < frameAsyn.CurrentFrame) { TickerManager.Instance.DriveToTickCount(frameAsyn.CurrentFrame - 1); _nextFrameStep = frameAsyn.CurrentFrame; } //当前帧判断内容 if (_nextFrameStep == frameAsyn.CurrentFrame) { //按键 foreach (var frameControlList in frameAsyn.Keys) { IInputListener listener = _inputListeners[frameControlList.Uin]; foreach (var con in frameControlList.Keys) { #region 解析按键 UInt16 key = (UInt16)con; //后两位是类型 up down UInt16 type = (Byte)(key & 0x3); key >>= 2; //值 0~2^10 范围 UInt16 value = (UInt16)(key & 0x3ff); key >>= 10; //自定义类型 key &= 0xf; #endregion if (key == InputDefine.DIRCTION_KEY) { float angle = value; if (CommonFunction.GreatOrEqualZero(angle - 180f)) { angle -= 360f; } listener.OnMove(angle, (MoveType)type); } else { if (type > 0) { listener.OnFunctionKeyDown(key); } else { listener.OnFunctionKeyUp(key); } } } } _nextFrameStep = frameAsyn.NextFrame; TickerManager.Instance.DriveToTickCount(_nextFrameStep - 1); } }
public void DirctionTouch(float angle, MoveType moveType) { if (GameSyncManager.Instance.IsStepLockMode) { if (CommonFunction.LessZero(angle)) { angle += 360f; } GameSyncManager.Instance.AddKeyInfo(InputDefine.DIRCTION_KEY, (UInt16)Mathf.FloorToInt(angle + CommonFunction.EPS), (byte)moveType); return; } //if isStepNormal if (_listener != null) { _listener.OnMove(angle, moveType); } }