Exemplo n.º 1
0
        void Start()
        {
            Matchmaking.SetMatchFoundNotificationCallback(MatchFoundCallback);
            Rooms.SetUpdateNotificationCallback(MatchmakingRoomUpdateCallback);

            TransitionToState(MatchRoomState.None);
        }
Exemplo n.º 2
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 3
0
        public void EndMatch(int localScore, int remoteScore)
        {
            switch (m_state)
            {
            case MatchRoomState.MyTurn:
            case MatchRoomState.RemoteTurn:
                var myID     = PlatformManager.MyID.ToString();
                var remoteID = m_remotePlayer.ID.ToString();
                var rankings = new Dictionary <string, int>();
                if (localScore > remoteScore)
                {
                    rankings[myID]     = 1;
                    rankings[remoteID] = 2;
                }
                else if (localScore < remoteScore)
                {
                    rankings[myID]     = 2;
                    rankings[remoteID] = 1;
                }
                else
                {
                    rankings[myID]     = 1;
                    rankings[remoteID] = 1;
                }

                // since there is no secure server to simulate the game and report
                // verifiable results, each client needs to independently report their
                // results for the service to compate for inconsistencies
                Matchmaking.ReportResultsInsecure(m_matchRoom, rankings)
                .OnComplete(GenericErrorCheckCallback);
                break;
            }

            TransitionToState(MatchRoomState.None);
        }
Exemplo n.º 4
0
    new void Awake()
    {
        Debug.Log("*** GUEST ***");

        Assert.IsNotNull(context);

        state = GuestState.LoggingIn;

        InitializePlatformSDK(GetEntitlementCallback);

        Matchmaking.SetMatchFoundNotificationCallback(MatchFoundCallback);

        Rooms.SetUpdateNotificationCallback(RoomUpdatedCallback);

        Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);

        Net.SetPeerConnectRequestCallback(PeerConnectRequestCallback);

        Net.SetConnectionStateChangedCallback(ConnectionStateChangedCallback);

        Voip.SetVoipConnectRequestCallback((Message <NetworkingPeer> msg) =>
        {
            Debug.Log("Accepting voice connection from " + msg.Data.ID);
            Voip.Accept(msg.Data.ID);
        });

        Voip.SetVoipStateChangeCallback((Message <NetworkingPeer> msg) =>
        {
            Debug.LogFormat("Voice state changed to {1} for user {0}", msg.Data.ID, msg.Data.State);
        });
    }
Exemplo n.º 5
0
 private void Requeue(Request request)
 {
     if (!Matchmaking.AddRequestToQueue(request))
     {
         RemoveConnection(request.ID);
     }
 }
Exemplo n.º 6
0
        void requestStartRatedMatch()
        {
            switch (currentState)
            {
            case states.NOT_INIT:
                printOutputLine("The app has not initialized properly and we don't know your userID.");
                break;

            case states.IDLE:
            case states.REQUEST_FIND:
            case states.FINDING_ROOM:
            case states.REQUEST_JOIN:
            case states.REQUEST_CREATE:
            case states.REQUEST_LEAVE:
            case states.IN_EMPTY_ROOM:
                printOutputLine("You need to be in a room with another player to start a rated match.");
                break;

            case states.IN_FULL_ROOM:
                printOutputLine("Trying to start a rated match.  This call should be made once a rated match begins so we will be able to submit results after the game is done.");

                Matchmaking.StartMatch(currentRoom.ID).OnComplete(startRatedMatchResponse);
                break;

            default:
                printOutputLine("You have hit an unknown state.");
                break;
            }
        }
 public void StartMatchmaking()
 {
     if (Matchmaking == null)
     {
         Matchmaking = gameObject.AddComponent <Matchmaking>();
     }
 }
