-4
我想爲我的遊戲代碼空中包廂排序的系統列表值匹配。它會在某個特定的時間開始變黑,並且在某個特定的時間開始變亮(在黑暗之後)。我在尋找的是如何檢查服務器時間是否在這些時間段之間?檢查,如果一個時間範圍,C#
using System.Collections.Generic;
namespace Game.GameEnvironment
{
class GameEnvironmentHandler
{
/// <summary>
/// List of dark times.
/// </summary>
private List<string> _darkTimes;
/// <summary>
/// List of light times.
/// </summary>
private List<string> _lightTimes;
public GameEnvironmentHandler()
{
// any time before 19:00 and after 08:00 is also light.
_darkTimes = new List<string>
{
"19:00", // getting dark
"19:30",
"20:00",
"20:30",
"21:00" // fully dark
};
_lightTimes = new List<string>
{
"06:00", // getting light
"06:30",
"07:00",
"07:30",
"08:00" // fully light
};
}
/// <summary>
/// Checks if its hit the first stage of dark times.
/// </summary>
/// <returns></returns>
public bool IsGettingDark()
{
}
/// <summary>
/// Checks if its hit the first stage of light times.
/// </summary>
/// <returns></returns>
public bool IsGettingLight()
{
}
/// <summary>
/// Gets what stage of getting dark or light its at (1-5)
/// </summary>
/// <returns></returns>
public int GetTimeStage()
{
return 0;
}
}
}
使用'Timespan'作爲你的存儲機制 –
Timespan需要手動輸入時間,你不能以編程方式從列表中加載它(不是我所知道的) –
有一個'Timespan'列表.... –