You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
5.6 KiB
C#
142 lines
5.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using SiegeSong;
|
|
using Gaia;
|
|
|
|
namespace SiegeSong
|
|
{
|
|
public class RuntimeManager : MonoBehaviour
|
|
{
|
|
public int MinuteOfHour
|
|
{
|
|
get
|
|
{
|
|
var timeOfDayRawValue = GaiaGlobal.GetTimeOfDayMainValue();
|
|
var totalMinute = (int)(timeOfDayRawValue * minutesInDay);
|
|
var hour = totalMinute / minutesInHour;
|
|
var minute = totalMinute - (hour * minutesInHour);
|
|
return minute;
|
|
}
|
|
}
|
|
|
|
public int HourOfDay
|
|
{
|
|
get
|
|
{
|
|
var timeOfDayRawValue = GaiaGlobal.GetTimeOfDayMainValue();
|
|
var totalMinute = (int)(timeOfDayRawValue * minutesInDay);
|
|
var hour = totalMinute / minutesInHour;
|
|
return hour;
|
|
}
|
|
}
|
|
|
|
public int DayOfYear;
|
|
public int DayOfMonth;
|
|
public int DayOfWeek;
|
|
public int WeekOfMonth;
|
|
public int MonthOfYear;
|
|
public int Year;
|
|
|
|
public GameObject PlayerInstance;
|
|
public GaiaScenePlayer GaiaPlayer;
|
|
public GameObject FogDataObject;
|
|
public FogVolumePriority FogPriority;
|
|
public FogVolume FogVolume;
|
|
public GaiaGlobal GaiaGlobalSettings;
|
|
public Suimono.Core.SuimonoModule WaterModule;
|
|
|
|
private int minutesInHour = 60;
|
|
private int minutesInDay = 1440;
|
|
private int daysInYear = 336;
|
|
private int monthsInYear = 12;
|
|
private int daysInWeek = 7;
|
|
|
|
private int inLoreBaseYear = 1131;
|
|
|
|
private int rawMinutes;
|
|
private string friendlyTime;
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
var newFriendlyTime = "";
|
|
var newRawMinutes = (int)(GaiaGlobal.GetTimeOfDayMainValue() * minutesInDay);
|
|
|
|
if (HourOfDay < 12)
|
|
newFriendlyTime = $"{(HourOfDay.ToString().Length == 2 ? HourOfDay : "0" + HourOfDay)}:{(MinuteOfHour.ToString().Length == 2 ? MinuteOfHour : "0" + MinuteOfHour)} AM";
|
|
else
|
|
newFriendlyTime = $"{((HourOfDay - 12).ToString().Length == 2 ? (HourOfDay - 12) : "0" + (HourOfDay - 12))}:{(MinuteOfHour.ToString().Length == 2 ? MinuteOfHour : "0" + MinuteOfHour)} PM";
|
|
|
|
if (friendlyTime != newFriendlyTime)
|
|
{
|
|
Debug.Log(newFriendlyTime);
|
|
Debug.Log($"Day - {DayOfYear} / Month - {MonthOfYear + 1} / Week of Month - {WeekOfMonth + 1} / Day of Month - {DayOfMonth}");
|
|
}
|
|
friendlyTime = newFriendlyTime;
|
|
|
|
if (rawMinutes > newRawMinutes)
|
|
{
|
|
if (DayOfYear == daysInYear)
|
|
{
|
|
Year++;
|
|
DayOfYear = 0;
|
|
var dayNumber = (DayOfMonth + 1).ToString();
|
|
var monthNumber = (MonthOfYear + 1).ToString();
|
|
PlayerInstance.GetComponentInChildren<NotificationManager>().Notify($"{(dayNumber.Length == 2 ? dayNumber : "0" + dayNumber)}/{(monthNumber.Length == 2 ? monthNumber : "0" + monthNumber)}/{Year + inLoreBaseYear} - The first day of Year {Year + 1} has begun.");
|
|
}
|
|
else
|
|
{
|
|
DayOfYear++;
|
|
var dayNumber = (DayOfMonth + 1).ToString();
|
|
var monthNumber = (MonthOfYear + 1).ToString();
|
|
PlayerInstance.GetComponentInChildren<NotificationManager>().Notify($"{(dayNumber.Length == 2 ? dayNumber : "0" + dayNumber)}/{(monthNumber.Length == 2 ? monthNumber : "0" + monthNumber)}/{Year + inLoreBaseYear} - A new day has begun.");
|
|
}
|
|
MonthOfYear = DayOfYear / monthsInYear;
|
|
DayOfMonth = DayOfYear % monthsInYear;
|
|
WeekOfMonth = (DayOfYear % monthsInYear) / daysInWeek;
|
|
DayOfWeek = (DayOfYear % monthsInYear) % daysInWeek;
|
|
}
|
|
rawMinutes = newRawMinutes;
|
|
}
|
|
|
|
public void PopulateReferences()
|
|
{
|
|
if (FogDataObject != null)
|
|
{
|
|
FogDataObject.GetComponent<FogVolumeData>().GameCamera = PlayerInstance.GetComponentInChildren<PlayerCameraManager>().ActiveCamera.GetComponentInChildren<Camera>();
|
|
}
|
|
|
|
if (FogPriority != null)
|
|
{
|
|
FogPriority.GameCamera = PlayerInstance.GetComponentInChildren<PlayerCameraManager>().ActiveCamera.GetComponentInChildren<Camera>();
|
|
}
|
|
|
|
if (FogVolume != null)
|
|
{
|
|
//FogVolume.FogVolumeData = FogDataObject;
|
|
FogVolume.AssignCamera();
|
|
}
|
|
|
|
if (GaiaPlayer != null)
|
|
{
|
|
GaiaPlayer.transform.parent = PlayerInstance.transform;
|
|
GaiaPlayer.transform.position = Vector3.zero;
|
|
}
|
|
|
|
if (WaterModule != null)
|
|
{
|
|
WaterModule.setTrack = PlayerInstance.transform;
|
|
WaterModule.setCamera = PlayerInstance.GetComponentInChildren<PlayerCameraManager>().ActiveCamera.transform.GetChild(0);
|
|
WaterModule.mainCamera = PlayerInstance.GetComponentInChildren<PlayerCameraManager>().ActiveCamera.transform.GetChild(0);
|
|
WaterModule.manualCamera = PlayerInstance.GetComponentInChildren<PlayerCameraManager>().ActiveCamera.transform.GetChild(0);
|
|
}
|
|
|
|
GaiaGlobalSettings.m_mainCamera = PlayerInstance.GetComponentInChildren<PlayerCameraManager>().ActiveCamera.GetComponentInChildren<Camera>();
|
|
}
|
|
}
|
|
} |