Exemplo n.º 8
0
 public bool DeepEquals(DestinyActivityDefinition?other)
 {
     return(other is not null &&
            (DisplayProperties is not null ? DisplayProperties.DeepEquals(other.DisplayProperties) : other.DisplayProperties is null) &&
            (OriginalDisplayProperties is not null ? OriginalDisplayProperties.DeepEquals(other.OriginalDisplayProperties) : other.OriginalDisplayProperties is null) &&
            (SelectionScreenDisplayProperties is not null ? SelectionScreenDisplayProperties.DeepEquals(other.SelectionScreenDisplayProperties) : other.SelectionScreenDisplayProperties is null) &&
            ReleaseIcon == other.ReleaseIcon &&
            ReleaseTime == other.ReleaseTime &&
            ActivityLightLevel == other.ActivityLightLevel &&
            DestinationHash == other.DestinationHash &&
            PlaceHash == other.PlaceHash &&
            ActivityTypeHash == other.ActivityTypeHash &&
            Tier == other.Tier &&
            PgcrImage == other.PgcrImage &&
            Rewards.DeepEqualsList(other.Rewards) &&
            Modifiers.DeepEqualsList(other.Modifiers) &&
            IsPlaylist == other.IsPlaylist &&
            Challenges.DeepEqualsList(other.Challenges) &&
            OptionalUnlockStrings.DeepEqualsList(other.OptionalUnlockStrings) &&
            PlaylistItems.DeepEqualsList(other.PlaylistItems) &&
            ActivityGraphList.DeepEqualsList(other.ActivityGraphList) &&
            (Matchmaking is not null ? Matchmaking.DeepEquals(other.Matchmaking) : other.Matchmaking is null) &&
            (GuidedGame is not null ? GuidedGame.DeepEquals(other.GuidedGame) : other.GuidedGame is null) &&
            DirectActivityModeHash == other.DirectActivityModeHash &&
            DirectActivityModeType == other.DirectActivityModeType &&
            Loadouts.DeepEqualsList(other.Loadouts) &&
            ActivityModeHashes.DeepEqualsListNaive(other.ActivityModeHashes) &&
            ActivityModeTypes.DeepEqualsListNaive(other.ActivityModeTypes) &&
            IsPvP == other.IsPvP &&
            InsertionPoints.DeepEqualsList(other.InsertionPoints) &&
            ActivityLocationMappings.DeepEqualsList(other.ActivityLocationMappings) &&
            Hash == other.Hash &&
            Index == other.Index &&
            Redacted == other.Redacted);
 }
Exemplo n.º 9
0
        public MatchmakingManager()
        {
            m_remotePlayers = new Dictionary <ulong, User>();

            Matchmaking.SetMatchFoundNotificationCallback(MatchFoundCallback);
            Rooms.SetUpdateNotificationCallback(MatchmakingRoomUpdateCallback);
        }
Exemplo n.º 10
0
        public void FindNearbyPeople()
        {
            //  Arrange
            var Matchmaking = new Matchmaking();
            int postCode    = 3000;
            int radius      = 20;

            //  Act

            int[] nearbyAreaCodes = Matchmaking.FindNearbyPeople(postCode, radius);

            //  Analyze =

            foreach (var areaCode in nearbyAreaCodes)
            {
                TestContext.WriteLine(areaCode.ToString());
            }

            string postnummer = string.Empty;

            for (int i = 0; i < nearbyAreaCodes.Length; i++)
            {
                if (i == 0)
                {
                    postnummer = postnummer + $"{nearbyAreaCodes[i]}";
                    continue;
                }
                postnummer = postnummer + $",{nearbyAreaCodes[i]}";
            }

            TestContext.WriteLine(postnummer);
            //  Assert
            Assert.IsNotNull(nearbyAreaCodes);
        }
Exemplo n.º 11
0
 void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
 {
     if (scene.buildIndex != 1 && scene.buildIndex != 0)
     {
         Matchmaking.JoinToAnyBattleOfType(myMode);
     }
 }
Exemplo n.º 12
0
    void MatchFoundCallback(Message <Room> msg)
    {
        Debug.Log("Found match. Room id = " + msg.Data.ID);

        roomId = msg.Data.ID;

        Matchmaking.JoinRoom(msg.Data.ID, true).OnComplete(JoinRoomCallback);
    }
Exemplo n.º 13
0
 void OnApplicationQuit()
 {
     // be a good matchmaking citizen and leave any queue immediately
     Matchmaking.Cancel();
     if (m_matchRoom != 0)
     {
         Rooms.Leave(m_matchRoom);
     }
 }
