Exemplo n.º 1
0
    //private ItemInventoryDB itemInventoryDB;

    void Start()
    {
        //itemInventoryDB = GetComponent<ItemInventoryDB>();

        // Make this class listen to lobby events
        Lobby.AddListener(this);
    }
Exemplo n.º 2
0
 //function called when the user connects to the lobby
 public void ConnectToLobby()
 {
     clientActive = true;
     Lobby.AddListener(this);
     Lobby.ConnectAsClient(lobbyIP, lobbyPort);
     introSource.Play();
 }
    //private AccessLevelsDB accessLevelsDB;

    void Start()
    {
        //accessLevelsDB = this.GetComponent<AccessLevelsDB>();

        // Make this class listen to lobby events
        Lobby.AddListener(this);
    }
Exemplo n.º 4
0
 // Start
 void Start()
 {
     if (isClient)
     {
         Lobby.AddListener(this);
     }
 }
Exemplo n.º 5
0
    // Start
    void Start()
    {
        friendsList = null;

        // Listen to lobby events
        Lobby.AddListener(this);
    }
Exemplo n.º 6
0
    // Start
    void Start()
    {
        guildMenuState = GuildMenuState.ListGuilds;
        Lobby.AddListener(this);

        // Retrieve guild list when logging in
        AccountManager.OnAccountLoggedIn += OnAccountLoggedIn;
    }
Exemplo n.º 7
0
    void Start()
    {
#if LMS_Auth
        StartCoroutine(PacketLoop(true));
        Lobby.AddListener(ms_Instance);
        Lobby.OnConnected    += OnConnectedToSessionServer;
        Lobby.OnDisconnected += OnDisconnectFromSessionServer;
#endif
    }
Exemplo n.º 8
0
    // Start
    void Start()
    {
        loginClientGUI = this.GetComponent <Login>();

        // Receive lobby RPCs
        Lobby.AddListener(this);

        // Retrieve crystal balance when logging in
        AccountManager.OnAccountLoggedIn += OnAccountLoggedIn;
    }
Exemplo n.º 9
0
    // Start
    void Start()
    {
        // Receive RPCs from lobby
        Lobby.AddListener(this);

        lobbyChat = this.GetComponent <LobbyChat>();

        var audioGameObject = GameObject.Find("Audio");

        if (audioGameObject != null)
        {
            music = audioGameObject.GetComponent <MusicManager>();
        }

        inputManager = GameObject.Find("InputManager").GetComponent <InputManager>();

        // Load settings

        // Graphics - Quality
        QualitySettings.SetQualityLevel(PlayerPrefs.GetInt("Graphics_QualityLevel", QualitySettings.GetQualityLevel()));

        /*vSync = PlayerPrefs.GetInt("Graphics_VSync", vSync != 0) != 0;
         * sunShafts = PlayerPrefs.GetInt("Graphics_SunShafts", sunShafts != 0) != 0;
         * bloom = PlayerPrefs.GetInt("Graphics_Bloom", bloom != 0) != 0;
         * toneMapping = PlayerPrefs.GetInt("Graphics_ToneMapping", toneMapping != 0) != 0;
         * vignetting = PlayerPrefs.GetInt("Graphics_Vignetting", vignetting != 0) != 0;
         * contrastEnhance = PlayerPrefs.GetInt("Graphics_ContrastEnhance", contrastEnhance != 0) != 0;
         * contrastStretch = PlayerPrefs.GetInt("Graphics_ContrastStretch", contrastStretch != 0) != 0;
         * depthOfField = PlayerPrefs.GetInt("Graphics_DepthOfField", depthOfField != 0) != 0;
         */

        vSync = PlayerPrefs.GetInt("Graphics_VSync", vSync ? 1 : 0) != 0;

        foreach (var effect in effects)
        {
            effect.activated = PlayerPrefs.GetInt("Graphics_" + effect.prefsId, effect.activated ? 1 : 0) != 0;
        }

        // Audio - Speaker mode
        AudioSettings.speakerMode = audioSpeakerModes[PlayerPrefs.GetInt("Audio_SpeakerMode", 0)];

        // Audio - Master volume
        AudioListener.volume = PlayerPrefs.GetFloat("Audio_MasterVolume", AudioListener.volume);

        // Audio - Music volume
        if (music != null)
        {
            // NOTE: Music manager sets the volume itself
            //music.volume = PlayerPrefs.GetFloat("Audio_MusicVolume", music.volume);
            music.PlayCategory(GetComponent <MusicCategory>());
        }

        // Input - Mouse sensitivity
        inputManager.mouseSensitivity = PlayerPrefs.GetFloat("Input_MouseSensitivity", inputManager.mouseSensitivity);
    }
