public override void PlayerControllerFixUpdate() { base.PlayerControllerFixUpdate(); //需要需要输入控制需要对接机位 if (IsInputController) { if (InputDevice.TurnLeft((int)playerIndex)) { playerTurnDirect = PlayerTurnDirect.Turn_Left; } else if (InputDevice.TurnRight((int)playerIndex)) { playerTurnDirect = PlayerTurnDirect.Turn_Right; } else { playerTurnDirect = PlayerTurnDirect.Turn_Mid; } //playerAccelerateSign = playerAIControler.accelerateMinValue + InputDevice.Accelerate((int)playerIndex); //Debug.Log("acc01 == " + InputDevice.Accelerate(0) + ", acc02 == " + InputDevice.Accelerate(1)); if (InputDevice.Accelerate(0) <= 0.1f && InputDevice.Accelerate(1) <= 0.1f) { //两个玩家都不踩脚踏板时,使玩家保持在镜头边缘. playerAccelerateSign = -0.05f; } else { playerAccelerateSign = playerAIControler.mPlayerAccMinRecord + InputDevice.Accelerate((int)playerIndex); } if (InputDevice.ButtonFireDown((int)playerIndex)) { if (!IsPlayerSystemForceAccelerateSign) { StartSupSpeed(); Invoke("CloseSupSpeed", m_SupSpeedKeepTime); } } } if (myTransform.localPosition.x <= 0f && !((RaceSceneControl)GameRoot.CurrentSceneControl).m_WaitMeUI[(int)playerIndex].activeInHierarchy) { ((RaceSceneControl)GameRoot.CurrentSceneControl).m_WaitMeUI[(int)playerIndex].SetActive(true); //播放"等等我"语言. SoundEffectPlayer.Play("WaitMe.wav"); } if (myTransform.localPosition.x > 0f && ((RaceSceneControl)GameRoot.CurrentSceneControl).m_WaitMeUI[(int)playerIndex].activeInHierarchy) { ((RaceSceneControl)GameRoot.CurrentSceneControl).m_WaitMeUI[(int)playerIndex].SetActive(false); } }
//狗熊的刷新函数 private void BrotherBearUpdate() { if (m_NowTimer > m_RandomEventTimer_Bear) { m_NowTimer = 0.0f; m_RandomEventTimer_Bear = UnityEngine.Random.Range(m_RandomEventTimer_BearBegin, m_RandomEventTimer_BearEnd); int EventParam = UnityEngine.Random.Range(0, m_RandomEventParam_Bear); AnimationParam obj = null; if (EventParam == 0) { obj = GetAnimationParam((int)PlayerAniType.X_PlayerLookLeft); } else if (EventParam == 1) { obj = GetAnimationParam((int)PlayerAniType.X_PlayerLookRight); } else { return; } if (obj == null) { Debug.Log("没找对动画参数"); } m_AnimationControl.wrapMode = WrapMode.Once; m_AnimationControl.CrossFade(obj.AnimationName); //obj.nowTimer = 0.0f; //m_NowUseAnimationParamlist.Add(obj); } if (!m_AnimationControl.isPlaying) { AnimationParam obj = GetAnimationParam((int)PlayerAniType.X_PlayerRun); m_AnimationControl.wrapMode = WrapMode.Loop; m_AnimationControl.CrossFade(obj.AnimationName); } if (m_IParkourPlayer_Xiong != null && m_IParkourPlayer_Xiong.IsInputController) { float accVal = InputDevice.Accelerate((int)m_IParkourPlayer_Xiong.playerIndex); if (accVal <= 0.3f) { m_AnimationControl[PlayerAniType.X_PlayerRun.ToString()].speed = 0f; } else { m_AnimationControl[PlayerAniType.X_PlayerRun.ToString()].speed = 1f + accVal; } } }
public override void OnUpdate() { base.OnUpdate(); EnterStart(); if (LoadObject != null) { //计算本周期进度条增加量 float accelerateValue = Mathf.Max(InputDevice.Accelerate((int)IParkourPlayer_Xiong.PlayerIndex.Index_P1), InputDevice.Accelerate((int)IParkourPlayer_Xiong.PlayerIndex.Index_P2)); if (accelerateValue > 0.0f) { loadAnimation.wrapMode = WrapMode.Loop; loadAnimation.CrossFade("X_PlayerSprint"); } else { loadAnimation.wrapMode = WrapMode.Loop; loadAnimation.CrossFade("X_PlayerRun"); } float processAddValue = TimeProgressAdd + Mathf.Lerp(0.0f, AccelerateProgressAdd, accelerateValue); //计算出来的是每秒的增加量,需要折算到当前周期 currentProgressValue += Mathf.Lerp(0.0f, processAddValue, Time.deltaTime); progressBar.SetProgressBar(currentProgressValue); //更新坐标 Vector3 p = loadAnimation.transform.localPosition; p.x = Mathf.Lerp(leftposition.localPosition.x, rightposition.localPosition.x, currentProgressValue); loadAnimation.transform.localPosition = p; //多算一些 if (currentProgressValue >= 1.1f) { ShowGameStart(); return; } currentRemainderTime -= Time.deltaTime; if (currentRemainderTime >= 0.0f) { UpdateTime(); } } }