open calendar with "c"

This commit is contained in:
j.mei7
2022-02-19 00:14:39 +01:00
parent a3db54a9b9
commit 439eb16d3b
15 changed files with 1236 additions and 123 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 419a6c97c6863fe4bba52001e71d1df1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
using System;
using UnityEngine;
using UnityEngine.UI;
public class Calendar : MonoBehaviour
{
TimeManager timeManager;
Image prevImage;
Transform daysTransform;
[SerializeField]
Color currentDayColor;
Color originDayColor;
private void Start()
{
daysTransform = transform.Find("Days");
timeManager = GameObject.Find("GameManager").GetComponent<TimeManager>();
originDayColor = daysTransform.Find("1").gameObject.GetComponent<Image>().color;
}
void Update()
{
if(gameObject.activeSelf)
RefreshCalendar();
}
void RefreshCalendar()
{
DateTime dateTime = timeManager.GetDateTime();
int counter;
int daysInMonth = DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
counter = 1;
while (counter <= 31)
{
if (counter >= daysInMonth + 1)
{
daysTransform.Find(counter.ToString()).gameObject.SetActive(false);
}
else
{
daysTransform.Find(counter.ToString()).gameObject.SetActive(true);
}
counter++;
}
if (prevImage != daysTransform.Find(dateTime.Day.ToString()).gameObject.GetComponent<Image>())
{
if (prevImage != null)
prevImage.color = originDayColor;
daysTransform.Find(dateTime.Day.ToString()).gameObject.GetComponent<Image>().color = currentDayColor;
prevImage = daysTransform.Find(dateTime.Day.ToString()).gameObject.GetComponent<Image>();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 96c62da3e09569940847187705433290
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,7 +5,14 @@ using UnityEngine;
// Handles the player input, such as interactions
public class PlayerController : MonoBehaviour
{
[SerializeField]
GameObject calendar;
void Update()
{
if (Input.GetButtonDown("Calendar") && calendar != null)
{
calendar.SetActive(!calendar.activeSelf);
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class TimeManager : MonoBehaviour
@@ -34,13 +35,10 @@ public class TimeManager : MonoBehaviour
{
dateTime = dateTime.AddMinutes(minutesPerInterval);
CheckPartsOfDay();
Debug.Log(GetTime());
}
void CheckPartsOfDay()
{
Debug.Log(dateTime.Hour);
if (dateTime.Hour >= 22)
partOfDay = PartOfDay.NIGHT;
else if(dateTime.Hour < 6)
@@ -52,6 +50,4 @@ public class TimeManager : MonoBehaviour
else if (dateTime.Hour >= 17 && dateTime.Hour < 22)
partOfDay = PartOfDay.EVENING;
}
// For Plant growth maybe add a List<GameObject/Script> where those plants can register themselves and every "TimeUp()" they get checked by the TimeManager
}