Exemplo n.º 10
0
    // Start
    void Start()
    {
        //allWeapons = Magic.instance.allWeapons;
        currentWeapon          = null;
        currentAttunementBuild = null;
        currentSkillSlotIndex  = -1;
        showSkill = null;

        // Receive RPCs from the lobby
        Lobby.AddListener(this);
    }
Exemplo n.º 11
0
    // Start
    void Start()
    {
        // Init ranking lists
        GameDB.InitRankingLists();

        // Update ranking list cache
        StartRankingListCacheUpdate();

        // Make this class listen to lobby events
        Lobby.AddListener(this);
    }
Exemplo n.º 12
0
    // Start
    void Start()
    {
        //loginClientGUI = this.GetComponent<LoginClientGUI>();
        //inGameLobby = this.GetComponent<InGameLobby>();

        artifactTree      = null;
        artifactInventory = null;
        //statsTree.Randomize();

        // Receive lobby RPCs
        Lobby.AddListener(this);
    }
Exemplo n.º 13
0
    public void StartServer()
    {
        Lobby.AddListener(this);

        Lobby.ConnectAsServer(lobbyIP, lobbyPort);


        //mainMenuManager.ShowMenu(windowPickSelection.GetComponent<Menu>());


        //pickSelectionScript.CreateLayout();
        //pickSelectionScript.CreatePickLayout();
    }
Exemplo n.º 14
0
    public void StartServerManual()
    {
        Lobby.AddListener(this);
        //gameServerIP = "127.0.0.1";
        //gameServerPort = 7000;
        Lobby.ConnectAsServer(lobbyIP, lobbyPort);
        uLink.Network.InitializeServer(32, 7000);


        mainMenuManager.ShowMenu(windowPickSelection.GetComponent <Menu>());


        pickSelectionScript.CreateLayout();
        pickSelectionScript.CreatePickLayout();
    }
Exemplo n.º 15
0
    // Start
    void Start()
    {
        // Create queues
        queue = new LobbyQueue[5];
        for (int i = 0; i < queue.Length; i++)
        {
            queue[i] = new LobbyQueue();
            queue[i].unitsNeededForGameStart = (i + 1) * 2;
        }

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

        // Send queue stats
        InvokeRepeating("SendQueueStats", 0.001f, queueStatsSendInterval);
    }
Exemplo n.º 16
0
    void Start()
    {
        Lobby.AddListener(this);
        Lobby.OnConnected       += Lobby_OnConnected;
        Lobby.OnDisconnected    += Lobby_OnDisconnected;
        Lobby.OnFailedToConnect += Lobby_OnFailedToConnect;

        RegisterMsgHandlers();

#if UNITY_EDITOR
        uLink.Network.config.timeoutDelay = 1800;
#else
        uLink.Network.config.timeoutDelay = 180;
#endif

        OnLobbyDisconnectedEvent          += OnLobbyDisconnected;
        MyServerManager.OnServerHostEvent += OnServerHost;
    }
