コード例 #1
0
ファイル: Lobby.cs プロジェクト: JordanFisher/WAL
        public void SetLobbyInfo()
        {
            if (!SteamMatches.IsLobbyOwner())
            {
                return;
            }

            // This ensures the lobby info changes and forces and update,
            // even if no relevant values changed.
            LobbyInfo.MarkAsChanged();

            // Assign unused teams/player spots to non-gamer players. (SteamID == 0).
            foreach (var player in LobbyInfo.Players)
            {
                if (player.SteamID != 0)
                {
                    continue;
                }
                player.GamePlayer    = FirstKingdomAvailableTo(player);
                player.GameTeam      = FirstTeamAvailableTo(player);
                player.HasPickedTeam = true;
            }

            SetLobbyName();
            BuildArgs();

            SteamMatches.SetLobbyData("Players", Jsonify(LobbyInfo.Players));
            SteamMatches.SetLobbyData("Spectators", Jsonify(LobbyInfo.Spectators));
            SteamMatches.SetLobbyData("Params", Jsonify(LobbyInfo.Params));
            SteamMatches.SetLobbyData("CommonArgs", LobbyInfo.CommonArgs);

            SteamMatches.SetLobbyData("NumPlayers", LobbyInfo.Players.Count(_player => _player.SteamID != 0).ToString());
            SteamMatches.SetLobbyData("NumSpectators", LobbyInfo.Spectators.Count.ToString());
            SteamMatches.SetLobbyData("MaxPlayers", Program.MaxPlayers.ToString());
        }
コード例 #2
0
ファイル: Lobby.cs プロジェクト: JordanFisher/WAL
        public void _StartGame()
        {
            //var lobby_data = SteamMatches.GetLobbyData("LobbyInfo");
            //var lobby = JsonConvert.DeserializeObject(lobby_data, typeof(LobbyInfo));
            //LobbyInfo = (LobbyInfo)lobby;

            LobbyInfo = GetLobbyInfo();

            string game_started = SteamMatches.GetLobbyData("GameStarted");

            if (game_started == "true")
            {
                var player = LobbyInfo.Players.Where(match => match.SteamID != 0).First();
                var args   = player.Args + ' ' + LobbyInfo.CommonArgs;

                Program.ParseOptions(args);
                Program.Spectate            = true;
                Program.Server              = false;
                Program.Client              = true;
                Program.StartupPlayerNumber = 0;
            }
            else
            {
                var args = ThisPlayer.Args + ' ' + LobbyInfo.CommonArgs;

                Program.ParseOptions(args);
            }

            SetScenarioToLoad(Program.StartupMap);
            Networking.Start();

            SteamMatches.SetLobbyData("GameStarted", "true");
        }
コード例 #3
0
ファイル: Lobby.cs プロジェクト: JordanFisher/WAL
        public void ResetLobby()
        {
            if (!SteamMatches.IsLobbyOwner())
            {
                return;
            }

            SteamMatches.SetLobbyData("CountDownStarted", "");
            SteamMatches.SetLobbyData("GameStarted", "");
        }
コード例 #4
0
        void Test_OnCreateLobby(bool result)
        {
            Console.WriteLine(result);

            string player_name = SteamCore.PlayerName();
            string lobby_name  = string.Format("{0}'s lobby", player_name);

            SteamMatches.SetLobbyData("name", lobby_name);

            SteamMatches.FindLobbies(Test_OnFindLobbies);
        }
コード例 #5
0
ファイル: Lobby.cs プロジェクト: JordanFisher/WAL
        public void StartGameCountdown()
        {
            // Only the lobby owner can start the match.
            if (!SteamMatches.IsLobbyOwner())
            {
                return;
            }

            // We never set the lobby to unjoinable.
            //SteamMatches.SetLobbyJoinable(false);

            SteamMatches.SetLobbyData("CountDownStarted", "true");
            SteamMatches.SetLobbyData("GameStarted", "");
        }
コード例 #6
0
        public static void SetLobbyName()
        {
            string lobby_name = "";

            if (SteamCore.InOfflineMode())
            {
                lobby_name = "Local lobby. Offline.";
            }
            else
            {
                lobby_name = string.Format("{0}'s lobby", SteamCore.PlayerName());
            }

            SteamMatches.SetLobbyData("name", lobby_name);
        }
コード例 #7
0
ファイル: Lobby.cs プロジェクト: JordanFisher/WAL
        public void SetMap(string map_name)
        {
            Console.WriteLine("set map to {0}", map_name);

            string full_name = map_name + ".m3n";

            bool skip = false;

            if ((SetMapThread == null || !SetMapThread.IsAlive) && GameMapName == full_name)
            {
                skip = true;
            }

            if (!skip)
            {
                GameMapName = full_name;

                PrevMapThread         = SetMapThread;
                SetMapThread          = new Thread(() => SetMapThreadFunc(GameMapName));
                SetMapThread.Priority = ThreadPriority.Highest;
                SetMapThread.Start();
            }

            if (SteamMatches.IsLobbyOwner())
            {
                string current = SteamMatches.GetLobbyData("MapName");
                string name    = map_name;

                if (name.Length > 0 && name.Contains(".m3n"))
                {
                    name = name.Substring(0, name.Length - 4);
                }

                if (current != map_name)
                {
                    SteamMatches.SetLobbyData("MapName", name);
                    SetLobbyInfo();
                }
            }
        }
コード例 #8
0
        public void OnCreateLobby(bool result)
        {
            if (result)
            {
                Console.WriteLine("Failure during lobby creation.");
                return;
            }

            Program.GameStarted = false;

            SteamMatches.SetLobbyMemberLimit(64);
            SetLobbyName();
            SteamMatches.SetLobbyData("NumPlayers", "1");
            SteamMatches.SetLobbyData("NumSpectators", "0");
            SteamMatches.SetLobbyData("MaxPlayers", "4");

            if (InTrainingLobby)
            {
                SteamMatches.SetLobbyJoinable(false);
            }

            Console.WriteLine("Trying to join the created lobby.");
            SteamMatches.JoinCreatedLobby(OnJoinLobby, OnLobbyChatUpdate, OnLobbyChatMsg, OnLobbyDataUpdate);
        }