Exemplo n.º 14
0
        public async void LoadProfiles()
        {
            int postalCode  = _profileRepo.GetProfilePostalcode(ProfileID);
            var matchmaking = new Matchmaking();

            int[] nearbyMAtches = matchmaking.FindNearbyPeople(postalCode, 30);
            AllProfiles    = new ObservableCollection <Profiles>(await _profileRepo.GetProfileAsync());
            NearbyProfiles = new ObservableCollection <Profiles>(AllProfiles.Where(c => nearbyMAtches.Contains(c.FK_Postalcode)));
        }
Exemplo n.º 15
0
        private void ProcessRoomData(Room room)
        {
            m_lastUpdateTime = Time.time;

            if (m_state == MatchRoomState.Configuring)
            {
                // get the User info for the other player
                if (room.UsersOptional != null)
                {
                    foreach (var user in room.UsersOptional)
                    {
                        if (PlatformManager.MyID != user.ID)
                        {
                            Debug.Log("Found remote user: "******"")
            {
                // process remote move
                ProcessRemoteMove(room.DataStore[m_remotePlayer.OculusID]);
                TransitionToState(MatchRoomState.MyTurn);
            }

            // If the room ownership transferred to me, we can mark the remote turn complete.
            // We don't do this when the remote move comes in if we aren't yet the owner because
            // the local user will not be able to write to the datastore if they aren't the
            // owner of the room.
            if (m_state == MatchRoomState.MyTurn && room.OwnerOptional != null && room.OwnerOptional.ID == PlatformManager.MyID)
            {
                m_gameController.MarkRemoteTurnComplete();
            }

            if (room.UsersOptional == null || (room.UsersOptional != null && room.UsersOptional.Count != 2))
            {
                Debug.Log("Other user quit the room");
                m_gameController.RemoteMatchEnded();
            }
        }
Exemplo n.º 16
0
 public static async Task RandomBattleRequest(Client client, CommandHandler command)
 {
     try
     {
         client.TierSelected = Matchmaking.GetTier(command.Data["species"]);
     }
     catch
     {
         client.TierSelected = Tiers.Ag;
     }
     await client.SendMessage($"<RANTIER tier={Enum.GetName(typeof(Tiers), client.TierSelected)}>");
 }
Exemplo n.º 17
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));
        }
Exemplo n.º 18
0
 public void AddClientToQueue(NetworkConnection clientConnection, ClientInitializeGamePackage initData)
 {
     if (Matchmaking.AddRequestToQueue(clientConnection.ClientSession.SessionID, initData.GamePlayerCount, initData.PlayerTeamwish))
     {
         m_waitingClientConnections.Add(clientConnection);
         SendMatchmakingStatus(clientConnection, string.Format(WAITING_IN_QUEUE, TotalPlayersOnlineCallback(), TotalPlayersSearching()));
         clientConnection.ConnectionDiedEvent += RemoveConnection;
     }
     else
     {
         SendMatchmakingError(clientConnection, INVALID_REQUEST);
     }
 }
Exemplo n.º 19
0
    void StartMatchmaking()
    {
        var options = new MatchmakingOptions();

        options.SetEnqueueQueryKey("quickmatch_query");
        options.SetCreateRoomJoinPolicy(RoomJoinPolicy.Everyone);
        options.SetCreateRoomMaxUsers(MaxClients);
        options.SetEnqueueDataSettings("version", Constants.Version.GetHashCode());

        Matchmaking.Enqueue2("quickmatch", options).OnComplete(MatchmakingEnqueueCallback);
        timeMatchmakingStarted = renderTime;
        state = InMatchmaking;
    }
Exemplo n.º 20
0
    void RetryUntilConnectedToServer()
    {
        Matchmaking.Cancel();
        DisconnectFromServer();
        if (isConnected)
        {
            return;
        }

        Debug.Log("Retrying in " + RetryTime + " seconds...");
        timeRetryStarted = renderTime;
        state            = WaitingForRetry;
    }
Exemplo n.º 21
0
        public async Task Matchmake(params string[] users)
        {
            if (users.Length != 10 && users.Length != 20)
            {
                await ReplyAsync($"The command needs exactly 10 or 20 user nicknames, you have provided {users.Length}. Use double quotes for nicknames with special characters, such as \"Pepa Novak\".");
            }
            else
            {
                await ReplyAsync("Trying to matchmake, please give me a few seconds.");

                Matchmaking m = new Matchmaking();
                _ = m.BuildTeams(Bot.Instance, Context.Guild.Id, Context.Channel, users);
            }
        }
Exemplo n.º 22
0
        public MatchmakingViewModel(IDialogCoordinator DialogCoordinator)
        {
            this._dialogCoordinator = DialogCoordinator;
            this._matchmaking       = new Matchmaking();

            // Read all the champions into an observable collection
            this._champions        = new ObservableCollection <Champion>(this._matchmaking.GetAllChampions());
            this._selectedChampion = this._champions[2];

            // Fill in the possibles lanes
            this._lanes = new ObservableCollection <string> {
                "Top", "Mid", "Bot", "Support", "Jungle"
            };
            this._selectedLane = this._lanes[1];
        }
Exemplo n.º 23
0
        void requestFindRoom()
        {
            switch (currentState)
            {
            case states.NOT_INIT:
                printOutputLine("The app has not initialized properly and we don't know your userID.");
                break;

            case states.IDLE:
                printOutputLine("\nTrying to find a matchmaking room\n");

                Matchmaking.Enqueue(Constants.FILTER_POOL, null).OnComplete(searchingStarted);
                currentState = states.REQUEST_FIND;
                break;

            case states.REQUEST_FIND:
                printOutputLine("You have already made a request to find a room.  Please wait for that request to complete.");
                break;

            case states.FINDING_ROOM:
                printOutputLine("You have already currently looking for a room.  Please wait for the match to be made.");
                break;

            case states.REQUEST_JOIN:
                printOutputLine("We are currently trying to join a room.  Please wait to see if we can join it.");
                break;

            case states.REQUEST_LEAVE:
                printOutputLine("We are currently trying to leave a room.  Please wait to see if we can leave it.");
                break;

            case states.REQUEST_CREATE:
                printOutputLine("You have already requested a matchmaking room to be created.  Please wait for the room to be made.");
                break;

            case states.IN_EMPTY_ROOM:
                printOutputLine("You have already in a matchmaking room.  Please wait for an opponent to join.");
                break;

            case states.IN_FULL_ROOM:
                printOutputLine("You have already in a match.");
                break;

            default:
                printOutputLine("You have hit an unknown state.");
                break;
            }
        }
Exemplo n.º 24
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile       from = sender.Mobile;
            PlayerMobile pm   = from as PlayerMobile;

            if (from == null || pm == null)
            {
                return;
            }

            bool redsallowed = info.IsSwitched(666);
            int  type        = info.IsSwitched(998) ? 0 : 1;

            switch (info.ButtonID)
            {
            case 0:
            {
                // Close on right click.
                break;
            }

            case 1:      // Okay
            {
                Matchmaking.WaitForParty(from, redsallowed, type);
                if (pm.HasGump(typeof(MatchmakingCreateGump)))
                {
                    pm.CloseGump(typeof(MatchmakingCreateGump));
                }

                if (pm.HasGump(typeof(MatchmakingGump)))
                {
                    pm.CloseGump(typeof(MatchmakingGump));
                }

                pm.SendGump(new MatchmakingGump(pm, 0));

                break;
            }

            case 2:     // Cancel
            {
                // Just close the gump.
                break;
            }
            }
        }
