From 448367d6d3415bd939d4eff420d9948836d7e84e Mon Sep 17 00:00:00 2001 From: Valdimir Date: Fri, 17 Nov 2023 15:33:02 +0200 Subject: [PATCH] fix stats --- Assets/Scripts/Player/Player.cs | 11 ++--------- Assets/Scripts/Player/Stat.cs | 15 +++++++++------ Assets/Scripts/UIElements/TimeSliderUI.cs | 1 + 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/Player/Player.cs b/Assets/Scripts/Player/Player.cs index c5e99056..7b950637 100644 --- a/Assets/Scripts/Player/Player.cs +++ b/Assets/Scripts/Player/Player.cs @@ -58,8 +58,6 @@ public class Player : MonoBehaviour _navAgent.updatePosition = false; _currentActing = PlayerStates.Awake; - - } private void OnDestroy() @@ -177,12 +175,6 @@ public class Player : MonoBehaviour return Mathf.Abs(Quaternion.Dot(q1, q2)) >= 1 - precision; } - //private TaskStatus InteractWithObject(BaseInteractableObject interactableObject) - //{ - // interactableObject.Interact(this); - // return TaskStatus.Complete; - //} - public void SetPlayerAnimation(AnimationStates newState, Action onAnimationFinish) { _OnAnimationFinish = onAnimationFinish; @@ -225,9 +217,10 @@ public class Player : MonoBehaviour break; case PlayerStates.Sleeping: Stats[StatsId.Energy].increase(0.2f); + Stats[StatsId.Food].deduct(0.03f); break; default: - Stats[StatsId.Food].deduct(0.034f); // 48 hours it's 100, 100/2880=~0.034 per minute + Stats[StatsId.Food].deduct(0.05f); // 48 hours it's 100, 100/2880=~0.034 per minute Stats[StatsId.Energy].deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute break; } diff --git a/Assets/Scripts/Player/Stat.cs b/Assets/Scripts/Player/Stat.cs index a6d62b7c..053f4054 100644 --- a/Assets/Scripts/Player/Stat.cs +++ b/Assets/Scripts/Player/Stat.cs @@ -1,10 +1,10 @@ public class Stat { - public string Name { get; set; } - public float Value { get; set; } - public float Price { get; set; } - public float Quantity { get; set; } - public float MaxValue { get; set; } + public string Name { get; private set; } + public float Value { get; private set; } + public float Price { get; private set; } + public float Quantity { get; private set; } + public float MaxValue { get; private set; } public Stat(string name, float startValue, float maxValue) { @@ -23,7 +23,10 @@ public class Stat public void increase(float byAmount) { - Value += byAmount; + if (Value < MaxValue) + { + Value += byAmount; + } } public bool deduct(float amount) diff --git a/Assets/Scripts/UIElements/TimeSliderUI.cs b/Assets/Scripts/UIElements/TimeSliderUI.cs index 2db103e9..458f89ec 100644 --- a/Assets/Scripts/UIElements/TimeSliderUI.cs +++ b/Assets/Scripts/UIElements/TimeSliderUI.cs @@ -39,6 +39,7 @@ public class TimeSliderUI : MonoBehaviour Hide(); }); + SliderValueChanger(_slider.value); _slider.onValueChanged.AddListener(x=>SliderValueChanger(x)); }