コード例 #1
0
        private void Update()
        {
            if (clock != null)
            {
                myTimeText.text = Clock.FormatTime(
                    clock.MyDisplayTime
                    );

                opponentTimeText.text = Clock.FormatTime(
                    clock.OpponentDisplayTime
                    );

                if (myTurn && clock.IsTimeOverForMe())
                {
                    OnOurTimeOver();
                }
            }
        }
コード例 #2
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();
        }