Exemplo n.º 17
0
    public void StartServerManual()
    {
        Lobby.AddListener(this);
        //gameServerIP = "127.0.0.1";
        //gameServerPort = 7000;
        Lobby.ConnectAsServer(lobbyIP, lobbyPort);
        uLink.Network.InitializeServer(32, 7000);


        mainMenuManager.ShowMenu(windowPickSelection.GetComponent <Menu>());


        pickSelectionScript.CreateLayout();
        pickSelectionScript.CreatePickLayout();
        cameraMain.SetActive(false);
        lightsObj.SetActive(false);
        cameraParticle.clearFlags = CameraClearFlags.SolidColor;
    }
Exemplo n.º 18
0
    // Start
    void Start()
    {
        divisionPoints = leaguePoints / InGameLobby.instance.divisions.Length;

        // Receive RPCs from the lobby
        Lobby.AddListener(this);

        // Retrieve ranking lists when logging in
        AccountManager.OnAccountLoggedIn += OnAccountLoggedIn;

        // Init ranking lists
        GameDB.InitRankingLists();

        currentSubject = RankingSubject.Player;
        ChangePage(RankingPage.Best);

        // Empty icon
        countryCodeToIcon[""] = LoadCountryIconAsync("empty");
    }
Exemplo n.º 19
0
    // Start
    void Start()
    {
        chatInputEnabled = true;
        entries          = new List <ChatMessage>();
        members          = new List <ChatMember>();
        myMessages       = new List <string>();
        myMessages.Add("");

        inGameLobby = this.GetComponent <InGameLobby>();

#if UNITY_EDITOR
        if (!Application.CanStreamedLevelBeLoaded("Client"))
        {
            this.AddEntry("<size=32><color=red>WARNING: CLIENT SCENE DOES NOT EXIST!</color></size>");
        }
#endif

        // Listen to lobby events
        Lobby.AddListener(this);
    }
Exemplo n.º 20
0
    void uZone_OnConnected(string id)
    {
        serverName = uZone.InstanceManager.Server.cmdArgs[1];
        maxPlayers = Convert.ToInt32(uZone.InstanceManager.Server.cmdArgs[2]);
        UnityEngine.Debug.Log("Instance connected.");
        gameServerPort = uZone.InstanceManager.Server.gameServerPort;
        uLink.Network.InitializeServer(32, uZone.InstanceManager.Server.gameServerPort);
        //ServerRegistry.AddServer(gameServerIP, uZone.InstanceManager.Server.gameServerPort, numPlayers, maxPlayers, serverName);

        Lobby.AddListener(this);
        Lobby.ConnectAsServer(lobbyIP, lobbyPort);

        GameObject PickSelectionObj = GameObject.Find("Window_PickSelection");

        mainMenuManager.ShowMenu(windowPickSelection.GetComponent <Menu>());
        PickSelection pickSelScript = PickSelectionObj.GetComponent <PickSelection>();

        pickSelScript.CreateLayout();
        pickSelScript.CreatePickLayout();
    }
Exemplo n.º 21
0
    public void Start()
    {
        Lobby.AddListener(this);

        // Initialize a lobby that can accept a maximum of 1024 connections.
        Lobby.InitializeLobby(1024, listenPort);

        // Add ourselves as listeners for when accounts log in or out.
        AccountManager.OnAccountLoggedIn  += OnAccountLoggedIn;
        AccountManager.OnAccountLoggedOut += OnAccountLoggedOut;

        /*
         * This is called to make the object subscribe to events
         * and have its named callbacks executed. These are defined
         * at the end of this script file.
         */
        uZone.InstanceManager.AddListener(this.gameObject);

        //One way of defining a callback. This is equivalent to connectedCallbackTwo.
        EventCallback connectedCallbackOne =
            arg =>
        {
            string id = (string)arg;
            UnityEngine.Debug.Log("Registered with ID: !" + id);
        };

        //This sets the callback to be executed on the event where the application
        //successfuly connects to uZone to be connectedCallbackOne.
        uZone.InstanceManager.SetCallback(EventCode.UzoneConnected, connectedCallbackOne);

        //A second call will overwrite the previously assigned callback.
        uZone.InstanceManager.SetCallback(EventCode.UzoneConnected, connectedCallbackTwo);

        //Calling this method will remove whatever callback is currently set for this event.
        //Also note that this is global for the application, and not just for this object.
        uZone.InstanceManager.DeleteCallback(EventCode.UzoneConnected);

        uZone.InstanceManager.Connect(host, Int32.Parse(port));
    }
