Exemple #1
0
    static async void Tick()
    {
        g_WebServer.Update();
        await MatchmakingManager.Update();

        System.Threading.Thread.Sleep(1);
    }
        /// <summary>
        /// Joins matchmaker queue.
        /// </summary>
        /// <remarks>
        /// Nakama allows for joining multiple matchmakers, however for the purposes of this demo,
        /// we will allow only for joining a single matchmaking queue.
        /// </remarks>
        private async Task <bool> StartMatchmakerAsync()
        {
            if (ticket != null)
            {
                Debug.Log("Matchmaker already started");
                return(false);
            }

            ISocket socket = NakamaSessionManager.Instance.Socket;

            // Create params object with default values
            MatchmakingParams param = new MatchmakingParams();

            socket.OnMatchmakerMatched += OnMatchmakerMatched;
            // Join the matchmaker
            ticket = await MatchmakingManager.EnterQueueAsync(socket, param);

            if (ticket == null)
            {
                Debug.Log("Couldn't start matchmaker" + Environment.NewLine + "Try again later");
                socket.OnMatchmakerMatched -= OnMatchmakerMatched;
                return(false);
            }
            else
            {
                // Matchmaker queue joined
                return(true);
            }
        }
Exemple #3
0
    //**************************************************************************************************************
    //                                                                                                             *
    //      FUNCTIONS                                                                                              *
    //                                                                                                             *
    //**************************************************************************************************************

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Called when the script instance is being loaded.
    /// </summary>
    private void Awake()
    {
        // Initialize singleton
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
    }
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Exemple #5
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
Exemple #6
0
        public static Host CreateBaseServer <TGame>(int port, out MatchmakingManager <TGame, AccountImpl> roomManager)
            where TGame : Game <AccountImpl>, new()
        {
            Host host        = new Host(port);
            var  st          = new Storage();
            var  auth        = new Authorization(st);
            var  account     = new Account <AccountImpl>(auth, st);
            var  matchmaking = new Matchmaking <AccountImpl>(account, new PlayerQueueImpl());

            roomManager = new MatchmakingManager <TGame, AccountImpl>(matchmaking);
            return(CreateServer <TGame, AccountImpl>(port, auth, account, matchmaking, roomManager));
        }
Exemple #7
0
 void Start()
 {
     if (isLocalPlayer)
     {
         matchManager        = FindObjectOfType <MatchmakingManager> ();
         pController         = GetComponent <PlayerController> ();
         pController.enabled = false;
     }
     else
     {
         buttonMatchmaking.SetActive(false);
     }
 }
        /// <summary>
        /// Leaves matchmaker queue.
        /// </summary>
        private async Task <bool> StopMatchmakerAsync(IMatchmakerTicket ticket)
        {
            if (ticket == null)
            {
                Debug.Log("Couldn't stop matchmaker; matchmaking hasn't been started yet");
                return(false);
            }
            ISocket socket = NakamaSessionManager.Instance.Socket;
            bool    good   = await MatchmakingManager.LeaveQueueAsync(socket, ticket);

            this.ticket = null;
            socket.OnMatchmakerMatched -= OnMatchmakerMatched;
            return(good);
        }
Exemple #9
0
    private void Start()
    {
        GameMode gameMode = GameData.getInstance().getGameMode();

        if (gameMode == GameMode.MATCHMAKING)
        {
            Time.timeScale = 0f;
            matchManager   = GetComponent <MatchmakingManager>();
            matchManager.joinMatchMakingRoom();
        }
        else
        {
            startSinglePlayer();
        }
    }
Exemple #10
0
        public static Host CreateServer <TGame, TAccountModel>(
            int port,
            Authorization auth,
            Account <TAccountModel> account,
            Matchmaking <TAccountModel> matchmaking,
            MatchmakingManager <TGame, TAccountModel> roomManager)
            where TGame : Game <TAccountModel>, new()
            where TAccountModel : AccountModel, new()
        {
            Host host = new Host(port);

            host.AddModule(auth);
            host.AddModule(account);
            host.AddModule(matchmaking);
            host.AddModule(roomManager);
            return(host);
        }
Exemple #11
0
    void Awake()
    {
        // make sure only one instance of this manager ever exists
        if (s_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        s_instance = this;
        DontDestroyOnLoad(gameObject);

        Core.Initialize();
        m_matchmaking  = new MatchmakingManager();
        m_p2p          = new P2PManager();
        m_leaderboards = new LeaderboardManager();
        m_achievements = new AchievementsManager();
    }
Exemple #12
0
 void Start()
 {
     matchManager = FindObjectOfType <MatchmakingManager> ();
 }
 protected void SetContextualReadyState(ContextualReadyState contextualReadyState)
 {
     Log.Print(LogType.Debug, "SetContextualReadyState");
     MatchmakingManager.StartPractice(this);
 }