/// <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;
     });
 }
Esempio 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;
     });
 }
Esempio n. 4
0
    public Engine(EngineSpeedCalc engineCalc, Rigidbody rigidbody, IGearManageable input, IReadOnlyReactiveProperty <GearState> gear)
    {
        mEngineCalc  = engineCalc;
        mRigidbody   = rigidbody;
        mGearManager = input;

        gear
        .Buffer(2, 1)
        .Subscribe(x =>
        {
            //現在のギアデータ
            GearState currentGear = x.Last();
            //1つ前のギアデータ
            GearState preGear = x.First();


            //atの時ギアが下がった時に速度が少し下がる処理
            //mtの時度外視
            if (input.GetGearManager.IsMT)
            {
                return;
            }
            //Rの時は度外視
            if (currentGear == GearState.REVERSE)
            {
                return;
            }
            if (preGear == GearState.REVERSE)
            {
                return;
            }
            //ギアが下げられた場合
            if ((int)currentGear < (int)preGear)
            {
                mEngineSpeed -= 5.0f;
            }
        });
    }