Exemplo n.º 22
0
    // Start
    void Start()
    {
        // Register codecs for serialization
        GameDB.InitCodecs();

        // Listen to lobby events
        Lobby.AddListener(this);

        displayedAccount       = null;
        accountSetupPageStatus = new RequestStatus[2];
        currentState           = GameLobbyState.WaitingForAccountInfo;
        currentLobbyModule     = profileGUI;

        lobbyChat.currentChannel = "Global";

        // Music objects
        audioGameObject = GameObject.Find("Audio");
        if (audioGameObject != null)
        {
            musicManager = audioGameObject.GetComponent <MusicManager>();
        }

        ArenaGUI.instance.ResetQueueInfo();
    }
Exemplo n.º 23
0
 // Start
 void Start()
 {
     // Receive lobby RPCs
     Lobby.AddListener(this);
 }
Exemplo n.º 24
0
    // StartLobby
    void StartLobby()
    {
        // Configure lobby
        ConfigureLobby();

        // After lobby initialization
        Lobby.OnLobbyInitialized += () => {
            LogManager.General.Log("Successfully initialized lobby.");

            // Private key
            LogManager.General.Log("Reading private key file");
            Lobby.privateKey = new PrivateKey(File.ReadAllText(privateKeyPath));

            // Login message
            LogManager.General.Log("Reading login message file");
            loginMessage = File.ReadAllText(loginMessagePath);

            // Security
            LogManager.General.Log("Initializing security");
            Lobby.InitializeSecurity(true);

            // Authoritative account manager
            LogManager.General.Log("Setting up account manager");
            AccountManager.Master.isAuthoritative = true;

            // Add ourselves as listeners for when accounts log in or out
            AccountManager.OnAccountLoggedIn   += OnAccountLoggedIn;
            AccountManager.OnAccountLoggedOut  += OnAccountLoggedOut;
            AccountManager.OnAccountRegistered += OnAccountRegistered;

            // Try to free up some RAM
            LogManager.General.Log("Freeing up RAM");
            System.GC.Collect();
            Resources.UnloadUnusedAssets();

            // Delete unactivated accounts
            //StartCoroutine(LobbyAccountManager.DeleteAllUnactivatedAccounts());

            // Copy accounts
            //StartCoroutine(LobbyAccountManager.CopyULobbyAccounts());

            /*var accountId = "/4P6sK+o";
             * var pw = "reitareset";
             *
             * LogManager.General.Log(pw);
             * StartCoroutine(LobbyAccountManager.CreateAccount(
             *      accountId,
             *      "*****@*****.**",
             *      pw
             * ));*/
        };

        // Peer connections
        Lobby.OnPeerConnected    += OnPeerConnected;
        Lobby.OnPeerDisconnected += OnPeerDisconnected;

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

        // Initialize the lobby
        LogManager.General.Log("Initializing lobby on port " + listenPort + " with a maximum of " + maxConnections + " players.");

        Lobby.InitializeLobby(
            maxConnections,
            listenPort,
            new RiakStorageManager(),
            new RiakAccountManager(),
            new RiakFriendManager()
            );
    }
Exemplo n.º 25
0
 // Start
 void Start()
 {
     inGameLobby = this.GetComponent <InGameLobby>();
     Lobby.AddListener(this);
 }
