コード例 #1
0
    void Ready(LobbyMessageInfo info)
    {
        LobbyPlayer player = GetLobbyPlayer(info);

        LogManager.General.Log(string.Format("Player '{0}' is now ready after logging in, connecting him to town", player.name));

        // Return player to his location in the game world
        LocationsDB.GetLocation(player.accountId, (data) => {
            // If that's the first time logging in, set the location to the default map
            if (data == null)
            {
                data = new PlayerLocation(MapManager.startingMap, ServerType.World);
            }

            // This will connect the player to a new or existing server
            // using the location data we just received.
            player.location = data;
        });

        // Add player to chat channels
        LobbyServer.globalChannel.AddPlayer(player);
        LobbyServer.announceChannel.AddPlayer(player);

        // Login message
        SendSystemMessage(player, loginMessage);
    }
コード例 #2
0
    // Helper function
    private void ConnectToGameServer(uZone.InstanceProcess instance)
    {
        LogManager.General.Log("Connecting player '" + name + "' to " + gameInstance);

        var ip   = instance.node.publicAddress;
        var port = instance.port;

        // Connect player to server
        Lobby.RPC("ConnectToGameServer", peer, ip, port);

        // Update location
        location.ip   = ip;
        location.port = port;
        LocationsDB.SetLocation(accountId, location, null);
    }
コード例 #3
0
    // Start
    void Start()
    {
        // Player
        playerCommands = new ChatCommand <LobbyPlayer>[] {
            // practice
            new ChatCommand <LobbyPlayer>(
                @"^practice$",
                (player, args) => {
                if (!player.inMatch)
                {
                    LobbyQueue.CreatePracticeMatch(player);
                }
                else
                {
                    // Notify player ...
                }
            }
                ),

            // online
            new ChatCommand <LobbyPlayer>(
                @"^online$",
                (player, args) => {
                LobbyServer.SendSystemMessage(player, "Players online: " + LobbyPlayer.list.Count);
            }
                )
        };

        // VIP
        vipCommands = new ChatCommand <LobbyPlayer>[] {
            // list
            new ChatCommand <LobbyPlayer>(
                @"^list$",
                (player, args) => {
                LobbyServer.SendSystemMessage(player, "Town: " + LobbyTown.running.Count);
                LobbyServer.SendSystemMessage(player, "World: " + LobbyWorld.running.Count);
                LobbyServer.SendSystemMessage(player, "Arena: " + LobbyMatch.running.Count);
                LobbyServer.SendSystemMessage(player, "FFA: " + LobbyFFA.running.Count);
            }
                )
        };

        // Community Manager
        communityManagerCommands = new ChatCommand <LobbyPlayer>[] {
            // goto
            new ChatCommand <LobbyPlayer>(
                @"^goto ([^ ]+) (.*)$",
                (player, args) => {
                var serverType = ChatServer.GetServerType(args[0]);
                var mapName    = args[1];

                player.location = new PlayerLocation(mapName, serverType);
            }
                ),

            // moveToPlayer
            new ChatCommand <LobbyPlayer>(
                @"^moveToPlayer (.*)$",
                (player, args) => {
                var playerName = args[1];

                LobbyGameDB.GetAccountIdByPlayerName(playerName, accountId => {
                    if (accountId == null)
                    {
                        return;
                    }

                    PositionsDB.GetPosition(accountId, position => {
                        if (position == null)
                        {
                            position = new PlayerPosition();
                        }

                        LocationsDB.GetLocation(accountId, location => {
                            if (location == null)
                            {
                                return;
                            }

                            // TODO: This is not 100% correct as it might get overwritten by the server
                            PositionsDB.SetPosition(player.accountId, position);

                            player.location = location;
                        });
                    });
                });
            }
                ),
        };

        // Game Master
        gameMasterCommands = new ChatCommand <LobbyPlayer>[] {
            // start
            new ChatCommand <LobbyPlayer>(
                @"^start ([^ ]+) (.*)$",
                (player, args) => {
                var serverType = ChatServer.GetServerType(args[0]);
                var mapName    = args[1];

                switch (serverType)
                {
                case ServerType.FFA:
                    new LobbyFFA(mapName).Register();
                    break;

                case ServerType.Town:
                    new LobbyTown(mapName).Register();
                    break;
                }
            }
                ),
        };

        // Admin
        adminCommands = new ChatCommand <LobbyPlayer>[] {
        };

        // Make this class listen to lobby events
        Lobby.AddListener(this);
    }