show player energy, change daytimecontroller to TimeManager

This commit is contained in:
Vladimir Koshevarov
2022-11-17 16:12:51 +02:00
parent 6b8d74932c
commit be3161d7e4
15 changed files with 859 additions and 223 deletions
-7
View File
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: e8490bd42479d9b47ae3707927cf7937
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+371 -15
View File
@@ -2978,10 +2978,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2649ed9748ff3864880311f1c2aecdef, type: 3}
m_Name:
m_EditorClassIdentifier:
_dateTimeController: {fileID: 307039699}
_playerController: {fileID: 1476341271}
_timeText: {fileID: 2089282903}
_moneyText: {fileID: 443940496}
_energy: {fileID: 910851332}
--- !u!1 &443940494
GameObject:
m_ObjectHideFlags: 0
@@ -3242,6 +3242,7 @@ RectTransform:
- {fileID: 2051386991}
- {fileID: 1006389537}
- {fileID: 1235246448}
- {fileID: 1613486730}
m_Father: {fileID: 329780516}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -3817,7 +3818,7 @@ GameObject:
- component: {fileID: 779251536}
- component: {fileID: 779251535}
m_Layer: 5
m_Name: MoneyIcon
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -4872,6 +4873,96 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ea47665625ccfd4408f6411caf45f910, type: 3}
--- !u!1 &910851330
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 910851331}
- component: {fileID: 910851332}
m_Layer: 5
m_Name: Bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &910851331
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 910851330}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1208778161}
- {fileID: 1671838872}
m_Father: {fileID: 1613486730}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -4.39, y: -0.6}
m_SizeDelta: {x: -16.4603, y: -13.6867}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &910851332
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 910851330}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 0
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 0
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 0}
m_FillRect: {fileID: 1671838872}
m_HandleRect: {fileID: 0}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 100
m_WholeNumbers: 0
m_Value: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!1 &931340241
GameObject:
m_ObjectHideFlags: 0
@@ -5088,10 +5179,10 @@ RectTransform:
m_Father: {fileID: 497576566}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -413.1, y: -17.039}
m_SizeDelta: {x: -1028.6992, y: 21.462}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -15.599976, y: -16.3}
m_SizeDelta: {x: 147.30078, y: 21.462}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1023905085 stripped
MonoBehaviour:
@@ -5132,7 +5223,7 @@ GameObject:
- component: {fileID: 1030855394}
- component: {fileID: 1030855393}
m_Layer: 5
m_Name: CalendarIcon
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -5151,7 +5242,7 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1235246448}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@@ -5395,7 +5486,7 @@ Mesh:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh26922
m_Name: pb_Mesh23968
serializedVersion: 10
m_SubMeshes:
- serializedVersion: 2
@@ -5894,6 +5985,82 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1194898190}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1208778160
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1208778161}
- component: {fileID: 1208778163}
- component: {fileID: 1208778162}
m_Layer: 5
m_Name: Border
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1208778161
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1208778160}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 910851331}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.22940063, y: 0}
m_SizeDelta: {x: 0.4588, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1208778162
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1208778160}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.2677999, g: 0.3081395, b: 0.3207547, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1208778163
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1208778160}
m_CullTransparentMesh: 1
--- !u!1 &1232329904
GameObject:
m_ObjectHideFlags: 0
@@ -6019,14 +6186,14 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2089282902}
- {fileID: 1030855392}
- {fileID: 2089282902}
m_Father: {fileID: 497576566}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -265.0797, y: -17.039}
m_AnchoredPosition: {x: 132.42029, y: -16.299986}
m_SizeDelta: {x: 148.7307, y: 21.462}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1287883232
@@ -11295,7 +11462,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c802a0d9d32b0c04b841113e87b83e4b, type: 3}
m_Name:
m_EditorClassIdentifier:
Clock: 0
--- !u!114 &1476341272
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -11602,6 +11768,44 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1579224152}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1613486729
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1613486730}
m_Layer: 5
m_Name: Energy
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1613486730
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1613486729}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 910851331}
- {fileID: 1726465721}
m_Father: {fileID: 497576566}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -437.8, y: -17.039}
m_SizeDelta: {x: 100, y: 21.462}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1628496569
GameObject:
m_ObjectHideFlags: 0
@@ -11686,6 +11890,82 @@ Transform:
m_Father: {fileID: 274182514}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1671838871
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1671838872}
- component: {fileID: 1671838874}
- component: {fileID: 1671838873}
m_Layer: 5
m_Name: Fill
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1671838872
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1671838871}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 910851331}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: -0.16749573, y: 0}
m_SizeDelta: {x: 0.58259, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1671838873
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1671838871}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.9245283, g: 0.6511125, b: 0.12646852, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1671838874
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1671838871}
m_CullTransparentMesh: 1
--- !u!1 &1682316605
GameObject:
m_ObjectHideFlags: 0
@@ -12076,6 +12356,82 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716045985}
m_CullTransparentMesh: 1
--- !u!1 &1726465720
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1726465721}
- component: {fileID: 1726465723}
- component: {fileID: 1726465722}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1726465721
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1726465720}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1613486730}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -42.5, y: 0}
m_SizeDelta: {x: 13, y: 14}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1726465722
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1726465720}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: dfe1a973babd6cc4bb1a418ed2f3562e, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1726465723
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1726465720}
m_CullTransparentMesh: 1
--- !u!1 &1791787532
GameObject:
m_ObjectHideFlags: 0
@@ -12437,8 +12793,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.33900002, y: 0}
m_AnchorMax: {x: 0.65355104, y: 0.5}
m_AnchoredPosition: {x: 4.5, y: -17.0386}
m_SizeDelta: {x: 807, y: 34.0772}
m_AnchoredPosition: {x: 4.38, y: -15.1362}
m_SizeDelta: {x: 807, y: 36.4047}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2051386992
MonoBehaviour:
@@ -12644,7 +13000,7 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1235246448}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
+21 -22
View File
@@ -1,22 +1,21 @@
using Assets.Scripts.Actions.Interfaces;
namespace Assets.Scripts.Actions
{
public class Eat : BaseAction, ISellableItem
{
public double Price { get; private set; }
private int _energyPerTick;
public Eat(int duration, int energyPerTick, double price) : base(duration)
{
Price = price;
_energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerController playerController)
{
playerController.foodEnergy.increase(_energyPerTick);
}
}
}
using Assets.Scripts.Actions.Interfaces;
namespace Assets.Scripts.Actions
{
public class Eat : BaseAction, ISellableItem
{
public float Price { get; private set; }
private int _energyPerTick;
public Eat(int duration, int energyPerTick, float price) : base(duration)
{
Price = price;
_energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerController playerController)
{
playerController.foodEnergy.increase(_energyPerTick);
}
}
}
@@ -3,6 +3,6 @@ namespace Assets.Scripts.Actions.Interfaces
{
internal interface ISellableItem
{
public double Price { get; }
public float Price { get; }
}
}
+15 -15
View File
@@ -1,15 +1,15 @@
namespace Assets.Scripts.Actions
{
public class Relax : BaseAction
{
private int _energyPerTick;
public Relax(int duration, int energyPerTick) : base(duration)
{
_energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerController playerController)
{
playerController.restEnergy.increase(_energyPerTick);
}
}
}
namespace Assets.Scripts.Actions
{
public class Relax : BaseAction
{
private int _energyPerTick;
public Relax(int duration, int energyPerTick) : base(duration)
{
_energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerController playerController)
{
playerController.energy.increase(_energyPerTick);
}
}
}
+14 -6
View File
@@ -1,11 +1,9 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class GameUIController : MonoBehaviour
{
[SerializeField]
private DateTimeController _dateTimeController;
[SerializeField]
private PlayerController _playerController;
@@ -15,23 +13,33 @@ public class GameUIController : MonoBehaviour
[SerializeField]
private TextMeshProUGUI _moneyText;
[SerializeField]
public Slider _energy;
// Start is called before the first frame update
void Start()
private void OnEnable()
{
TimeManager.OnMinuteChanged += UpdateTime;
}
private void OnDisable()
{
TimeManager.OnMinuteChanged -= UpdateTime;
}
// Update is called once per frame
void Update()
{
_moneyText.text = $"${_playerController.money.Value}";
UpdateTime();
_energy.value = _playerController.energy.Value;
}
private void UpdateTime()
{
if (_timeText != null)
{
_timeText.text = _dateTimeController.CurrentTime.ToString("HH:mm");
_timeText.text = TimeManager.CurrentTime.ToString(@"hh\:mm");
}
}
}
+12 -10
View File
@@ -4,10 +4,10 @@ using UnityEngine;
public class PlayerController : MonoBehaviour
{
public Stat money = new Stat("Money", 100.00);
public Stat money = new Stat("Money", 100.0f);
public Stat rentAccount = new Stat("Rent Account", 0);
public Stat foodEnergy = new Stat("Food Energy", 0);
public Stat restEnergy = new Stat("Rest Energy", 0);
public Stat energy = new Stat("Energy", 100);
// bank
public Stat bankAccount = new Stat("Bank Account", 0);
@@ -40,11 +40,15 @@ public class PlayerController : MonoBehaviour
public Stat tvItem = new Stat("Tv Item", 1500, 1);
public Stat laptopItem = new Stat("Laptop Item", 3000, 1);
private void OnEnable()
{
TimeManager.OnMinuteChanged += DecreaseEnergy;
}
private int _day;
public int Clock;
private void OnDisable()
{
TimeManager.OnMinuteChanged -= DecreaseEnergy;
}
// Start is called before the first frame update
void Start()
{
@@ -53,13 +57,11 @@ public class PlayerController : MonoBehaviour
// Update is called once per frame
void Update()
{
}
public void StartNewDay()
public void DecreaseEnergy()
{
Clock = 24;
energy.deduct(0.096f); // 24 hours it's 100, 100/1440=~0.096 per minute
}
public bool TryBuyAction(BaseAction action)
+41 -41
View File
@@ -1,41 +1,41 @@
public class Stat
{
public string Name { get; set; }
public double Value { get; set; }
public double Price { get; set; }
public double Quantity { get; set; }
public Stat(string name, double startValue)
{
Name = name;
Value = startValue;
}
public Stat(string name, double price, double quantity)
{
Name = name;
Price = price;
Quantity = quantity;
}
public void increase(double byAmount)
{
Value += byAmount;
}
public bool deduct(double amount)
{
if (Value >= amount)
{
Value -= amount;
return true;
}
return false;
}
public void forceDeduct(double amount)
{
Value -= amount;
}
}
public class Stat
{
public string Name { get; set; }
public float Value { get; set; }
public double Price { get; set; }
public double Quantity { get; set; }
public Stat(string name, float startValue)
{
Name = name;
Value = startValue;
}
public Stat(string name, float price, float quantity)
{
Name = name;
Price = price;
Quantity = quantity;
}
public void increase(float byAmount)
{
Value += byAmount;
}
public bool deduct(float amount)
{
if (Value >= amount)
{
Value -= amount;
return true;
}
return false;
}
public void forceDeduct(float amount)
{
Value -= amount;
}
}
@@ -1,106 +1,116 @@
using System;
using UnityEngine;
public class DateTimeController : MonoBehaviour
{
[SerializeField]
private float _timeMultiplier;
[SerializeField]
private float _startHour;
[SerializeField]
private Light _sunLight;
[SerializeField]
private float _sunriseHour;
[SerializeField]
private float _sunsetHour;
[SerializeField]
private Color _dayAmbientLight;
[SerializeField]
private Color _nightAmbientLight;
[SerializeField]
private AnimationCurve _lightChangeCurve;
[SerializeField]
private float _maxSunLightIntensity;
[SerializeField]
private Light _moonLight;
[SerializeField]
private float _maxMoonLightIntensity;
private TimeSpan _sunriseTime;
private TimeSpan _sunsetTime;
private DateTime _currentTime;
public DateTime CurrentTime => _currentTime;
// Start is called before the first frame update
void Start()
{
_currentTime = DateTime.Now.Date + TimeSpan.FromHours(_startHour);
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
_sunsetTime = TimeSpan.FromHours(_sunsetHour);
}
// Update is called once per frame
void Update()
{
UpdateTime();
RotateSun();
}
private void UpdateTime()
{
_currentTime = _currentTime.AddSeconds(Time.deltaTime * _timeMultiplier);
}
private void RotateSun()
{
float sunLightRotation;
if (_currentTime.TimeOfDay > _sunriseTime && _currentTime.TimeOfDay < _sunsetTime)
{
TimeSpan sunriseToSunsetDuration = CalculateTimeDifference(_sunriseTime, _sunsetTime);
TimeSpan timeSinceSunrise = CalculateTimeDifference(_sunriseTime, _currentTime.TimeOfDay);
double percentage = timeSinceSunrise.TotalMinutes / sunriseToSunsetDuration.TotalMinutes;
sunLightRotation = Mathf.Lerp(0, 180, (float)percentage);
}
else
{
TimeSpan nightDuration = CalculateTimeDifference(_sunsetTime, _sunriseTime);
TimeSpan timeSinceSunset = CalculateTimeDifference(_sunsetTime, _currentTime.TimeOfDay);
double percentage = timeSinceSunset.TotalMinutes / nightDuration.TotalMinutes;
sunLightRotation = Mathf.Lerp(180, 360, (float)percentage);
}
_sunLight.transform.rotation = Quaternion.AngleAxis(sunLightRotation, Vector3.right);
}
private void UpdateLightSettings()
{
float dotProduct = Vector3.Dot(_sunLight.transform.forward, Vector3.down);
_sunLight.intensity = Mathf.Lerp(0, _maxSunLightIntensity, _lightChangeCurve.Evaluate(dotProduct));
_moonLight.intensity = Mathf.Lerp(_maxMoonLightIntensity, 0, _lightChangeCurve.Evaluate(dotProduct));
RenderSettings.ambientLight = Color.Lerp(_nightAmbientLight, _dayAmbientLight, _lightChangeCurve.Evaluate(dotProduct));
}
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)
{
TimeSpan diff = to - from;
if (diff.TotalSeconds < 0)
{
diff += TimeSpan.FromHours(24);
}
return diff;
}
}
using System;
using UnityEngine;
public class TimeManager : MonoBehaviour
{
public static Action OnMinuteChanged;
[SerializeField]
private float _startHour;
[SerializeField]
private Light _sunLight;
[SerializeField]
private float _sunriseHour;
[SerializeField]
private float _sunsetHour;
[SerializeField]
private Color _dayAmbientLight;
[SerializeField]
private Color _nightAmbientLight;
[SerializeField]
private AnimationCurve _lightChangeCurve;
[SerializeField]
private float _maxSunLightIntensity;
[SerializeField]
private Light _moonLight;
[SerializeField]
private float _maxMoonLightIntensity;
private TimeSpan _sunriseTime;
private TimeSpan _sunsetTime;
private float _timer;
[SerializeField]
private float _minuteToRealTime = 0.5f;
public static TimeSpan CurrentTime { get; private set; }
// Start is called before the first frame update
void Start()
{
_timer = _minuteToRealTime;
CurrentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour);
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
_sunsetTime = TimeSpan.FromHours(_sunsetHour);
}
// Update is called once per frame
void Update()
{
UpdateTime();
//RotateSun();
}
private void UpdateTime()
{
_timer -= Time.deltaTime;
if (_timer <= 0)
{
CurrentTime = CurrentTime.Add(TimeSpan.FromMinutes(1));
OnMinuteChanged?.Invoke();
_timer = _minuteToRealTime;
}
}
//private void RotateSun()
//{
// float sunLightRotation;
// if (_currentTime.TimeOfDay > _sunriseTime && _currentTime.TimeOfDay < _sunsetTime)
// {
// TimeSpan sunriseToSunsetDuration = CalculateTimeDifference(_sunriseTime, _sunsetTime);
// TimeSpan timeSinceSunrise = CalculateTimeDifference(_sunriseTime, _currentTime.TimeOfDay);
// double percentage = timeSinceSunrise.TotalMinutes / sunriseToSunsetDuration.TotalMinutes;
// sunLightRotation = Mathf.Lerp(0, 180, (float)percentage);
// }
// else
// {
// TimeSpan nightDuration = CalculateTimeDifference(_sunsetTime, _sunriseTime);
// TimeSpan timeSinceSunset = CalculateTimeDifference(_sunsetTime, _currentTime.TimeOfDay);
// double percentage = timeSinceSunset.TotalMinutes / nightDuration.TotalMinutes;
// sunLightRotation = Mathf.Lerp(180, 360, (float)percentage);
// }
// _sunLight.transform.rotation = Quaternion.AngleAxis(sunLightRotation, Vector3.right);
//}
private void UpdateLightSettings()
{
float dotProduct = Vector3.Dot(_sunLight.transform.forward, Vector3.down);
_sunLight.intensity = Mathf.Lerp(0, _maxSunLightIntensity, _lightChangeCurve.Evaluate(dotProduct));
_moonLight.intensity = Mathf.Lerp(_maxMoonLightIntensity, 0, _lightChangeCurve.Evaluate(dotProduct));
RenderSettings.ambientLight = Color.Lerp(_nightAmbientLight, _dayAmbientLight, _lightChangeCurve.Evaluate(dotProduct));
}
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)
{
TimeSpan diff = to - from;
if (diff.TotalSeconds < 0)
{
diff += TimeSpan.FromHours(24);
}
return diff;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+134
View File
@@ -0,0 +1,134 @@
fileFormatVersion: 2
guid: dfe1a973babd6cc4bb1a418ed2f3562e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 128
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

+134
View File
@@ -0,0 +1,134 @@
fileFormatVersion: 2
guid: bc479ad3f781c4540995d023a62d8c1d
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant: