Exemplo n.º 1
0
    IEnumerator LeaveInstance(bool gameEnded, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        if (player.inMatch)
        {
            LogManager.General.Log("Player '" + player.name + "' returned from a match");

            if (gameEnded)
            {
                // Send him his new stats
                LobbyGameDB.GetPlayerStats(player);

                // Send him his new artifact inventory
                ArtifactsDB.GetArtifactInventory(player);

                // Update ranking list cache
                if (!player.match.updatedRankingList)
                {
                    RankingsServer.instance.StartRankingListCacheUpdate(player.match);
                    player.match.updatedRankingList = true;
                }
            }

            LeaveMatch(player);
        }
        else if (player.inFFA)
        {
            // Send him his new stats
            //StartCoroutine(lobbyGameDB.GetPlayerStats(player));

            // Update ranking list cache

            /*if(!player.match.updatedRankingList) {
             *      RankingsServer.instance.StartRankingListCacheUpdate(player.match);
             *      player.match.updatedRankingList = true;
             * }*/

            LeaveMatch(player);
        }
        else if (player.inTown || player.inWorld)
        {
            player.gameInstance = null;

            if (AccountManager.Master.IsLoggedIn(player.peer))
            {
                yield return(AccountManager.Master.LogOut(info.sender).WaitUntilDone());
            }
        }
    }
Exemplo n.º 2
0
    // Sends data about the account to any player
    public static void SendPublicAccountInfo(string accountId, LobbyPlayer toPlayer)
    {
        var player = GetLobbyPlayer(accountId);

        // Name
        LobbyGameDB.GetPlayerName(accountId, data => {
            if (data == null)
            {
                if (player == toPlayer)
                {
                    Lobby.RPC("AskPlayerName", toPlayer.peer);
                }
            }
            else
            {
                Lobby.RPC("ReceivePlayerName", toPlayer.peer, accountId, data);

                if (player == toPlayer)
                {
                    if (string.IsNullOrEmpty(player.name))
                    {
                        player.name = data;
                        LobbyServer.OnReceivePlayerName(player);
                    }
                }
            }
        });

        // Character customization
        CharacterCustomizationDB.GetCharacterCustomization(accountId, data => {
            if (data == null)
            {
                if (player == toPlayer)
                {
                    Lobby.RPC("CustomizeCharacter", toPlayer.peer, accountId);
                }
            }
            else
            {
                if (player != null)
                {
                    player.custom = data;
                }
                Lobby.RPC("ReceiveCharacterCustomization", toPlayer.peer, accountId, data);
            }
        });

        // Skill build
        SkillBuildsDB.GetSkillBuild(accountId, data => {
            if (data == null)
            {
                Lobby.RPC("ReceiveSkillBuild", toPlayer.peer, accountId, SkillBuild.GetStarterBuild());
            }
            else
            {
                Lobby.RPC("ReceiveSkillBuild", toPlayer.peer, accountId, data);
            }
        });

        // Stats
        LobbyGameDB.GetPlayerStats(accountId, data => {
            if (data == null)
            {
                data = new PlayerStats();
            }

            // Assign stats
            if (player != null)
            {
                player.stats = data;
            }

            // Send the stats to the player
            Lobby.RPC("ReceivePlayerStats", toPlayer.peer,
                      accountId,
                      Jboy.Json.WriteObject(data)
                      );
        });

        // FFA Stats
        LobbyGameDB.GetPlayerFFAStats(accountId, data => {
            if (data == null)
            {
                data = new PlayerStats();
            }

            // Assign stats
            if (player != null)
            {
                player.ffaStats = data;
            }

            // Send the stats to the player
            Lobby.RPC("ReceivePlayerFFAStats", toPlayer.peer,
                      accountId,
                      Jboy.Json.WriteObject(data)
                      );
        });

        // Character stats
        TraitsDB.GetCharacterStats(accountId, data => {
            if (data == null)
            {
                data = new CharacterStats();
            }

            if (player != null)
            {
                player.charStats = data;
            }

            Lobby.RPC("ReceiveCharacterStats", toPlayer.peer, accountId, data);
        });

        // Artifact inventory
        ArtifactsDB.GetArtifactInventory(accountId, data => {
            if (data == null)
            {
                data = new ArtifactInventory();
            }

            if (player != null)
            {
                player.artifactInventory = data;
            }

            Lobby.RPC("ReceiveArtifactInventory", toPlayer.peer, accountId, Jboy.Json.WriteObject(data));
        });

        // Artifact tree
        ArtifactsDB.GetArtifactTree(accountId, data => {
            if (data == null)
            {
                data = ArtifactTree.GetStarterArtifactTree();
            }

            if (player != null)
            {
                player.artifactTree = data;
            }

            Lobby.RPC("ReceiveArtifactTree", toPlayer.peer, accountId, Jboy.Json.WriteObject(data));
        });

        // Experience
        ExperienceDB.GetExperience(accountId, data => {
            uint exp = 0;

            if (data != null)
            {
                exp = data.experience;
            }

            Lobby.RPC("ReceiveExperience", toPlayer.peer, accountId, exp);
        });

        // Item inventory
        ItemInventoryDB.GetItemInventory(accountId, data => {
            if (data == null)
            {
                data = new ItemInventory();
            }

            if (player != null)
            {
                player.itemInventory = data;
            }

            Lobby.RPC("ReceiveItemInventory", toPlayer.peer, accountId, Jboy.Json.WriteObject(data));
        });

        // View profile
        Lobby.RPC("ViewProfile", toPlayer.peer, accountId);
    }