예제 #1
0
        public async void OurMoveWasFinished(ChessMove ourMove)
        {
            clock.StartMe();

            foreach (Vector2Int pos in Board.IteratePositions())
            {
                PieceId pieceId = board.GetPieceIdAt(pos);

                if (pieceId == null)
                {
                    continue;
                }

                if (pieceId.color != color)
                {
                    continue;
                }

                await Task.Delay(Random.Range(500, 5_000));

                float duration = clock.StopMe();

                if (clock.IsTimeOverForMe())
                {
                    OnOutOfTime?.Invoke();
                    return;
                }

                OnMoveFinish?.Invoke(new ChessMove {
                    origin   = pos,
                    target   = FindFreeSpot(),
                    duration = duration
                });
                return;
            }

            throw new Exception();
        }
예제 #2
0
 public void OtherSideRanOutOfTime()
 {
     OnOutOfTime?.Invoke();
 }