初期化メソッド追加/温度変化をなめらかにした
This commit is contained in:
parent
2309c6d7be
commit
97fcc28eac
|
|
@ -2896,9 +2896,10 @@ MonoBehaviour:
|
|||
panController: {fileID: 2603874727618424762}
|
||||
thermoMeter: {fileID: 1928679192}
|
||||
temperature: 0
|
||||
temperatureSpeed: 0
|
||||
panSpeed: 0
|
||||
panFactor: 0.5
|
||||
deadZone: 0.08
|
||||
deadZone: 0.01
|
||||
baseIncreaseSpeed: 0.06
|
||||
hotIncreaseSpeed: 0.09
|
||||
maxDecreaseSpeed: 0.09
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@ public class ThermalControl : MonoBehaviour
|
|||
[SerializeField] private ThermoMeter thermoMeter;
|
||||
[Space]
|
||||
[SerializeField, ReadOnly] private float temperature;
|
||||
[SerializeField, ReadOnly] private float temperatureSpeed;
|
||||
[SerializeField, ReadOnly] private float panSpeed;
|
||||
[Space]
|
||||
[Header("フライパン感度/デッドゾーン")]
|
||||
[SerializeField] private float panFactor = .5f;
|
||||
[SerializeField] private float deadZone = .1f;
|
||||
[Header("熱くなるスピード/冷えるスピードの最大値")]
|
||||
[Header("熱くなるスピード/冷えるスピードの最大値/加速")]
|
||||
[SerializeField] private float baseIncreaseSpeed = .03f;
|
||||
[SerializeField] private float hotIncreaseSpeed = .07f;
|
||||
[SerializeField] private float maxDecreaseSpeed = .03f;
|
||||
|
|
@ -29,43 +30,43 @@ public class ThermalControl : MonoBehaviour
|
|||
[Header("ゲージ調整")]
|
||||
[SerializeField] private float coldValue = 0.32f;
|
||||
[SerializeField] private float hotValue = 0.67f;
|
||||
|
||||
private float duration = 0.3f;
|
||||
|
||||
public IReadOnlyReactiveProperty<ThermalCondition> Condition => condition;
|
||||
private ReactiveProperty<ThermalCondition> condition;
|
||||
|
||||
private void Start()
|
||||
public void Initialize()
|
||||
{
|
||||
temperature = 0f;
|
||||
condition = new ReactiveProperty<ThermalCondition>(ThermalCondition.Cold);
|
||||
thermoMeter.SetScale(coldValue, hotValue);
|
||||
|
||||
|
||||
condition.DistinctUntilChanged().Subscribe(x =>
|
||||
{
|
||||
Debug.Log($"cond :{x} temp: {temperature}");
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private ThermalCondition prevCond;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
panSpeed = panController.Delta.magnitude * panFactor;
|
||||
if (panSpeed > deadZone)
|
||||
{
|
||||
temperature -= Mathf.Min(panSpeed, maxDecreaseSpeed) * Time.deltaTime;
|
||||
temperatureSpeed = Mathf.Lerp(temperatureSpeed, -Mathf.Min(panSpeed, maxDecreaseSpeed), Time.deltaTime / duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (condition.Value == ThermalCondition.Hot)
|
||||
{
|
||||
temperature += hotIncreaseSpeed * Time.deltaTime;
|
||||
temperatureSpeed = Mathf.Lerp(temperatureSpeed, hotIncreaseSpeed, Time.deltaTime / duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
temperature += baseIncreaseSpeed * Time.deltaTime;
|
||||
temperatureSpeed = Mathf.Lerp(temperatureSpeed, baseIncreaseSpeed, Time.deltaTime / duration);
|
||||
}
|
||||
}
|
||||
temperature = Mathf.Clamp01(temperature);
|
||||
temperature = Mathf.Clamp01(temperature + temperatureSpeed * Time.deltaTime);
|
||||
thermoMeter.SetValue(temperature);
|
||||
condition.Value = GetCondition();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class PopcornGameManager : MonoBehaviour
|
|||
// startingGuide.SetActive(true);
|
||||
isProgress = false;
|
||||
cornManager.Initialize();
|
||||
thermalControl.Initialize();
|
||||
|
||||
thermalControl.Condition.DistinctUntilChanged().Subscribe(x =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue