石头串联
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
@@ -54,6 +55,11 @@ namespace AibisDream
|
||||
engineData.CalcAir(config.airMaxRatio, config.airMinRatio, config.baseAirMax);
|
||||
// 推算速度
|
||||
engineData.CalcSpeed(config.acceleratedSpeed, config.resistance);
|
||||
// 判断是否成功
|
||||
if (engineData.CheckSuccess(config.targetSpeed))
|
||||
{
|
||||
DialogController.Instance.StartDialogNode("EngineSuccess");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,6 +102,15 @@ namespace AibisDream
|
||||
return sq;
|
||||
}
|
||||
|
||||
public IEnumerator OpenCoverAsync()
|
||||
{
|
||||
var sq = OpenCover();
|
||||
if (sq.active && !sq.IsComplete())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭盖板
|
||||
/// </summary>
|
||||
@@ -114,6 +129,15 @@ namespace AibisDream
|
||||
return sq;
|
||||
}
|
||||
|
||||
public IEnumerator CloseCoverAsync()
|
||||
{
|
||||
var sq = CloseCover();
|
||||
if (sq.active && !sq.IsComplete())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Lock()
|
||||
{
|
||||
// 禁止油门和气门
|
||||
@@ -152,6 +176,8 @@ namespace AibisDream
|
||||
}
|
||||
|
||||
config = data;
|
||||
// 重置Data
|
||||
OnEnable();
|
||||
}
|
||||
|
||||
public override void Save()
|
||||
@@ -185,12 +211,15 @@ namespace AibisDream
|
||||
public float airMinRatio;
|
||||
public float baseAirMax;
|
||||
public int maxLevel;
|
||||
public float targetSpeed;
|
||||
public float invalidTime;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct EngineData
|
||||
{
|
||||
private const float SuccessDuration = 3f;
|
||||
|
||||
public float curSpeed;
|
||||
public float curOil;
|
||||
public float curAir;
|
||||
@@ -201,6 +230,9 @@ namespace AibisDream
|
||||
public AutoFlipBool isValid;
|
||||
public bool inAirRange;
|
||||
|
||||
public float reachTargetTime;
|
||||
public bool isSuccess;
|
||||
|
||||
public EngineData(float flipDelayTime)
|
||||
{
|
||||
isValid = new AutoFlipBool(flipDelayTime, true);
|
||||
@@ -211,11 +243,13 @@ namespace AibisDream
|
||||
curAirMax = 0;
|
||||
curAirLevel = 0;
|
||||
inAirRange = false;
|
||||
reachTargetTime = 0;
|
||||
isSuccess = false;
|
||||
}
|
||||
|
||||
public void OilChange(float oilChangeRatio)
|
||||
{
|
||||
curOil = CommonUtil.LimitedAdd(curOil, oilChangeRatio * Time.deltaTime, 1f, 0f);
|
||||
curOil = CommonUtil.Limit(curOil + oilChangeRatio * Time.deltaTime, 1f, 0f);
|
||||
}
|
||||
|
||||
public void CalcSpeed(float acceleratedSpeed, float resistance)
|
||||
@@ -224,13 +258,13 @@ namespace AibisDream
|
||||
? (curOil * acceleratedSpeed - curSpeed * resistance) * Time.deltaTime
|
||||
: -curSpeed * resistance * Time.deltaTime;
|
||||
|
||||
curSpeed = CommonUtil.LimitedAdd(curSpeed, addNum, 1f, 0f);
|
||||
curSpeed = CommonUtil.Limit(curSpeed + addNum, 1f, 0f);
|
||||
}
|
||||
|
||||
public void CalcAir(float airMaxRatio, float airMinRatio, float baseAirMax)
|
||||
{
|
||||
curAirMax = curSpeed * (curAirLevel + 1) * airMaxRatio + baseAirMax;
|
||||
curAirMin = curSpeed * (curAirLevel + 1) * airMinRatio;
|
||||
curAirMax = CommonUtil.Limit(curSpeed * (curAirLevel + 1) * airMaxRatio + baseAirMax, 1f, 0f);
|
||||
curAirMin = CommonUtil.Limit(curSpeed * (curAirLevel + 1) * airMinRatio, 0.8f, 0f);
|
||||
|
||||
curAir = curOil;
|
||||
// 如果离开范围且当前在系统有效期,就进入一段失效期
|
||||
@@ -256,5 +290,26 @@ namespace AibisDream
|
||||
curAirLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckSuccess(float targetSpeed)
|
||||
{
|
||||
// 已经成功就不用校验了
|
||||
if (isSuccess) return false;
|
||||
|
||||
if (curSpeed >= targetSpeed)
|
||||
{
|
||||
reachTargetTime += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
reachTargetTime = 0;
|
||||
}
|
||||
|
||||
// 如果速度达标时间足够就判断成功
|
||||
if (!(reachTargetTime >= SuccessDuration)) return false;
|
||||
|
||||
isSuccess = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user