// 进入状态 public bool OnEnter(IntPtr lParam) { cmd_Entity_Change_Wing_State param = IntPtrHelper.toData <cmd_Entity_Change_Wing_State>(lParam); currWing_State = param; m_bWing = false; tr = m_pFSM.transform; lastFrameTick = GameLogicAPI.getTickCount(); ApplyAnimation(); floatingState = FloatingState.Float; fMinFloatHeight = param.fMinFlyHeight; if (fMinFloatHeight < 0.01f) //2016-09-01暂时方案,param可能还没有参数传过来,所以变成0,此时先取预制体的浮空最低高度 { Debug.Log(fMinFloatHeight); fMinFloatHeight = m_pFSM.creaturePropety.floatingMinHeight; } fUpSpeed = param.fUpSpeed; //m_pFSM.creaturePropety.floatUpSpeed; m_pFSM.groundNormal = Vector3.zero; m_ySpeed = 0.0f; m_lastvelocity = Vector3.zero; m_maxSpeed = param.fSpeed; m_accSpeed = param.fAcceleration; m_maxHeight = param.fMaxFlyHeight; m_lastFrameDeltaTime = 0.0f; startHeight = m_pFSM.transform.position.y; return(true); }
public void ChangeState(IntPtr lParam) { cmd_Entity_Change_Wing_State param = IntPtrHelper.toData <cmd_Entity_Change_Wing_State>(lParam); currWing_State = param; if (currWing_State.nType == WING_STATE_TYPE.WING_STATE_FLOOR || (currWing_State.nType == WING_STATE_TYPE.WING_STATE_INVALID && floatingState != FloatingState.Down)) { // 服务器可能没通知floor而在进视野时直接通知invalid floatingState = FloatingState.Down; if (accelerate == true) { //申请退出加速 applyAccelerate(false); } if (m_bWing && m_pFSM.animator) { m_pFSM.animator.SetBool("flyDown", true); } if (m_bWing && wingAnimator) { wingAnimator.SetBool("flyDown", true); startHeight = m_pFSM.transform.position.y; } } else if (currWing_State.nType == WING_STATE_TYPE.WING_STATE_ACCELERATION) { EnableAccelerate(true, currWing_State.fMaxSpeed); } else if (currWing_State.nType == WING_STATE_TYPE.WING_STATE_NORMAL_FLIGHT) { EnableAccelerate(false, currWing_State.fSpeed); } else if (currWing_State.nType == WING_STATE_TYPE.WING_STATE_START_FLY) { if (floatingState != FloatingState.Float) { floatingState = FloatingState.Float; } } }