GlobalGameJame/Assets/Scripts/NightDayParticles.cs

44 lines
1005 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NightDayParticles : MonoBehaviour
{
public GameObject parentParticle;
public bool activeInDay = false;
public bool activeInNight = false;
public DayManager dayManager;
bool night = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float sunRotationX = dayManager.transform.localEulerAngles.x;
sunRotationX = (sunRotationX > 180) ? sunRotationX - 360 : sunRotationX;
if (sunRotationX < 0 && !night)
{
night = true;
}
else if (sunRotationX > 0 && night)
{
night = false;
}
if ((activeInDay && !night) || (activeInNight && night))
{
parentParticle.SetActive(true);
}
else
{
parentParticle.SetActive(false);
}
}
}