simple eating )

This commit is contained in:
2023-02-28 23:41:38 +02:00
parent 75b9665674
commit a54ce69e66
9 changed files with 58 additions and 501 deletions
+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;
}