コード例 #1
0
ファイル: GameStateTool.cs プロジェクト: AnkisCZ/HeroesReplay
        public async Task <StormState> GetStateAsync(Replay replay, StormState currentState)
        {
            TimeSpan?elapsed = await heroesOfTheStorm.TryGetTimerAsync();

            if (elapsed != null && elapsed != TimeSpan.Zero)
            {
                TimeSpan next = replayHelper.RemoveNegativeOffset(elapsed.Value);

                if (replayHelper.IsNearEnd(replay, next))
                {
                    return(new StormState(next, GameState.EndOfGame));
                }
                if (next <= TimeSpan.Zero)
                {
                    return(new StormState(next, GameState.StartOfGame));
                }
                if (next > currentState.Timer)
                {
                    return(new StormState(next, GameState.Running));
                }
                if (next < currentState.Timer)
                {
                    return(new StormState(next, GameState.Paused));
                }
                return(new StormState(next, currentState.State));
            }

            if (replayHelper.IsNearEnd(replay, currentState.Timer))
            {
                return(new StormState(currentState.Timer, GameState.EndOfGame));
            }


            return(currentState);
        }
コード例 #2
0
 public async Task <StormState> GetStateAsync(StormReplay stormReplay, StormState currentState)
 {
     return(await stateTool.GetStateAsync(stormReplay.Replay, currentState));
 }
コード例 #3
0
 public static bool IsStart(this StormState stormState) => stormState.State == GameState.StartOfGame;
コード例 #4
0
 public static bool IsPaused(this StormState stormState) => stormState.State == GameState.Paused;
コード例 #5
0
 public static bool IsRunning(this StormState stormState) => stormState.State == GameState.Running;
コード例 #6
0
 public static bool IsEnd(this StormState stormState) => stormState.State == GameState.EndOfGame;