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