add time manager and day/night cycle
This commit is contained in:
@@ -1857,6 +1857,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 410087041}
|
- component: {fileID: 410087041}
|
||||||
- component: {fileID: 410087040}
|
- component: {fileID: 410087040}
|
||||||
|
- component: {fileID: 410087043}
|
||||||
- component: {fileID: 410087042}
|
- component: {fileID: 410087042}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Directional Light
|
m_Name: Directional Light
|
||||||
@@ -1974,6 +1975,20 @@ MonoBehaviour:
|
|||||||
m_ShadowLayerMask: 1
|
m_ShadowLayerMask: 1
|
||||||
m_RenderingLayers: 1
|
m_RenderingLayers: 1
|
||||||
m_ShadowRenderingLayers: 1
|
m_ShadowRenderingLayers: 1
|
||||||
|
--- !u!114 &410087043
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 410087039}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1df4995bc2c404c47986a4f90cf3ca4f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::SunRotation
|
||||||
|
directionalLight: {fileID: 0}
|
||||||
|
offset: 270
|
||||||
--- !u!1 &430850200
|
--- !u!1 &430850200
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2913,6 +2928,143 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 589087811}
|
m_GameObject: {fileID: 589087811}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &596191950
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 596191951}
|
||||||
|
- component: {fileID: 596191953}
|
||||||
|
- component: {fileID: 596191952}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: testtimer
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &596191951
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 596191950}
|
||||||
|
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: 1704696510}
|
||||||
|
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: -860, y: -571.5217}
|
||||||
|
m_SizeDelta: {x: 200, y: 50}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &596191952
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 596191950}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
|
||||||
|
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_text: New Text
|
||||||
|
m_isRightToLeft: 0
|
||||||
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_fontSharedMaterials: []
|
||||||
|
m_fontMaterial: {fileID: 0}
|
||||||
|
m_fontMaterials: []
|
||||||
|
m_fontColor32:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_enableVertexGradient: 0
|
||||||
|
m_colorMode: 3
|
||||||
|
m_fontColorGradient:
|
||||||
|
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_fontColorGradientPreset: {fileID: 0}
|
||||||
|
m_spriteAsset: {fileID: 0}
|
||||||
|
m_tintAllSprites: 0
|
||||||
|
m_StyleSheet: {fileID: 0}
|
||||||
|
m_TextStyleHashCode: -1183493901
|
||||||
|
m_overrideHtmlColors: 0
|
||||||
|
m_faceColor:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontSize: 36
|
||||||
|
m_fontSizeBase: 36
|
||||||
|
m_fontWeight: 400
|
||||||
|
m_enableAutoSizing: 0
|
||||||
|
m_fontSizeMin: 18
|
||||||
|
m_fontSizeMax: 72
|
||||||
|
m_fontStyle: 0
|
||||||
|
m_HorizontalAlignment: 1
|
||||||
|
m_VerticalAlignment: 256
|
||||||
|
m_textAlignment: 65535
|
||||||
|
m_characterSpacing: 0
|
||||||
|
m_characterHorizontalScale: 1
|
||||||
|
m_wordSpacing: 0
|
||||||
|
m_lineSpacing: 0
|
||||||
|
m_lineSpacingMax: 0
|
||||||
|
m_paragraphSpacing: 0
|
||||||
|
m_charWidthMaxAdj: 0
|
||||||
|
m_TextWrappingMode: 1
|
||||||
|
m_wordWrappingRatios: 0.4
|
||||||
|
m_overflowMode: 0
|
||||||
|
m_linkedTextComponent: {fileID: 0}
|
||||||
|
parentLinkedComponent: {fileID: 0}
|
||||||
|
m_enableKerning: 0
|
||||||
|
m_ActiveFontFeatures: 6e72656b
|
||||||
|
m_enableExtraPadding: 0
|
||||||
|
checkPaddingRequired: 0
|
||||||
|
m_isRichText: 1
|
||||||
|
m_EmojiFallbackSupport: 1
|
||||||
|
m_parseCtrlCharacters: 1
|
||||||
|
m_isOrthographic: 1
|
||||||
|
m_isCullingEnabled: 0
|
||||||
|
m_horizontalMapping: 0
|
||||||
|
m_verticalMapping: 0
|
||||||
|
m_uvLineOffset: 0
|
||||||
|
m_geometrySortingOrder: 0
|
||||||
|
m_IsTextObjectScaleStatic: 0
|
||||||
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
|
m_useMaxVisibleDescender: 1
|
||||||
|
m_pageToDisplay: 1
|
||||||
|
m_margin: {x: 0, y: 0, z: -78.094, w: 0}
|
||||||
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
|
m_isVolumetricText: 0
|
||||||
|
m_hasFontAssetChanged: 0
|
||||||
|
m_baseMaterial: {fileID: 0}
|
||||||
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
--- !u!222 &596191953
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 596191950}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &615859199
|
--- !u!1 &615859199
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -5080,6 +5232,7 @@ GameObject:
|
|||||||
- component: {fileID: 1230830890}
|
- component: {fileID: 1230830890}
|
||||||
- component: {fileID: 1230830889}
|
- component: {fileID: 1230830889}
|
||||||
- component: {fileID: 1230830892}
|
- component: {fileID: 1230830892}
|
||||||
|
- component: {fileID: 1230830894}
|
||||||
- component: {fileID: 1230830893}
|
- component: {fileID: 1230830893}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GameManager
|
m_Name: GameManager
|
||||||
@@ -5177,6 +5330,19 @@ MonoBehaviour:
|
|||||||
- quantity: 0
|
- quantity: 0
|
||||||
item: 0
|
item: 0
|
||||||
ownedBackpackType: 0
|
ownedBackpackType: 0
|
||||||
|
--- !u!114 &1230830894
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1230830888}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1b892c02d92dd70419f61cf0ae34b9d8, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::TimeManager
|
||||||
|
TEST_TEXT_BOX: {fileID: 596191952}
|
||||||
--- !u!1 &1268265871
|
--- !u!1 &1268265871
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -7194,6 +7360,7 @@ RectTransform:
|
|||||||
- {fileID: 1685149660}
|
- {fileID: 1685149660}
|
||||||
- {fileID: 1187986793}
|
- {fileID: 1187986793}
|
||||||
- {fileID: 1047025328}
|
- {fileID: 1047025328}
|
||||||
|
- {fileID: 596191951}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
|||||||
@@ -2730,6 +2730,7 @@ GameObject:
|
|||||||
- component: {fileID: 954594192}
|
- component: {fileID: 954594192}
|
||||||
- component: {fileID: 954594191}
|
- component: {fileID: 954594191}
|
||||||
- component: {fileID: 954594190}
|
- component: {fileID: 954594190}
|
||||||
|
- component: {fileID: 954594195}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GameManager
|
m_Name: GameManager
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -2825,6 +2826,19 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &954594195
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 954594189}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1b892c02d92dd70419f61cf0ae34b9d8, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::TimeManager
|
||||||
|
TEST_TEXT_BOX: {fileID: 0}
|
||||||
--- !u!1 &986462055
|
--- !u!1 &986462055
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public class GameManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public static GameManager Instance { get; private set; }
|
public static GameManager Instance { get; private set; }
|
||||||
public DialogueManager DialogueManager { get; private set; }
|
public DialogueManager DialogueManager { get; private set; }
|
||||||
|
public TimeManager TimeManager { get; private set; }
|
||||||
public Inventory Inventory { get; private set; }
|
public Inventory Inventory { get; private set; }
|
||||||
public Storybools Storybools { get; private set; }
|
public Storybools Storybools { get; private set; }
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ private void ReloadReferences()
|
|||||||
Instance.DialogueManager.ReloadReferences();
|
Instance.DialogueManager.ReloadReferences();
|
||||||
|
|
||||||
Instance.Inventory = GetComponent<Inventory>();
|
Instance.Inventory = GetComponent<Inventory>();
|
||||||
|
Instance.TimeManager = GetComponent<TimeManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public struct SaveData
|
|||||||
public QuestSaveData QuestData;
|
public QuestSaveData QuestData;
|
||||||
public StoryboolSaveData StoryboolData;
|
public StoryboolSaveData StoryboolData;
|
||||||
public InventorySaveData InventorySaveData;
|
public InventorySaveData InventorySaveData;
|
||||||
|
public TimeSaveData TimeSaveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SaveFileName()
|
public static string SaveFileName()
|
||||||
@@ -43,6 +44,7 @@ private static void HandleSaveData()
|
|||||||
{
|
{
|
||||||
GameManager.Instance.SaveStoryBools(ref _saveData.StoryboolData);
|
GameManager.Instance.SaveStoryBools(ref _saveData.StoryboolData);
|
||||||
GameManager.Instance.Inventory.SaveInventory(ref _saveData.InventorySaveData);
|
GameManager.Instance.Inventory.SaveInventory(ref _saveData.InventorySaveData);
|
||||||
|
GameManager.Instance.TimeManager.SaveTime(ref _saveData.TimeSaveData);
|
||||||
QuestRegistry.Instance.SaveQuestData(ref _saveData.QuestData);
|
QuestRegistry.Instance.SaveQuestData(ref _saveData.QuestData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ public static void HandleLoadData()
|
|||||||
{
|
{
|
||||||
GameManager.Instance.LoadStoryBools(_saveData.StoryboolData);
|
GameManager.Instance.LoadStoryBools(_saveData.StoryboolData);
|
||||||
GameManager.Instance.Inventory.LoadInventory(_saveData.InventorySaveData);
|
GameManager.Instance.Inventory.LoadInventory(_saveData.InventorySaveData);
|
||||||
|
GameManager.Instance.TimeManager.LoadTime(_saveData.TimeSaveData);
|
||||||
QuestRegistry.Instance.LoadQuestData(_saveData.QuestData);
|
QuestRegistry.Instance.LoadQuestData(_saveData.QuestData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TimeManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
private const int HOURS_PER_DAY = 24;
|
||||||
|
private const int MINUTES_PER_HOUR = 60;
|
||||||
|
public const int SECONDS_PER_MINUTE = 2;
|
||||||
|
|
||||||
|
private int currentHour = 12;
|
||||||
|
private int currentMinute = 0;
|
||||||
|
private float currentSecond = 0;
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
StepTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StepTime()
|
||||||
|
{
|
||||||
|
currentSecond += Time.deltaTime;
|
||||||
|
|
||||||
|
if (currentSecond > SECONDS_PER_MINUTE)
|
||||||
|
{
|
||||||
|
currentSecond = 0;
|
||||||
|
currentMinute += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentMinute > MINUTES_PER_HOUR - 1)
|
||||||
|
{
|
||||||
|
currentMinute = 0;
|
||||||
|
currentHour += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentHour > (HOURS_PER_DAY - 1))
|
||||||
|
{
|
||||||
|
currentHour = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current second within the current minute
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Current second within the current minute</returns>
|
||||||
|
public float GetCurrentSecond()
|
||||||
|
{
|
||||||
|
return currentSecond;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current minute within the current hour
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Current minute within the current hour</returns>
|
||||||
|
public int GetCurrentMinute()
|
||||||
|
{
|
||||||
|
return currentMinute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current hour within the current day
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Current hour within the current day</returns>
|
||||||
|
public int GetCurrentHour()
|
||||||
|
{
|
||||||
|
return currentHour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a formatted time string
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Returns a formatted string with the hour, minute, and second</returns>
|
||||||
|
public string GetTimeString()
|
||||||
|
{
|
||||||
|
string formattedHour = currentHour.ToString("00");
|
||||||
|
string formattedMinute = currentMinute.ToString("00");
|
||||||
|
string formattedSecond = currentSecond.ToString("00.00");
|
||||||
|
|
||||||
|
return $"{formattedHour}:{formattedMinute}:{formattedSecond}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Time Save/Load
|
||||||
|
public void SaveTime(ref TimeSaveData data)
|
||||||
|
{
|
||||||
|
data.hour = currentHour;
|
||||||
|
data.minute = currentMinute;
|
||||||
|
data.second = currentSecond;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadTime(TimeSaveData data)
|
||||||
|
{
|
||||||
|
currentHour = data.hour;
|
||||||
|
currentMinute = data.minute;
|
||||||
|
currentSecond = data.second;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public struct TimeSaveData
|
||||||
|
{
|
||||||
|
public int hour;
|
||||||
|
public int minute;
|
||||||
|
public float second;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1b892c02d92dd70419f61cf0ae34b9d8
|
||||||
@@ -47,6 +47,12 @@ void Update()
|
|||||||
{
|
{
|
||||||
cameraController.RotateCam();
|
cameraController.RotateCam();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add actual save feature later, this is just for test
|
||||||
|
if (Input.GetKeyDown(KeyCode.I))
|
||||||
|
{
|
||||||
|
SaveSystem.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyGravity();
|
ApplyGravity();
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class SunRotation : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Light directionalLight;
|
||||||
|
public float offset = 270f; // Adjust for sunrise/sunset timing
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
directionalLight = GetComponent<Light>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
DateTime dateTime = new DateTime(
|
||||||
|
DateTime.Today.Year,
|
||||||
|
DateTime.Today.Month,
|
||||||
|
DateTime.Today.Day,
|
||||||
|
GameManager.Instance.TimeManager.GetCurrentHour(),
|
||||||
|
GameManager.Instance.TimeManager.GetCurrentMinute(), 0);
|
||||||
|
|
||||||
|
// Get current time and convert to a fraction of a day (0 to 1)
|
||||||
|
float timeOfDay = (float)dateTime.TimeOfDay.TotalDays;
|
||||||
|
|
||||||
|
float sunRotation = timeOfDay * 360f + offset;
|
||||||
|
transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.Euler(sunRotation, 0, 0), 10);
|
||||||
|
|
||||||
|
// adjust light intensity based on sun height
|
||||||
|
float sunElevation = Mathf.Sin(sunRotation * Mathf.Deg2Rad);
|
||||||
|
directionalLight.intensity = Mathf.Max(0, sunElevation);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1df4995bc2c404c47986a4f90cf3ca4f
|
||||||
Reference in New Issue
Block a user