/// <summary> /// 限位 /// </summary> void Clamp() { if (Count < 0) { Count = 0; } if (Step <= 0) { Step = ValueAdjust.Clamp(Step, 1); } }
/// <summary> /// 装填完成 /// </summary> internal virtual void ReloadFinish() { if (ContinualReload) { Capasity = ValueAdjust.Clamp(Capasity + 1, 0, Capasity_Max); } else { Capasity = Capasity_Max; } }
/// <summary> /// 计算转速 /// </summary> private void CalculateRevs() { float CurrentFactor = 1; float wheelRevs; //wheelRevs = (carController.m_WheelColliders[0].rpm + carController.m_WheelColliders[1].rpm + carController.m_WheelColliders[2].rpm + carController.m_WheelColliders[3].rpm) / 4; wheelRevs = Speed.magnitude * 60f / carController.m_WheelColliders[0].radius; if (wheelRevs > WheelRevs && RevsPercent > 0.8f) { WheelRevs = ValueAdjust.Lerp(WheelRevs, wheelRevs, Time.deltaTime, 200); } else if (wheelRevs > WheelRevs && RevsPercent > 0.6f) { WheelRevs = ValueAdjust.Lerp(WheelRevs, wheelRevs, Time.deltaTime, 800); } else { WheelRevs = wheelRevs; } //计算引擎转速(用于显示和声音) EngineRevs = WheelRevs * CurrentFactor; if (EngineRevs > Revs) { if (RevsPercent > 0.8f) { Revs = ValueAdjust.Lerp(Revs, EngineRevs, Time.deltaTime, 200); } else if (RevsPercent > 0.6f) { Revs = ValueAdjust.Lerp(Revs, EngineRevs, Time.deltaTime, 1000); } else { //Revs = Mathf.Lerp(Revs, EngineRevs, Time.deltaTime * 4f); Revs = ValueAdjust.Lerp(Revs, EngineRevs, Time.deltaTime, 5000); } } else { Revs = ValueAdjust.Lerp(Revs, 0, Time.deltaTime, 2000); //Revs = Mathf.Lerp(Revs, 0, Time.deltaTime * 0.5f); } Revs = ValueAdjust.Clamp(Revs, 0, TopRevs); RevsPercent = ValueAdjust.Clamp(Revs / TopRevs); }