Exemplo n.º 26
0
    // Setup
    void Start()
    {
        LogManager.System.GenerateReport();

        if (Application.genuineCheckAvailable && !Application.genuine)
        {
            LogManager.General.LogError("Client files have been modified, quitting.");
            Application.Quit();
            return;
        }

        // Cursor
        Cursor.SetCursor(cursorIcon, cursorHotSpot, cursorMode);

        SetupApplicationForLobby();
        gameLobby           = GetComponent <InGameLobby>();
        clientVersionNumber = GetComponent <Version>().versionNumber;
        intro               = GetComponent <Intro>();
        introEnabled        = intro.enabled;
        textFieldHeight     = GUILayout.Height(24);
        popupMenu           = null;
        accountNotActivated = false;

        // FOR TESTING ONLY
#if UNITY_EDITOR
        if (!Application.CanStreamedLevelBeLoaded("Client"))
        {
            editorAutoLogin = false;
            LogManager.General.LogError("<color=red>YOU FORGOT TO ADD THE CLIENT SCENE IN THE BUILD SETTINGS</color>");
        }

        if (editorAutoLogin)
        {
            intro.enabled = false;
            introEnabled  = false;
        }

        retrieveLobbyIP = false;
        lobbyHost       = editorLobbyHost;
#endif

        // Retrieve lobby IP
        if (retrieveLobbyIP)
        {
            StartCoroutine(NetworkHelper.DownloadIPAndPort(lobbyIpURL, (host, port) => {
                lobbyHost = host;
                lobbyPort = port;

                ConnectToLobby();
            }));
        }

        // Retrieve changelog
        WWW changeLogRequest = new WWW(changeLogURL);
        StartCoroutine(DownloadChangeLog(changeLogRequest));

        // Public key
        NetworkHelper.InitPublicLobbyKey();

        // Receive lobby events
        Lobby.AddListener(this);

        // Add this class as a listener to different account events.
        AccountManager.OnAccountLoggedIn   += OnAccountLoggedIn;
        AccountManager.OnAccountLoggedOut  += OnAccountLoggedOut;
        AccountManager.OnAccountRegistered += OnAccountRegistered;
        AccountManager.OnLogInFailed       += OnLogInFailed;
        AccountManager.OnRegisterFailed    += OnRegisterFailed;

        // Connect to lobby
        if (!retrieveLobbyIP)
        {
            ConnectToLobby();
        }
    }
Exemplo n.º 27
0
 // Start
 void Start()
 {
     // Make this class listen to lobby events
     Lobby.AddListener(this);
 }
Exemplo n.º 28
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);
    }
