コード例 #1
0
        Task IMultiplayerClient.MatchRoomStateChanged(MatchRoomState state)
        {
            Scheduler.Add(() =>
            {
                if (Room == null)
                {
                    return;
                }

                Room.MatchState = state;
                RoomUpdated?.Invoke();
            }, false);

            return(Task.CompletedTask);
        }
コード例 #2
0
        private void TransitionToState(MatchRoomState state)
        {
            var m_oldState = m_state;

            m_state = state;

            switch (m_state)
            {
            case MatchRoomState.None:
                m_matchButtonText.text = "Find Match";
                // the player can abort from any of the other states to the None state
                // so we need to be careful to clean up all state variables
                m_remotePlayer = null;
                Matchmaking.Cancel();
                if (m_matchRoom != 0)
                {
                    Rooms.Leave(m_matchRoom);
                    m_matchRoom = 0;
                }
                break;

            case MatchRoomState.Queued:
                Assert.AreEqual(MatchRoomState.None, m_oldState);
                m_matchButtonText.text = "Leave Queue";
                Matchmaking.Enqueue2(POOL).OnComplete(MatchmakingEnqueueCallback);
                break;

            case MatchRoomState.Configuring:
                Assert.AreEqual(MatchRoomState.Queued, m_oldState);
                m_matchButtonText.text = "Cancel Match";
                break;

            case MatchRoomState.MyTurn:
            case MatchRoomState.RemoteTurn:
                Assert.AreNotEqual(MatchRoomState.None, m_oldState);
                Assert.AreNotEqual(MatchRoomState.Queued, m_oldState);
                m_matchButtonText.text = "Cancel Match";
                break;
            }
        }