Ejemplo n.º 1
0
 private void NextTurn(Events.MoveMadeEventArgs args)
 {
     if (!IsGameOver)
     {
         StartCoroutine(WaitForCheckMateCheckRoutine(args));
     }
 }
Ejemplo n.º 2
0
 private void OnMoveMade(Events.MoveMadeEventArgs args)
 {
     if (args.PieceColor != Color)
     {
         LastMoveSpecialCase = false;
     }
 }
Ejemplo n.º 3
0
    private IEnumerator WaitForCheckMateCheckRoutine(Events.MoveMadeEventArgs args)
    {
        yield return(new WaitForSeconds(args.WaitTime + .2f));

        PieceColor storedCurrentTurn = CurrentTurn == PieceColor.Blue ? PieceColor.Blue : PieceColor.Red;

        while (CurrentGameBoard.WaitingForPromotion)
        {
            yield return(null);
        }

        CurrentTurn = PieceColor.None;

        StartCoroutine(CurrentGameBoard.CheckIfCheckMate(storedCurrentTurn == PieceColor.Blue ? PieceColor.Red : PieceColor.Blue));

        while (CurrentGameBoard.RunningCheckMateCheck)
        {
            yield return(null);
        }

        if (CurrentGameBoard.CheckMate && args.Checking)
        {
            GameOver(storedCurrentTurn, "Checkmate!");
        }
        else if (CurrentGameBoard.CheckMate && !args.Checking)
        {
            GameOver(PieceColor.None, "Stalemate!");
        }
        else
        {
            if (args.Checking)
            {
                UIConsole.Instance.Log("Check!", UIConsole.Instance.ImportantMessage);
            }

            _pauseTimer = true;

            CurrentTurn = storedCurrentTurn == PieceColor.Blue ? PieceColor.Red : PieceColor.Blue;

            UIConsole.Instance.Log($"{CurrentTurn}'s Move", UIConsole.Instance.TurnMessage);
        }
    }