Exemplo n.º 29
0
    // Awake
    void Awake()
    {
        // TODO: Checks...
        instance = this;

        // This will be reset later if -batchmode was specified
#if UNITY_STANDALONE_WIN
        isTestServer = true;
#else
        isTestServer = false;
#endif

        // Default values
        serverPort = defaultServerPort;
        partyCount = 1;

        // -party0 account1 -party1 account2
        // -batchmode -port7100
        // taskkill /IM
        LogManager.General.Log("Parsing command line arguments");
        string[] args    = System.Environment.GetCommandLineArgs();
        int      partyId = GameServerParty.Undefined;

        foreach (string arg in args)
        {
            LogManager.General.Log("Command line argument: '" + arg + "'");

            // Overwrite port
            if (arg.StartsWith("-port") && arg.Length > "-port".Length)
            {
                serverPort = int.Parse(arg.Substring(5));
                // Batchmode
            }
            else if (arg == "-batchmode")
            {
                batchMode    = true;
                isTestServer = false;
                // Party count
            }
            else if (arg.StartsWith("-partycount") && arg.Length > "-partycount".Length)
            {
                partyCount = int.Parse(arg.Substring("-partycount".Length));

                LogManager.General.Log(string.Format("Creating parties: {0}", partyCount));
                GameServerParty.partyList.Clear();
                GameServerParty.CreateParties(partyCount);
                // Teams
            }
            else if (arg.StartsWith("-party") && arg.Length > "-party".Length)
            {
                partyId            = int.Parse(arg.Substring("-party".Length));
                restrictedAccounts = true;
                // Map
            }
            else if (arg.StartsWith("-map") && arg.Length > "-map".Length)
            {
                mapName = arg.Substring("-map".Length);
                // Lobby IP
            }
            else if (arg.StartsWith("-lobbyIP") && arg.Length > "-lobbyIP".Length)
            {
                lobbyIP = arg.Substring("-lobbyIP".Length);
                // Lobby Port
            }
            else if (arg.StartsWith("-lobbyPort") && arg.Length > "-lobbyPort".Length)
            {
                lobbyPort = int.Parse(arg.Substring("-lobbyPort".Length));
                // Server type
            }
            else if (arg.StartsWith("-type") && arg.Length > "-type".Length)
            {
                string serverTypeString = arg.Substring("-type".Length);
                switch (serverTypeString)
                {
                case "Arena":
                    GameManager.serverType = ServerType.Arena;
                    break;

                case "Town":
                    GameManager.serverType = ServerType.Town;
                    break;

                case "FFA":
                    GameManager.serverType = ServerType.FFA;
                    break;

                case "World":
                    GameManager.serverType = ServerType.World;
                    break;
                }
                // Database IP
            }
            else if (arg.StartsWith("-databaseIP") && arg.Length > "-databaseIP".Length)
            {
                databaseIP = arg.Substring("-databaseIP".Length);
                // Database Port
            }
            else if (arg.StartsWith("-databasePort") && arg.Length > "-databasePort".Length)
            {
                databasePort = int.Parse(arg.Substring("-databasePort".Length));
                // Account ID
            }
            else
            {
                if (partyId >= 0 && partyId < GameServerParty.partyList.Count)
                {
                    var currentParty = GameServerParty.partyList[partyId];
                    accountToParty[arg] = currentParty;
                    currentParty.expectedMemberCount += 1;
                }
            }
        }

        // For testing
        if (isTestServer)
        {
            GameManager.serverType = testServerType;
        }
        else
        {
            if (!string.IsNullOrEmpty(databaseIP))
            {
                Database.AddNode("riak", databaseIP, databasePort, 10, Defaults.WriteTimeout, Defaults.ReadTimeout);
                Database.Connect();
            }
            else
            {
                LogManager.DB.LogError("No database address specified, can't connect to the database");
            }
        }

        // Create at least 1 party if no party count has been specified
        if (GameServerParty.partyList.Count != partyCount)
        {
            switch (GameManager.serverType)
            {
            case ServerType.Arena:
                partyCount = 2;
                break;

            case ServerType.FFA:
                partyCount = 10;
                break;
            }

            LogManager.General.Log(string.Format("Creating parties: {0}", partyCount));
            GameServerParty.partyList.Clear();
            GameServerParty.CreateParties(partyCount);
        }

        // Server type
        LogManager.General.Log("Server type: " + GameManager.serverType);
        MapManager.InitPhysics(GameManager.serverType);

        if (restrictedAccounts)
        {
            LogManager.General.Log("Server is restricted to the following accounts: " + accountToParty.Keys);
        }

        if (GameManager.isArena)
        {
            QueueSettings.queueIndex = accountToParty.Count / 2 - 1;
            LogManager.General.Log("Queue type is: " + (QueueSettings.queueIndex + 1) + "v" + (QueueSettings.queueIndex + 1));
        }
        else if (GameManager.isFFA)
        {
            QueueSettings.queueIndex = 0;
            LogManager.General.Log("Queue type is: " + (QueueSettings.queueIndex + 1) + "v" + (QueueSettings.queueIndex + 1));
        }

        // Server batchmode
        //if(batchMode) {
        LogManager.General.Log("Batchmode is being used: Destroy the camera and disable renderers");

        // Destroy the camera
        Destroy(Camera.main);

        // Disable renderers in batchmode
        DisableRenderers(creatorPrefab);

        // No statistics GUI
#if UNITY_EDITOR
        GetComponent <uLinkStatisticsGUI>().enabled = true;
#endif

        // No audio
        AudioListener.pause = true;

        // Disable all game modes just to be safe
        var gameModes = GetComponents <GameMode>();
        foreach (var mode in gameModes)
        {
            mode.enabled = false;
        }

        // Pick correct game mode
        int maxPlayerCount = 0;
        switch (GameManager.serverType)
        {
        case ServerType.Arena:
            gameMode = GetComponent <ArenaGameMode>();
            int maxSpectators = 10;
            maxPlayerCount = 10 + maxSpectators;
            break;

        case ServerType.Town:
            gameMode       = GetComponent <TownGameMode>();
            maxPlayerCount = 1024;
            break;

        case ServerType.FFA:
            gameMode       = GetComponent <FFAGameMode>();
            maxPlayerCount = 10;
            break;

        case ServerType.World:
            gameMode       = GetComponent <WorldGameMode>();
            maxPlayerCount = 1024;
            break;
        }

        // FFA
        if (GameManager.isFFA)
        {
            GameServerParty.partyList.Clear();
            GameServerParty.CreateParties(10, 1);
        }

        // Public key
        NetworkHelper.InitPublicLobbyKey();

        // Started by uZone?
        if (uZone.Instance.wasStartedByuZone)
        {
            // Listen to lobby events and RPCs
            Lobby.AddListener(this);

            IPAndPortCallBack connectToServices = (host, port) => {
                // Connect to lobby
                LogManager.General.Log(string.Format("Connecting to lobby as server {0}:{1}", host, port));
                Lobby.ConnectAsServer(host, port);

                // Update members in case we downloaded the info
                lobbyIP   = host;
                lobbyPort = port;

                // Set up callback
                uZone.Instance.GlobalEvents events = new uZone.Instance.GlobalEvents();
                events.onInitialized = uZone_OnInitialized;

                // This will tell uZone that the instance is ready
                // and we can let other players connect to it
                LogManager.General.Log("Initializing the uZone instance");
                uZone.Instance.Initialize(events);
            };

            // uLobby and uZone
#if UNITY_STANDALONE_WIN
            lobbyIP   = "127.0.0.1";
            lobbyPort = 1310;

            connectToServices(lobbyIP, lobbyPort);
#else
            if (string.IsNullOrEmpty(lobbyIP))
            {
                StartCoroutine(NetworkHelper.DownloadIPAndPort("https://battleofmages.com/scripts/login-server-ip.php", connectToServices));
            }
            else
            {
                connectToServices(lobbyIP, lobbyPort);
            }
#endif
        }

        // Load map
        StartCoroutine(MapManager.LoadMapAsync(
                           mapName,

                           // Map is loaded asynchronously...
                           // When it's finished, we use the callback:
                           () => {
            // Register codecs for serialization
            GameDB.InitCodecs();

            // Server port
            if (!isTestServer)
            {
                try {
                    serverPort = uZone.Instance.port;
                    LogManager.General.Log("Using port assigned from uZone: " + serverPort);
                } catch {
                    LogManager.General.Log("Failed to retrieve port info from uZone! Using port " + serverPort);
                }
            }
            else
            {
                LogManager.General.Log("Using test server port: " + serverPort);
            }

            // Init server
            LogManager.General.Log("Initializing the server on port " + serverPort);
            uLink.Network.InitializeServer(maxPlayerCount, serverPort);

            // Encryption
            LogManager.General.Log("Initializing security");
            uLink.Network.InitializeSecurity(true);

#if !UNITY_EDITOR
            // Clean up
            DestroyServerAssets();
#endif
            // Send ready message if we didn't do it yet
            SendReadyMessage();
        }
                           ));
    }