PotatoPlan/Game1/Sources/Objects/DayNightCycle.cs

80 lines
1.5 KiB
C#
Raw Normal View History

2020-05-06 16:22:30 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
class DayNightCycle
{
private bool Time = true;
private int nightTime = 0;
private int dayTime = 0;
private int lengthOfDay = 6000;
private int lengthOfNight = 6000;
public void updateTime(int Speed)
{
for (int i = 0; i < Speed; i++)
{
if (Time)
{
dayTime++;
if (dayTime == lengthOfDay)
{
Time = false;
dayTime = 0;
}
}
else
{
nightTime++;
if (nightTime == lengthOfNight)
{
Time = true;
nightTime = 0;
}
}
}
}
public string getDayNight()
{
if (Time)
{
return "Day";
}
else
{
return "Night";
}
}
public Color GetTimeOfDay()
{
int blue;
if (nightTime == 0 || dayTime == 0)
{
blue = 1;
}
else
{
blue = (6000 / nightTime);
}
return Color.FromNonPremultiplied(0, 0, blue, 100);
}
public int GetTimeOfDayInt()
{
if (Time)
{
return dayTime / 60;
}
else
{
return nightTime / 60;
}
}
}