-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' 목록이 있습니다 .... –