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
+3 -222
View File
@@ -37,8 +37,8 @@ RenderSettings:
m_ReflectionBounces: 1 m_ReflectionBounces: 1
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994} m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.1826001, g: 0.22831085, b: 0.30717328, a: 1} m_IndirectSpecularColor: {r: 0.17276844, g: 0.21589246, b: 0.2978263, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@@ -855,7 +855,6 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_startHour: 9 _startHour: 9
_sunLight: {fileID: 705507994}
_sunriseHour: 7 _sunriseHour: 7
_sunsetHour: 20.5 _sunsetHour: 20.5
_minuteToRealTime: 0.5 _minuteToRealTime: 0.5
@@ -867,7 +866,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 307039698} m_GameObject: {fileID: 307039698}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -66.86987, y: -30.572754, z: 45.03262} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@@ -1563,100 +1562,6 @@ MeshFilter:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 696070341} m_GameObject: {fileID: 696070341}
m_Mesh: {fileID: 1744877714637898952, guid: 0d817475ce7adaa4f81fbdb111b8599c, type: 3} m_Mesh: {fileID: 1744877714637898952, guid: 0d817475ce7adaa4f81fbdb111b8599c, type: 3}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
m_Layer: 0
m_Name: Sunlight
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 0.8
m_Bias: 0.05
m_NormalBias: 0
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.13156042, y: 0.92744404, z: -0.34980756, w: -0.013194327}
m_LocalPosition: {x: 0, y: 50, z: 50}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1504187455}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 40.194, y: 188.774, z: 19.363}
--- !u!1 &716241207 --- !u!1 &716241207
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3663,7 +3568,6 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 307039700} - {fileID: 307039700}
- {fileID: 2047049769}
- {fileID: 1550470211} - {fileID: 1550470211}
- {fileID: 1689632238} - {fileID: 1689632238}
m_Father: {fileID: 0} m_Father: {fileID: 0}
@@ -9779,7 +9683,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 705507995}
- {fileID: 1856998490} - {fileID: 1856998490}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
@@ -10685,128 +10588,6 @@ Transform:
m_Father: {fileID: 656725490} m_Father: {fileID: 656725490}
m_RootOrder: -1 m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2047049764
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2047049769}
- component: {fileID: 2047049768}
- component: {fileID: 2047049767}
- component: {fileID: 2047049766}
- component: {fileID: 2047049765}
m_Layer: 0
m_Name: followpath
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!114 &2047049765
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047049764}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a17411f0f5c4b764fb4afd65c74cbcb5, type: 3}
m_Name:
m_EditorClassIdentifier:
MovementType: 0
MyPath: {fileID: 101167830}
speed: 1
maxDistance: 0.1
--- !u!65 &2047049766
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047049764}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &2047049767
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047049764}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &2047049768
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047049764}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2047049769
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2047049764}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.65, y: 3.46, z: -17.134588}
m_LocalScale: {x: 0.4125, y: 0.39875, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 971260931}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2053101242 --- !u!1 &2053101242
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -59,14 +59,14 @@ public class ConversationController : MonoBehaviour
_selectedAction = action; _selectedAction = action;
if (action is ISellable) 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) private void ApplyActionOnPlayer(IPlayerAction action)
{ {
if (action is ISellable) //if (action is ISellable)
Player.Instance.BuyAction(action); // Player.Instance.BuyAction(action);
} }
private void RemoveChoices() private void RemoveChoices()
{ {
@@ -10,6 +10,7 @@ public class ColaFreezer : BaseInteractableObject
{ {
if (!player.HasFoodObject()) if (!player.HasFoodObject())
{ {
player.BuyObject(_foodObjectSO);
// Spawn new object and set to player // Spawn new object and set to player
var transform = Instantiate(_foodObjectSO.prefab, _playerArrivePoint); var transform = Instantiate(_foodObjectSO.prefab, _playerArrivePoint);
var foodObject = transform.GetComponent<FoodObject>(); var foodObject = transform.GetComponent<FoodObject>();
+13 -1
View File
@@ -4,7 +4,7 @@ using UnityEngine;
public class Fridge : BaseInteractableObject public class Fridge : BaseInteractableObject
{ {
private const int _maxCapacity=4; private const int _maxCapacity=10;
private List<FoodObject> _foodObjects= new List<FoodObject>(); private List<FoodObject> _foodObjects= new List<FoodObject>();
public override void Interact(Player player) public override void Interact(Player player)
@@ -20,6 +20,18 @@ public class Fridge : BaseInteractableObject
else else
Debug.Log($"Fridge is full"); 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() 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) 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 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); Stats[StatsId.Money].deduct(objectToBuy.objectPrice);
action.ApplyAction(this); //action.ApplyAction(this);
}
public float Eat()
{
Stats[StatsId.Food].increase(10);
return Stats[StatsId.Food].Value;
} }
private static string GetEnumMemberValue<T>(T value) private static string GetEnumMemberValue<T>(T value)
+6 -6
View File
@@ -7,12 +7,12 @@ public class PlayerStats
{ {
return new Dictionary<StatsId, Stat>() return new Dictionary<StatsId, Stat>()
{ {
{StatsId.Money, new Stat("Money", 100.0m)}, {StatsId.Money, new Stat("Money", 100.0f,10000000f)},
{StatsId.RentAccount, new Stat("Rent Account", 0)}, {StatsId.RentAccount, new Stat("Rent Account", 0,10f)},
{StatsId.Food, new Stat("Food Energy", 50) }, {StatsId.Food, new Stat("Food Energy", 50,100f) },
{StatsId.Energy,new Stat("Energy", 100) }, {StatsId.Energy,new Stat("Energy", 100,100f) },
{StatsId.BankAccount,new Stat("Bank Account", 0) }, //{StatsId.BankAccount,new Stat("Bank Account", 0) },
{StatsId.Job, new Stat("Unemployed", 0) }, {StatsId.Job, new Stat("Unemployed", 0, 100f) },
}; };
} }
//// Knowledge for University Jobs //// Knowledge for University Jobs
+11 -8
View File
@@ -1,29 +1,32 @@
public class Stat public class Stat
{ {
public string Name { get; set; } public string Name { get; set; }
public decimal Value { get; set; } public float Value { get; set; }
public decimal Price { get; set; } public float Price { get; set; }
public decimal Quantity { 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; Name = name;
Value = startValue; Value = startValue;
MaxValue = maxValue;
} }
public Stat(string name, decimal price, decimal quantity) public Stat(string name, float price, float quantity, float maxValue)
{ {
Name = name; Name = name;
Price = price; Price = price;
Quantity = quantity; Quantity = quantity;
MaxValue = maxValue;
} }
public void increase(decimal byAmount) public void increase(float byAmount)
{ {
Value += byAmount; Value += byAmount;
} }
public bool deduct(decimal amount) public bool deduct(float amount)
{ {
if (Value >= amount) if (Value >= amount)
{ {
@@ -33,7 +36,7 @@ public class Stat
return false; return false;
} }
public void forceDeduct(decimal amount) public void forceDeduct(float amount)
{ {
Value -= amount; Value -= amount;
} }
+1 -1
View File
@@ -14,4 +14,4 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
prefab: {fileID: 2680879424619819010, guid: 48940f42625c11541b2ebe92e86b6314, type: 3} prefab: {fileID: 2680879424619819010, guid: 48940f42625c11541b2ebe92e86b6314, type: 3}
objectName: Cola objectName: Cola
objectPrice: 0 objectPrice: 10
+5 -5
View File
@@ -8,8 +8,8 @@ public class TimeManager : MonoBehaviour
[SerializeField] [SerializeField]
private float _startHour; private float _startHour;
[SerializeField] //[SerializeField]
private Light _sunLight; //private Light _sunLight;
[SerializeField] [SerializeField]
private float _sunriseHour; private float _sunriseHour;
@@ -31,7 +31,7 @@ public class TimeManager : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
_sunInitialIntensity = _sunLight.intensity; // _sunInitialIntensity = _sunLight.intensity;
_timer = _minuteToRealTime; _timer = _minuteToRealTime;
_currentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour); _currentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour);
_sunriseTime = TimeSpan.FromHours(_sunriseHour); _sunriseTime = TimeSpan.FromHours(_sunriseHour);
@@ -61,7 +61,7 @@ public class TimeManager : MonoBehaviour
{ {
float intensityMultiplier = 1; float intensityMultiplier = 1;
float timeofDay = (float)(CurrentTime.TotalDays - CurrentTime.Days); 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 > _sunriseTime.TotalDays && timeofDay < _sunsetTime.TotalDays)
{ {
if (timeofDay <= _sunsetTime.TotalDays) if (timeofDay <= _sunsetTime.TotalDays)
@@ -73,7 +73,7 @@ public class TimeManager : MonoBehaviour
{ {
intensityMultiplier = 0; intensityMultiplier = 0;
} }
_sunLight.intensity = _sunInitialIntensity * intensityMultiplier; // _sunLight.intensity = _sunInitialIntensity * intensityMultiplier;
} }
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to) private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)