simple eating )

This commit is contained in:
2023-02-28 23:41:38 +02:00
parent 75b9665674
commit 811b2efc85
9 changed files with 55 additions and 252 deletions
@@ -59,14 +59,14 @@ public class ConversationController : MonoBehaviour
_selectedAction = action;
if (action is ISellable)
{
_btnApply.interactable = Player.Instance.Stats[StatsId.Money].Value >= (action as ISellable).Price;
// _btnApply.interactable = Player.Instance.Stats[StatsId.Money].Value >= (action as ISellable).Price;
}
}
private void ApplyActionOnPlayer(IPlayerAction action)
{
if (action is ISellable)
Player.Instance.BuyAction(action);
//if (action is ISellable)
// Player.Instance.BuyAction(action);
}
private void RemoveChoices()
{
@@ -10,6 +10,7 @@ public class ColaFreezer : BaseInteractableObject
{
if (!player.HasFoodObject())
{
player.BuyObject(_foodObjectSO);
// Spawn new object and set to player
var transform = Instantiate(_foodObjectSO.prefab, _playerArrivePoint);
var foodObject = transform.GetComponent<FoodObject>();
+13 -1
View File
@@ -4,7 +4,7 @@ using UnityEngine;
public class Fridge : BaseInteractableObject
{
private const int _maxCapacity=4;
private const int _maxCapacity=10;
private List<FoodObject> _foodObjects= new List<FoodObject>();
public override void Interact(Player player)
@@ -20,6 +20,18 @@ public class Fridge : BaseInteractableObject
else
Debug.Log($"Fridge is full");
}
else
{
//Eat menu
if (_foodObjects.Count>0)
{
while(player.Stats[StatsId.Food].Value< player.Stats[StatsId.Food].MaxValue && _foodObjects.Count > 0)
{
_foodObjects.RemoveAt(0);
player.Eat();
}
}
}
}
+12 -6
View File
@@ -203,22 +203,28 @@ public class Player : MonoBehaviour
public void UpdateStatsByClock()
{
Stats[StatsId.Food].deduct(0.034m); // 48 hours it's 100, 100/2880=~0.034 per minute
Stats[StatsId.Food].deduct(0.034f); // 48 hours it's 100, 100/2880=~0.034 per minute
if (_currentAnimation != AnimationStates.Sleeping)
{
Stats[StatsId.Energy].deduct(0.1m); // 24 hours it's 100, 100/1440=~0.096 per minute
Stats[StatsId.Energy].deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute
}
else
{
Stats[StatsId.Energy].increase(1m);
Stats[StatsId.Energy].increase(1f);
}
}
public void BuyAction(IPlayerAction action)
public void BuyObject(FoodObjectSO objectToBuy)
{
Stats[StatsId.Money].deduct(((ISellable)action).Price);
action.ApplyAction(this);
Stats[StatsId.Money].deduct(objectToBuy.objectPrice);
//action.ApplyAction(this);
}
public float Eat()
{
Stats[StatsId.Food].increase(10);
return Stats[StatsId.Food].Value;
}
private static string GetEnumMemberValue<T>(T value)
+6 -6
View File
@@ -7,12 +7,12 @@ public class PlayerStats
{
return new Dictionary<StatsId, Stat>()
{
{StatsId.Money, new Stat("Money", 100.0m)},
{StatsId.RentAccount, new Stat("Rent Account", 0)},
{StatsId.Food, new Stat("Food Energy", 50) },
{StatsId.Energy,new Stat("Energy", 100) },
{StatsId.BankAccount,new Stat("Bank Account", 0) },
{StatsId.Job, new Stat("Unemployed", 0) },
{StatsId.Money, new Stat("Money", 100.0f,10000000f)},
{StatsId.RentAccount, new Stat("Rent Account", 0,10f)},
{StatsId.Food, new Stat("Food Energy", 50,100f) },
{StatsId.Energy,new Stat("Energy", 100,100f) },
//{StatsId.BankAccount,new Stat("Bank Account", 0) },
{StatsId.Job, new Stat("Unemployed", 0, 100f) },
};
}
//// Knowledge for University Jobs
+11 -8
View File
@@ -1,29 +1,32 @@
public class Stat
{
public string Name { get; set; }
public decimal Value { get; set; }
public decimal Price { get; set; }
public decimal Quantity { get; set; }
public float Value { get; set; }
public float Price { get; set; }
public float Quantity { get; set; }
public float MaxValue { get; set; }
public Stat(string name, decimal startValue)
public Stat(string name, float startValue, float maxValue)
{
Name = name;
Value = startValue;
MaxValue = maxValue;
}
public Stat(string name, decimal price, decimal quantity)
public Stat(string name, float price, float quantity, float maxValue)
{
Name = name;
Price = price;
Quantity = quantity;
MaxValue = maxValue;
}
public void increase(decimal byAmount)
public void increase(float byAmount)
{
Value += byAmount;
}
public bool deduct(decimal amount)
public bool deduct(float amount)
{
if (Value >= amount)
{
@@ -33,7 +36,7 @@ public class Stat
return false;
}
public void forceDeduct(decimal amount)
public void forceDeduct(float amount)
{
Value -= amount;
}
+1 -1
View File
@@ -14,4 +14,4 @@ MonoBehaviour:
m_EditorClassIdentifier:
prefab: {fileID: 2680879424619819010, guid: 48940f42625c11541b2ebe92e86b6314, type: 3}
objectName: Cola
objectPrice: 0
objectPrice: 10
+5 -5
View File
@@ -8,8 +8,8 @@ public class TimeManager : MonoBehaviour
[SerializeField]
private float _startHour;
[SerializeField]
private Light _sunLight;
//[SerializeField]
//private Light _sunLight;
[SerializeField]
private float _sunriseHour;
@@ -31,7 +31,7 @@ public class TimeManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{
_sunInitialIntensity = _sunLight.intensity;
// _sunInitialIntensity = _sunLight.intensity;
_timer = _minuteToRealTime;
_currentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour);
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
@@ -61,7 +61,7 @@ public class TimeManager : MonoBehaviour
{
float intensityMultiplier = 1;
float timeofDay = (float)(CurrentTime.TotalDays - CurrentTime.Days);
_sunLight.transform.localRotation = Quaternion.Euler((timeofDay * 360f) - 90, 170, 0);
//_sunLight.transform.localRotation = Quaternion.Euler((timeofDay * 360f) - 90, 170, 0);
if (timeofDay > _sunriseTime.TotalDays && timeofDay < _sunsetTime.TotalDays)
{
if (timeofDay <= _sunsetTime.TotalDays)
@@ -73,7 +73,7 @@ public class TimeManager : MonoBehaviour
{
intensityMultiplier = 0;
}
_sunLight.intensity = _sunInitialIntensity * intensityMultiplier;
// _sunLight.intensity = _sunInitialIntensity * intensityMultiplier;
}
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)