refactor
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 498c3ad6d3a87f74bb2d659f4ef55525
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f29a36e328b7dd48988057b39cb810e
|
||||
guid: 4e8c25231560207498886874c90ec7ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4add4f03070ea3f46a3e4aea1fc71585
|
||||
guid: 0943ab7a4aa9faa4facefc0e7852bbc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
public static class ExtentionMethods
|
||||
{
|
||||
public static string GetDayName(this TimeSpan time)
|
||||
{
|
||||
switch (time.Days % 7)
|
||||
{
|
||||
case 0:
|
||||
return "Sunday";
|
||||
case 1:
|
||||
return "Monday";
|
||||
case 2:
|
||||
return "Tuesday";
|
||||
case 3:
|
||||
return "Wednesday";
|
||||
case 4:
|
||||
return "Thursday";
|
||||
case 5:
|
||||
return "Friday";
|
||||
case 6:
|
||||
return "Saturday";
|
||||
}
|
||||
return "ooops";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32bb24701f5677f4a9ebb408a9b3cd9a
|
||||
guid: c293aa502df7f5a49870c228a9e9dca2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c67621cbedb3453428fcc7207806f507
|
||||
guid: 70ee3205d7b15b4449cdacc7a726e220
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e0f7035780121c4c9c8d64f9f1c6593
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+45
-45
@@ -1,45 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraPlayerFollow : MonoBehaviour
|
||||
{
|
||||
private Vector3 _cameraOffset;
|
||||
|
||||
private Transform _obstruction;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0.01f, 1.0f)]
|
||||
private float _smoothFactor = 0.5f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_obstruction = null;
|
||||
_cameraOffset = transform.position - Player.Instance.transform.position;
|
||||
// .LookAt(_player);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
Vector3 newPosition = Player.Instance.transform.position + _cameraOffset;
|
||||
|
||||
transform.position = Vector3.Slerp(transform.position, newPosition, _smoothFactor);
|
||||
ViewObstructed();
|
||||
}
|
||||
|
||||
private void ViewObstructed()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position, Player.Instance.transform.position - transform.position, out hit, 3.5f))
|
||||
{
|
||||
if (hit.collider.gameObject.tag != "Player")
|
||||
{
|
||||
_obstruction = hit.transform;
|
||||
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
|
||||
}
|
||||
}
|
||||
else if (_obstruction != null)
|
||||
{
|
||||
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
||||
_obstruction = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraPlayerFollow : MonoBehaviour
|
||||
{
|
||||
private Vector3 _cameraOffset;
|
||||
|
||||
private Transform _obstruction;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0.01f, 1.0f)]
|
||||
private float _smoothFactor = 0.5f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_obstruction = null;
|
||||
_cameraOffset = transform.position - Player.Instance.transform.position;
|
||||
// .LookAt(_player);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
Vector3 newPosition = Player.Instance.transform.position + _cameraOffset;
|
||||
|
||||
transform.position = Vector3.Slerp(transform.position, newPosition, _smoothFactor);
|
||||
ViewObstructed();
|
||||
}
|
||||
|
||||
private void ViewObstructed()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position, Player.Instance.transform.position - transform.position, out hit, 3.5f))
|
||||
{
|
||||
if (hit.collider.gameObject.tag != "Player")
|
||||
{
|
||||
_obstruction = hit.transform;
|
||||
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
|
||||
}
|
||||
}
|
||||
else if (_obstruction != null)
|
||||
{
|
||||
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
||||
_obstruction = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4e1e654ad8309241b3a54f10170ea2c
|
||||
guid: 6e81c6202b4f1294cb16972d7a25eeb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ba7a715b2719ca45aa1d964bc9d2f92
|
||||
guid: 8b80f4c0c91e48e418ea436255074f8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59acbdefe19456b4093c8081fc195458
|
||||
guid: e7675785cd5331f4bb7a2aa78bf300fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cfda29cc43f07b4f9af450516d8a828
|
||||
guid: 7a74888cae6f9f14ba0d76cfc5c0198a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3ae2c077e8e7c041b87a85a0ff8dd4c
|
||||
guid: dcf28888027a4ab4ba2df2a33b89899e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcc540dae28291b498a66c667c22bc3a
|
||||
guid: 7819b8e1ad3797d4da4153a0bfd3ebac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbd507d46c2bcc940b91fc92a2dfe513
|
||||
guid: fbda389b6a6aec14997efc4be22664e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,139 +1,138 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimeManager : MonoBehaviour
|
||||
{
|
||||
public static TimeManager Instance { get; private set; }
|
||||
|
||||
private const float MINUTE_TIME = 1f;
|
||||
private const float FF_TIME = 0.003f;
|
||||
|
||||
public Action OnMinuteChanged;
|
||||
public Action OnFastForwardEnd;
|
||||
|
||||
[SerializeField]
|
||||
private float _startHour;
|
||||
|
||||
//[SerializeField]
|
||||
//private Light _sunLight;
|
||||
|
||||
[SerializeField]
|
||||
private float _sunriseHour;
|
||||
[SerializeField]
|
||||
private float _sunsetHour;
|
||||
|
||||
private TimeSpan _sunriseTime;
|
||||
private TimeSpan _sunsetTime;
|
||||
|
||||
private float _timer;
|
||||
private float _sunInitialIntensity;
|
||||
|
||||
private float _minuteToRealTime;
|
||||
|
||||
private static TimeSpan _currentTime;
|
||||
public static TimeSpan CurrentTime => _currentTime;
|
||||
|
||||
|
||||
|
||||
private TimeSpan _timeToStop;
|
||||
|
||||
private bool _isPause = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// _sunInitialIntensity = _sunLight.intensity;
|
||||
_timer = _minuteToRealTime;
|
||||
_currentTime = TimeSpan.Zero + TimeSpan.FromHours(_startHour);
|
||||
_timeToStop = _currentTime;
|
||||
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
|
||||
_sunsetTime = TimeSpan.FromHours(_sunsetHour);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!_isPause)
|
||||
{
|
||||
UpdateTime();
|
||||
RotateSun();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTime()
|
||||
{
|
||||
_timer -= Time.deltaTime;
|
||||
if (_timer <= 0)
|
||||
{
|
||||
_currentTime = _currentTime.Add(TimeSpan.FromMinutes(1));
|
||||
OnMinuteChanged?.Invoke();
|
||||
|
||||
if (_currentTime.TotalMinutes >= _timeToStop.TotalMinutes)
|
||||
{
|
||||
_minuteToRealTime = MINUTE_TIME;
|
||||
_timeToStop = TimeSpan.MaxValue;
|
||||
OnFastForwardEnd?.Invoke();
|
||||
}
|
||||
_timer = _minuteToRealTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void FastForward(TimeSpan timeToStop)
|
||||
{
|
||||
_isPause = false;
|
||||
_timeToStop = _currentTime.Add(timeToStop);
|
||||
_minuteToRealTime = FF_TIME;
|
||||
}
|
||||
|
||||
private void RotateSun()
|
||||
{
|
||||
float intensityMultiplier = 1;
|
||||
float timeofDay = (float)(CurrentTime.TotalDays - CurrentTime.Days);
|
||||
//_sunLight.transform.localRotation = Quaternion.Euler((timeofDay * 360f) - 90, 170, 0);
|
||||
if (timeofDay > _sunriseTime.TotalDays && timeofDay < _sunsetTime.TotalDays)
|
||||
{
|
||||
if (timeofDay <= _sunsetTime.TotalDays)
|
||||
intensityMultiplier = Mathf.Clamp01((timeofDay - ((float)_sunsetTime.TotalDays - 0.02f)) * (1 / 0.02f));
|
||||
if (timeofDay >= _sunriseTime.TotalDays)
|
||||
intensityMultiplier = Mathf.Clamp01(1 - (timeofDay - ((float)_sunriseTime.TotalDays - 0.02f) * (1 / 0.02f)));
|
||||
}
|
||||
else
|
||||
{
|
||||
intensityMultiplier = 0;
|
||||
}
|
||||
// _sunLight.intensity = _sunInitialIntensity * intensityMultiplier;
|
||||
}
|
||||
|
||||
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)
|
||||
{
|
||||
TimeSpan diff = to - from;
|
||||
if (diff.TotalSeconds < 0)
|
||||
{
|
||||
diff += TimeSpan.FromHours(24);
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
_isPause = true;
|
||||
}
|
||||
|
||||
internal void Resume()
|
||||
{
|
||||
_isPause = false;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimeManager : MonoBehaviour
|
||||
{
|
||||
public static TimeManager Instance { get; private set; }
|
||||
|
||||
private const float MINUTE_TIME = 1f;
|
||||
private const float FF_TIME = 0.003f;
|
||||
|
||||
public Action OnMinuteChanged;
|
||||
public Action OnFastForwardEnd;
|
||||
|
||||
[SerializeField]
|
||||
private TimeSpan _startTime = new TimeSpan(1, 08, 00, 00);
|
||||
|
||||
//[SerializeField]
|
||||
//private Light _sunLight;
|
||||
|
||||
[SerializeField]
|
||||
private float _sunriseHour;
|
||||
[SerializeField]
|
||||
private float _sunsetHour;
|
||||
|
||||
private TimeSpan _sunriseTime;
|
||||
private TimeSpan _sunsetTime;
|
||||
|
||||
private float _timer;
|
||||
private float _sunInitialIntensity;
|
||||
|
||||
private float _minuteToRealTime;
|
||||
|
||||
private static TimeSpan _currentTime;
|
||||
public static TimeSpan CurrentTime => _currentTime;
|
||||
|
||||
|
||||
private TimeSpan _timeToStop;
|
||||
|
||||
private bool _isPause = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// _sunInitialIntensity = _sunLight.intensity;
|
||||
_timer = _minuteToRealTime;
|
||||
_currentTime = TimeSpan.Zero + _startTime;
|
||||
_timeToStop = _currentTime;
|
||||
_sunriseTime = TimeSpan.FromHours(_sunriseHour);
|
||||
_sunsetTime = TimeSpan.FromHours(_sunsetHour);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!_isPause)
|
||||
{
|
||||
UpdateTime();
|
||||
RotateSun();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTime()
|
||||
{
|
||||
_timer -= Time.deltaTime;
|
||||
if (_timer <= 0)
|
||||
{
|
||||
_currentTime = _currentTime.Add(TimeSpan.FromMinutes(1));
|
||||
OnMinuteChanged?.Invoke();
|
||||
|
||||
if (_currentTime.TotalMinutes >= _timeToStop.TotalMinutes)
|
||||
{
|
||||
_minuteToRealTime = MINUTE_TIME;
|
||||
_timeToStop = TimeSpan.MaxValue;
|
||||
OnFastForwardEnd?.Invoke();
|
||||
}
|
||||
_timer = _minuteToRealTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void FastForward(TimeSpan timeToStop)
|
||||
{
|
||||
_isPause = false;
|
||||
_timeToStop = _currentTime.Add(timeToStop);
|
||||
_minuteToRealTime = FF_TIME;
|
||||
}
|
||||
|
||||
private void RotateSun()
|
||||
{
|
||||
float intensityMultiplier = 1;
|
||||
float timeofDay = (float)(CurrentTime.TotalDays - CurrentTime.Days);
|
||||
//_sunLight.transform.localRotation = Quaternion.Euler((timeofDay * 360f) - 90, 170, 0);
|
||||
if (timeofDay > _sunriseTime.TotalDays && timeofDay < _sunsetTime.TotalDays)
|
||||
{
|
||||
if (timeofDay <= _sunsetTime.TotalDays)
|
||||
intensityMultiplier = Mathf.Clamp01((timeofDay - ((float)_sunsetTime.TotalDays - 0.02f)) * (1 / 0.02f));
|
||||
if (timeofDay >= _sunriseTime.TotalDays)
|
||||
intensityMultiplier = Mathf.Clamp01(1 - (timeofDay - ((float)_sunriseTime.TotalDays - 0.02f) * (1 / 0.02f)));
|
||||
}
|
||||
else
|
||||
{
|
||||
intensityMultiplier = 0;
|
||||
}
|
||||
// _sunLight.intensity = _sunInitialIntensity * intensityMultiplier;
|
||||
}
|
||||
|
||||
private TimeSpan CalculateTimeDifference(TimeSpan from, TimeSpan to)
|
||||
{
|
||||
TimeSpan diff = to - from;
|
||||
if (diff.TotalSeconds < 0)
|
||||
{
|
||||
diff += TimeSpan.FromHours(24);
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
_isPause = true;
|
||||
}
|
||||
|
||||
internal void Resume()
|
||||
{
|
||||
_isPause = false;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98af8458d80ad3a489a169272f679b4c
|
||||
guid: 00bbfcf5f7cdbb543bd6e09cd773f199
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae5ecbfd9a3637247b4cd539f9a57316
|
||||
guid: a49cd67cb3095a74d9b654426bc046b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,10 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Startup : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
// SceneManager.LoadScene(1);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -45,17 +44,17 @@ public class ModalWindowPanel : MonoBehaviour
|
||||
[SerializeField]
|
||||
private Button _declineButton;
|
||||
|
||||
private Action onConfirmAction;
|
||||
private Action onDeclineAction;
|
||||
//private Action onConfirmAction;
|
||||
//private Action onDeclineAction;
|
||||
|
||||
public void Confirm()
|
||||
{
|
||||
onConfirmAction?.Invoke();
|
||||
// onConfirmAction?.Invoke();
|
||||
// Close();
|
||||
}
|
||||
public void Decline()
|
||||
{
|
||||
onDeclineAction?.Invoke();
|
||||
// onDeclineAction?.Invoke();
|
||||
//Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class TopBarUI : MonoBehaviour
|
||||
{
|
||||
if (_timeText != null)
|
||||
{
|
||||
_timeText.text = TimeManager.CurrentTime.ToString(@"hh\:mm");
|
||||
_timeText.text = $"{TimeManager.CurrentTime.GetDayName()} {TimeManager.CurrentTime.ToString(@"hh\:mm")} day ({TimeManager.CurrentTime.Days})";
|
||||
}
|
||||
|
||||
_energy.value = (float)Player.Instance.Stats[StatsId.Energy].Value;
|
||||
|
||||
Reference in New Issue
Block a user