Exemplo n.º 25
0
        public static Host CreateClient <TAccountModel>(
            int port,
            out Authorization auth,
            out Matchmaking <TAccountModel> matchmaking)
            where TAccountModel : AccountModel, new()
        {
            Host host = new Host(port);

            auth = new Authorization();
            var account = new Account <TAccountModel>();

            matchmaking = new Matchmaking <TAccountModel>(account);
            host.AddModule(auth);
            host.AddModule(account);
            host.AddModule(matchmaking);
            return(host);
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
0
        // Use this for initialization
        void Start()
        {
            currentState      = states.NOT_INIT;
            localUser         = null;
            remoteUser        = null;
            currentRoom       = null;
            lastPacketID      = 0;
            ratedMatchStarted = false;

            Core.Initialize();

            // Setup our room update handler
            Rooms.SetUpdateNotificationCallback(updateRoom);
            // Setup our match found handler
            Matchmaking.SetMatchFoundNotificationCallback(foundMatch);

            checkEntitlement();
        }
Exemplo n.º 28
0
    protected override void OnQuit()
    {
        Matchmaking.Cancel();

        if (IsConnectedToServer())
        {
            DisconnectFromServer();
        }

        if (roomId == 0)
        {
            isReadyToShutdown = true;
        }
        else
        {
            LeaveRoom(roomId, LeaveRoomOnQuitCallback);
        }
    }
Exemplo n.º 29
0
        void MatchFoundCallback(Message <Room> msg)
        {
            if (msg.IsError)
            {
                Debug.Log(msg.GetError().Message);
                TransitionToState(MatchRoomState.None);
                return;
            }

            if (m_state != MatchRoomState.Queued)
            {
                // ignore callback - user already cancelled
                return;
            }

            // since this example communicates via updates to the datastore, it's vital that
            // we subscribe to room updates
            Matchmaking.JoinRoom(msg.Data.ID, true /* subscribe to update notifications */)
            .OnComplete(MatchmakingJoinRoomCallback);
            m_matchRoom = msg.Data.ID;
        }
Exemplo n.º 30
0
 public bool DeepEquals(DestinyActivityDefinition other)
 {
     return(other != null &&
            ActivityGraphList.DeepEqualsReadOnlyCollections(other.ActivityGraphList) &&
            ActivityLevel == other.ActivityLevel &&
            ActivityLightLevel == other.ActivityLightLevel &&
            ActivityLocationMappings.DeepEqualsReadOnlyCollections(other.ActivityLocationMappings) &&
            ActivityModes.DeepEqualsReadOnlyCollections(other.ActivityModes) &&
            ActivityModeTypes.DeepEqualsReadOnlySimpleCollection(other.ActivityModeTypes) &&
            ActivityType.DeepEquals(other.ActivityType) &&
            Challenges.DeepEqualsReadOnlyCollections(other.Challenges) &&
            CompletionUnlockHash == other.CompletionUnlockHash &&
            Destination.DeepEquals(other.Destination) &&
            DirectActivityMode.DeepEquals(other.DirectActivityMode) &&
            DirectActivityModeType == other.DirectActivityModeType &&
            DisplayProperties.DeepEquals(other.DisplayProperties) &&
            (GuidedGame != null ? GuidedGame.DeepEquals(other.GuidedGame) : other.GuidedGame == null) &&
            InheritFromFreeRoam == other.InheritFromFreeRoam &&
            InsertionPoints.DeepEqualsReadOnlyCollections(other.InsertionPoints) &&
            IsPlaylist == other.IsPlaylist &&
            IsPvP == other.IsPvP &&
            (Matchmaking != null ? Matchmaking.DeepEquals(other.Matchmaking) : other.Matchmaking == null) &&
            Modifiers.DeepEqualsReadOnlyCollections(other.Modifiers) &&
            OptionalUnlockStrings.DeepEqualsReadOnlyCollections(other.OptionalUnlockStrings) &&
            OriginalDisplayProperties.DeepEquals(other.OriginalDisplayProperties) &&
            PgcrImage == other.PgcrImage &&
            Place.DeepEquals(other.Place) &&
            PlaylistItems.DeepEqualsReadOnlyCollections(other.PlaylistItems) &&
            ReleaseIcon == other.ReleaseIcon &&
            ReleaseTime == other.ReleaseTime &&
            Rewards.DeepEqualsReadOnlyCollections(other.Rewards) &&
            (SelectionScreenDisplayProperties != null ? SelectionScreenDisplayProperties.DeepEquals(other.SelectionScreenDisplayProperties) : other.SelectionScreenDisplayProperties == null) &&
            SuppressOtherRewards == other.SuppressOtherRewards &&
            Tier == other.Tier &&
            Loadouts.DeepEqualsReadOnlyCollections(other.Loadouts) &&
            Blacklisted == other.Blacklisted &&
            Hash == other.Hash &&
            Index == other.Index &&
            Redacted == other.Redacted);
 }