Пример #1
0
 public virtual List<string> GetProfile()
 {
     if (lobbyMode == LobbyMode.NEW_GAME) {
         GameProfile prf = new GameProfile();
         prf.ProfileName = profileName;
         return prf.Serialize();
     }
     else
         return profile;
 }
Пример #2
0
 public override List <string> GetProfile()
 {
     if (lobbyMode == LobbyMode.NEW_GAME)
     {
         GameProfile prf = new GameProfile();
         prf.ProfileName = profileName;
         return(prf.Serialize());
     }
     else
     {
         return(profile);
     }
 }
Пример #3
0
    protected override void OnGUI()
    {
        if (ServerEvents.singleton.InProgress)
        {
            return;
        }

        if (lobbyMode != LobbyMode.NONE)
        {
            if (lobbyMode == LobbyMode.ONLY_SERVER)
            {
                GameProfile gm = new GameProfile();
                gm.ProfileName = "Minebot";
                profile        = allProfiles == null?gm.Serialize() : allProfiles[0];

                NetworkManager.singleton.ServerChangeScene("Start");
                ServerEvents.singleton.ServerOnly        = true;
                ServerEvents.singleton.ServerOnlyProfile = profile;
                ServerEvents.singleton.InProgress        = true;
                return;
            }

            int readyCount = 0;
            foreach (var conn in readyMap.Keys)
            {
                if (readyMap[conn])
                {
                    readyCount++;
                }
            }

            int connectionsCount = 0;
            foreach (NetworkConnection conn in NetworkServer.connections)
            {
                if (conn != null)
                {
                    connectionsCount++;
                }
            }

            GUILayout.Space(20);
            GUILayout.Label("Вы в лобби. Подключено " + connectionsCount + " игроков");
            GUILayout.Label("Готовы " + readyCount + " из " + connectionsCount);

            if (!ready)
            {
                if (lobbyMode == LobbyMode.NEW_GAME)
                {
                    GUILayout.Label("Название мира:");
                    ServerEvents.singleton.NewWorldName = GUILayout.TextField(ServerEvents.singleton.NewWorldName);
                    GUILayout.Label("Сид структуры мира (0 - рандом):");
                    ServerEvents.singleton.SeedToGenerate = GUILayout.TextField(ServerEvents.singleton.SeedToGenerate);
                    GUILayout.Label("Сид спавна комнат (0 - рандом):");
                    ServerEvents.singleton.SeedToSpawn = GUILayout.TextField(ServerEvents.singleton.SeedToSpawn);
                    GUILayout.Label("Имя персонажа:");
                    profileName = GUILayout.TextField(profileName);
                }
                else if (lobbyMode == LobbyMode.LOAD_GAME)
                {
                    foreach (List <string> current in allProfiles)
                    {
                        if (GUILayout.Button(current[0] + (profile == current ? " Выбран" : "")))
                        {
                            profile = current;
                        }
                    }
                }
            }

            if (lobbyMode == LobbyMode.NEW_GAME || profile != null)
            {
                if (GUILayout.Button(ready ? "Не готов" : "Готов"))
                {
                    ready = !ready;
                    SetReady(NetworkManager.singleton.client.connection, ready);
                }
            }

            if (readyCount == connectionsCount && GUILayout.Button("Старт!"))
            {
                ServerEvents.singleton.InProgress = true;
                MessageManager.RequestProfileClientMessage.SendToAllClients(new EmptyMessage());
                lastConnections = readyCount;
            }
        }
    }