Exemplo n.º 1
0
 /// <summary>
 /// ■brakePower:ブレーキの強さ
 /// </summary>
 public EngineSpeedCalc(VehicleSettings.EngineSettings engineSettings, VehicleSettings.PenaltySettings penaltySettings,
                        GearParam gearParam, IReadOnlyReactiveProperty <GearState> gear)
 {
     mEngineSettings      = engineSettings;
     mPenaltySettings     = penaltySettings;
     mCurrentGear         = gear;
     mLowestSpeed         = gearParam.GetGearData(GearState.REVERSE).MaxSpeed;
     mEngineRpmCalculator = new EngineRpmCalculator(gearParam, gear);
     mCurrentGear
     .Buffer(2, 1)
     .Subscribe(x =>
     {
         //現在のギアデータ
         GearData gearData = gearParam.GetGearData(x.Last());
         //1つ前のギアデータ
         GearData lateGearData = gearParam.GetGearData(x.First());
         //現在のギアに必要な回転数を取得
         mNeedSpeed = gearData.NeedSpeed;
         //現在のギアの最大回転数を取得
         mMaxSpeed = gearData.MaxSpeed;
         //ギア変更前の最大回転数を取得
         mPreMaxSpeed = lateGearData.MaxSpeed;
         //エンジンブレーキの強さを取得
         mEngineBrakePow = gearData.EngineBrake;
         //1秒あたりのエンジン回転数を取得
         mAccPow = gearData.EngineRot;
     });
 }
 //コンストラクタ
 public EngineRpmCalculator(GearParam gearParam, IReadOnlyReactiveProperty <GearState> gearState)
 {
     gearState
     .Buffer(2, 1)
     .Subscribe(x =>
     {
         mMaxSpeed    = gearParam.GetGearData(x.Last()).MaxSpeed;
         mGearState   = x.Last();
         mMaxPreSpeed = gearParam.GetGearData(x.First()).MaxSpeed;
     });
 }
Exemplo n.º 3
0
 //コンストラクタ
 public EngineRpmCalculator(GearParam gearParam, IReadOnlyReactiveProperty <GearState> gearState)
 {
     gearState
     .Buffer(2, 1)
     .Subscribe(x =>
     {
         //現在のギアに設定されている最高速度
         mMaxSpeed = gearParam.GetGearData(x.Last()).MaxSpeed;
         //現在のギアステート
         mGearState = x.Last();
         //ひとつ前のギアに設定されている最高速度
         mMaxPreSpeed = gearParam.GetGearData(x.First()).MaxSpeed;
     });
 }
Exemplo n.º 4
0
    /// <summary>
    /// GearStateを返す
    /// </summary>
    /// <returns></returns>
    private GearState AT()
    {
        //reverseから
        float speed = mVehicleCore.EngineSpeed;

        if (speed >= mGearParam.GetGearData(GearState.SIXTH).NeedSpeed)
        {
            mCurrentGearIndex = 7;
        }
        else if (speed >= mGearParam.GetGearData(GearState.FIFTH).NeedSpeed)
        {
            mCurrentGearIndex = 6;
        }
        else if (speed >= mGearParam.GetGearData(GearState.FOURTH).NeedSpeed)
        {
            mCurrentGearIndex = 5;
        }
        else if (speed >= mGearParam.GetGearData(GearState.THIRD).NeedSpeed)
        {
            mCurrentGearIndex = 4;
        }
        else if (speed >= mGearParam.GetGearData(GearState.SECOND).NeedSpeed)
        {
            mCurrentGearIndex = 3;
        }
        else if (speed >= mGearParam.GetGearData(GearState.FIRST).NeedSpeed)
        {
            mCurrentGearIndex = 2;
        }
        else
        {
            mCurrentGearIndex = 0;
        }                              //minusにならない
        mCurrentGearIndex = Mathf.Clamp(mCurrentGearIndex, 0, (int)GearState.MAX - 1);
        return((GearState)Enum.ToObject(typeof(GearState), mCurrentGearIndex));
    }