示例#1
0
 public static string GetModeString(MatchMode mode)
 {
     return(Loc.LS(ExtMatchMode.ToString(mode)));
 }
示例#2
0
文件: CTF.cs 项目: derhass/olmod
        // pickup of flag item
        public static bool Pickup(Player player, Item flagItem)
        {
            var flag = flagItem.m_index;

            if (flag < 0 || flag >= FlagObjs.Count)
            {
                return(false);
            }
            var ownFlag = MPTeams.AllTeams[flag] == player.m_mp_team;

            if (ownFlag && FlagStates[flag] == FlagState.HOME)
            {
                if (CTF.PlayerHasFlag.ContainsKey(player.netId))
                {
                    CTF.Score(player);
                }
                return(false);
            }
            if (!ownFlag && (PlayerHasFlag.ContainsKey(player.netId) || PlayerHasFlag.ContainsValue(flag)))
            {
                return(false);
            }

            var currentState = FlagStates[flag];

            // this also sends to 'client 0' so it'll get processed on the server as well
            CTFEvent evt;

            if (ownFlag)
            {
                if (!SendCTFFlagUpdate(-1, player.netId, flag, FlagState.HOME, true, flagItem))
                {
                    return(false);
                }

                evt = CTFEvent.RETURN;
            }
            else
            {
                if (!SendCTFPickup(-1, player, flag, FlagState.PICKEDUP, flagItem))
                {
                    return(false);
                }

                if (!CTF.CarrierBoostEnabled)
                {
                    player.c_player_ship.m_boosting             = false;
                    player.c_player_ship.m_boost_overheat_timer = float.MaxValue;
                }
                evt = CTFEvent.PICKUP;
            }

            var msg = evt == CTFEvent.RETURN ? "{0} RETURNS THE {2} FLAG!" :
                      currentState == FlagState.HOME ? "{0} ({1}) PICKS UP THE {2} FLAG!" :
                      "{0} ({1}) FINDS THE {2} FLAG AMONG SOME DEBRIS!";

            CTF.NotifyAll(evt, string.Format(Loc.LS(msg), player.m_mp_name, MPTeams.TeamName(player.m_mp_team),
                                             MPTeams.TeamName(MPTeams.AllTeams[flag])), player, flag);
            if (FlagReturnTimer[flag] != null)
            {
                GameManager.m_gm.StopCoroutine(FlagReturnTimer[flag]);
                FlagReturnTimer[flag] = null;
            }
            return(true);
        }
        private static IEnumerator MatchStart(int connectionId)
        {
            var        newPlayer      = Server.FindPlayerByConnectionId(connectionId);
            MPBanEntry newPlayerEntry = new MPBanEntry(newPlayer);

            // prevent banned players from JIP into our match
            // there is already a delayed Disconnect going on, just
            // prevent this player from entering the JIP code
            if (MPBanPlayers.IsBanned(newPlayerEntry))
            {
                yield break;
            }

            float pregameWait = 3f;

            if (!newPlayer.m_mp_name.StartsWith("OBSERVER"))
            {
                foreach (Player player in Overload.NetworkManager.m_Players)
                {
                    if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip"))
                    {
                        NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage {
                            playerId = newPlayer.netId, ready = false
                        });
                    }
                }
                MPJoinInProgress.SetReady(newPlayer, false, true); // special case: do not disable the player completely, as this would prevent this player to be sent to new clients joining before we finally switch to ready
            }

            pregameWait = SendPreGame(connectionId, pregameWait);
            yield return(new WaitForSeconds(pregameWait));

            Server.SendLoadoutDataToClients();

            if (newPlayer.m_mp_name.StartsWith("OBSERVER"))
            {
                Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name);
                newPlayer.Networkm_spectator = true;
                Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name);

                yield return(null); // make sure spectator change is received before sending MatchStart
            }
            else
            {
                foreach (Player player in Overload.NetworkManager.m_Players)
                {
                    if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip"))
                    {
                        NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage {
                            playerId = newPlayer.netId, ready = true
                        });
                    }
                }
                MPJoinInProgress.SetReady(newPlayer, true);
            }

            if (NetworkMatch.GetMatchState() != MatchState.PLAYING)
            {
                yield break;
            }

            IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode());

            NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg);
            SendMatchState(connectionId);

            NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship);
            MPTweaks.Send(connectionId);
            //if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled)
            //    newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true);
            CTF.SendJoinUpdate(newPlayer);
            Race.SendJoinUpdate(newPlayer);
            foreach (Player player in Overload.NetworkManager.m_Players)
            {
                if (player.connectionToClient.connectionId == connectionId)
                {
                    continue;
                }
                // Resend mode for existing player to move h2h -> anarchy
                NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg);

                if (!newPlayer.m_spectator)
                {
                    player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true);
                }

                //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId);
                NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage
                {
                    m_net_id     = player.netId,
                    lobby_id     = player.connectionToClient.connectionId,
                    m_pos        = player.transform.position,
                    m_rotation   = player.transform.rotation,
                    use_loadout1 = player.m_use_loadout1
                });
            }
            ServerStatLog.Connected(newPlayer.m_mp_name);
            MPBanPlayers.ApplyAllBans(); // make sure the newly connected player gets proper treatment if he is BANNED
        }
示例#4
0
 private static void DrawItem(UIElement uie, ref Vector2 position)
 {
     uie.SelectAndDrawItem(Loc.LS("INTERNET MATCH"), position, 4, false, 1f, 0.75f);
     position.y += 62f;
 }
示例#5
0
        private static bool Prefix()
        {
            if (!MPInternet.OldEnabled || MPInternet.ServerEnabled)
            {
                return(true);
            }
            string pwd = NetworkMatch.m_match_req_password;

            if (pwd == "")
            {
                var pmd = (PrivateMatchDataMessage)_NetworkMatch_m_private_data_Field.GetValue(null);
                pwd = pmd != null ? pmd.m_password : "";
            }
            MPInternet.ServerAddress = MPInternet.FindPasswordAddress(pwd.Trim(), out string msg);
            if (MPInternet.ServerAddress == null)
            {
                Debug.Log("SwitchToLobbyMenu FindPasswordAddress failed " + msg);
                NetworkMatch.CreateGeneralUIPopup("INTERNET MATCH", msg, 1);
                //MenuManager.ChangeMenuState(MenuState.MP_LOCAL_MATCH, true);

                /*
                 * MenuManager.m_menu_state = MenuState.MP_LOCAL_MATCH;
                 * MenuManager.m_next_menu_state = MenuManager.m_menu_state;
                 * UIManager.CreateUIElement(UIManager.SCREEN_CENTER, 7000, UIElementType.MP_MATCH_SETUP, Loc.LS("INTERNET MATCH"));
                 * MenuManager.m_menu_sub_state = MenuSubState.ACTIVE;
                 * MenuManager.m_menu_micro_state = NetworkMatch.m_match_req_password == "" ? 4 : 1;
                 */
                MenuManager.ClearMpStatus();
                return(false);
            }
            MenuManager.m_mp_status = NetworkMatch.m_match_req_password == "" ? Loc.LS("CREATING INTERNET MATCH") : Loc.LS("JOINING INTERNET MATCH");
            return(true);
        }
            static void DrawAutoSelectWindow(UIElement uie)
            {
                UIManager.X_SCALE    = 0.2f;
                UIManager.ui_bg_dark = true;
                uie.DrawMenuBG();

                Vector2 position = uie.m_position;

                position.y = UIManager.UI_TOP + 64f;
                uie.DrawHeaderMedium(Vector2.up * (UIManager.UI_TOP + 40f), Loc.LS("AUTOSELECT"), 265f);
                position.y += 100f;
                uie.DrawMenuSeparator(position);
                position.y -= 40f;



                position.y += 82;
                Vector2 position2 = position;

                position.x  -= 160f;
                position2.x += 160f;

                UIColorPrimaries   = MPAutoSelection.primarySwapFlag ? UIManager.m_col_ui4 : UIManager.m_col_ui0;
                UIColorSecondaries = MPAutoSelection.secondarySwapFlag ? UIManager.m_col_ui4 : UIManager.m_col_ub0;

                Vector2 left  = position;
                Vector2 right = position;

                left.x  += 81;
                right.x += 234;

                //Draw the neverselect Buttons
                for (int i = 0; i < 8; i++)
                {
                    int primaryindex   = getWeaponIconIndex(MPAutoSelection.PrimaryPriorityArray[i]);
                    int secondaryindex = getWeaponIconIndex(MPAutoSelection.SecondaryPriorityArray[i]);
                    UIManager.DrawSpriteUI(left, 0.2f, 0.2f, UIColorPrimaries, uie.m_alpha, 26 + primaryindex);
                    UIManager.DrawSpriteUI(right, 0.2f, 0.2f, UIColorSecondaries, uie.m_alpha, 104 + secondaryindex);

                    left.y  += 50f;
                    right.y += 50f;
                    if (MPAutoSelectUI_UIElement_Draw.isPrimarySelected[i])
                    {
                        uie.DrawWideBox(position, 100f, 28f, Color.blue, 0.2f, 7);
                        UIManager.DrawQuadBarHorizontal(position, 100f, 18f, 30f, Color.blue, 12);
                    }
                    else if (MPAutoSelection.PrimaryNeverSelect[i])
                    {
                        uie.DrawWideBox(position, 100f, 28f, Color.red, 0.2f, 7);
                        UIManager.DrawQuadBarHorizontal(position, 100f, 18f, 30f, Color.red, 12);
                    }
                    position.x -= 150f;
                    uie.SelectAndDrawItem(!MPAutoSelection.PrimaryNeverSelect[i] ? "+" : "-", position, 2000 + i, false, 0.022f, 1f);
                    position.x += 150f;
                    uie.SelectAndDrawHalfItem(MPAutoSelection.PrimaryPriorityArray[i], position, 1720 + i, false);
                    position.y += 50f;


                    if (MPAutoSelectUI_UIElement_Draw.isSecondarySelected[i])
                    {
                        uie.DrawWideBox(position2, 100f, 28f, Color.blue, 0.2f, 7);
                        UIManager.DrawQuadBarHorizontal(position2, 100f, 18f, 30, Color.blue, 12);
                    }
                    else if (MPAutoSelection.SecondaryNeverSelect[i])
                    {
                        uie.DrawWideBox(position2, 100f, 28f, Color.red, 0.2f, 7);
                        UIManager.DrawQuadBarHorizontal(position2, 100f, 18f, 30, Color.red, 12);
                    }
                    position2.x += 150f;
                    uie.SelectAndDrawItem((!MPAutoSelection.SecondaryNeverSelect[i] ? "+" : "-"), position2, 2010 + i, false, 0.022f, 1f);
                    position2.x -= 150f;
                    uie.SelectAndDrawHalfItem(MPAutoSelection.SecondaryPriorityArray[i], position2, 1728 + i, false);
                    position2.y += 50f;
                }



                position    = left;
                position.x  = 540f;
                position.y -= 400f;
                uie.SelectAndDrawItem("Status: " + ((MPAutoSelection.primarySwapFlag || MPAutoSelection.secondarySwapFlag) ? "ACTIVE" : "INACTIVE"), position, 2100, false, 0.3f, 0.45f);
                position.y += 50f;
                position.x += 5f;
                uie.SelectAndDrawItem("Weapon Logic: " + (MPAutoSelection.primarySwapFlag ? "ON" : "OFF"), position, 2103, false, 0.27f, 0.4f);
                position.y += 50f;
                uie.SelectAndDrawItem("Missile Logic: " + (MPAutoSelection.secondarySwapFlag ? "ON" : "OFF"), position, 2102, false, 0.27f, 0.4f);


                position.x -= 5f;
                position.y += 74f;
                uie.SelectAndDrawItem("DONT SWAP WHILE FIRING: " + (!MPAutoSelection.swapWhileFiring ? "ON" : "OFF"), position, 2106, false, 0.3f, 0.40f);
                position.y += 50f;
                uie.SelectAndDrawItem("RETRY SWAP AFTER FIRING: " + (!MPAutoSelection.dontAutoselectAfterFiring ? "ON" : "OFF"), position, 2105, false, 0.3f, 0.40f);
                position.y += 50f;
                uie.SelectAndDrawItem("ALERT: " + (MPAutoSelection.zorc ? "ON" : "OFF"), position, 2104, false, 0.3f, 0.45f);
                position.y += 73f;
                uie.SelectAndDrawItem("RESET TO DEFAULTS", position, 2107, false, 0.3f, 0.45f);



                // Button description
                position2.x -= 160f;
                position2.y -= 8f;

                position2.y -= 8f;
                string k = selectionToDescription(UIManager.m_menu_selection);

                MPAutoSelection.last_valid_description = k;
                position.x = 0f;
                uie.DrawLabelSmall(position + Vector2.up * 40f, k, 500f); //position2
                position.y += 12f;
                uie.DrawMenuSeparator(position + Vector2.up * 40f);


                position.x = 0f;
                position.y = UIManager.UI_BOTTOM - 30f;
                uie.SelectAndDrawItem(Loc.LS("BACK"), position, 100, fade: false);
            }
示例#7
0
 public static void DrawConsoleOption(UIElement uie, ref Vector2 position)
 {
     position.y += 62f;
     uie.SelectAndDrawStringOptionItem(Loc.LS("ENABLE CONSOLE KEY"), position, 9, MenuManager.GetToggleSetting(Console.KeyEnabled ? 1 : 0), Loc.LS("ACTIVATE CONSOLE WITH ` KEY"), 1.5f, false);
 }
示例#8
0
 private static void DrawRightColumn(UIElement uie, ref Vector2 position)
 {
     col_bot     = position.y;
     position.x += 600f;
     position.y  = col_top - 250f;
     uie.SelectAndDrawStringOptionItem(Loc.LS("ALLOW REAR VIEW CAMERA"), position, 11, Menus.GetMMSRearViewPIP(), Loc.LS("CLIENTS CAN CHOOSE TO HAVE REAR VIEW"), 1f, false);
     position.y += 62f;
     uie.SelectAndDrawStringOptionItem(Loc.LS("SCALE RESPAWN TO TEAM SIZE"), position, 12, Menus.GetMMSScaleRespawnTime(), Loc.LS("AUTOMATICALLY SCALE RESPAWN TIME TO TEAM SIZE (e.g. 4 = 4 seconds)"), 1f, !(MenuManager.mms_mode == ExtMatchMode.TEAM_ANARCHY || MenuManager.mms_mode == ExtMatchMode.CTF || MenuManager.mms_mode == ExtMatchMode.MONSTERBALL));
     position.y += 62f;
     uie.SelectAndDrawStringOptionItem(Loc.LS("CLASSIC SPAWNS"), position, 13, Menus.GetMMSClassicSpawns(), Loc.LS("SPAWN WITH IMPULSE+ DUALS AND FALCONS"), 1f, false);
     position.y += 62f;
     uie.SelectAndDrawStringOptionItem(Loc.LS("CTF CARRIER BOOSTING"), position, 14, Menus.GetMMSCtfCarrierBoost(), Loc.LS("FLAG CARRIER CAN USE BOOST IN CTF"), 1f, false);
     position.y += 62f;
 }
示例#9
0
        static bool Prefix(UIElement __instance)
        {
            if (MenuManager.m_menu_micro_state != 8)
            {
                return(true);
            }
            var uie = __instance;

            UIManager.X_SCALE = 0.35f;
            uie.DrawMenuBG();
            uie.DrawHeaderMedium(Vector2.up * (UIManager.UI_TOP + 30f), Loc.LS("MULTIPLAYER LEVEL SELECT"), 265f);
            Vector2 position = uie.m_position;

            position.y = UIManager.UI_TOP + 85f;
            // is this useful?
            //uie.SelectAndDrawStringOptionItem(Loc.LS("LEVEL SET"), position, 4, MPLevelSelect.OTL ? "OTL" : "LOCAL", string.Empty, 1.5f, false);
            position.y += 85f;
            uie.DrawMenuSeparator(position - Vector2.up * 35f);
            int colItems = 8;

            for (int col = 0; col < 2; col++)
            {
                position.y = UIManager.UI_TOP + 85f * 2;
                position.x = -214f + col * 428f;
                int first = MenuManager.m_list_items_first + col * colItems;
                int last  = Math.Min(first + colItems, MenuManager.m_list_items_last + 1);
                for (int i = first; i < last; i++)
                {
                    int idx = MPLevelSelect.LevelIndex[i];
                    uie.SelectAndDrawHalfItem3(idx >= 0 ? GameManager.MultiplayerMission.GetLevelDisplayName(idx) : "?", position, 1000 + i, idx == -1, false);
                    position.y += 62f;
                }
            }
            position.y  = UIManager.UI_TOP + 85f * 2 + 62f * colItems;
            position.x  = 0f;
            position.y -= 62f;
            uie.DrawMenuSeparator(position + Vector2.up * 35f);
            position.y -= 62f * 3.5f;
            if (MenuManager.m_list_item_paging)
            {
                DrawPageArrows(uie, position, true, true, 435f);
            }
            position.x = -535f;
            position.y = -60f;
            _UIElement_DrawMiniLevelImage_Method.Invoke(uie, new object[] { position, 300f, UIManager.m_menu_selection >= 1000 });
            //uie.DrawMiniLevelImage(position, 300f, UIManager.m_menu_selection >= 1000);

            var curLevelIdx = UIManager.m_menu_selection >= 1000 && UIManager.m_menu_selection < 1000 + MPLevelSelect.LevelIndex.Length ?
                              MPLevelSelect.LevelIndex[UIManager.m_menu_selection - 1000] : -1;

            position.y -= 70f;
            if (curLevelIdx >= 0)
            {
                uie.DrawMiniHeaderBright(position, GameManager.MultiplayerMission.GetLevelDisplayName(curLevelIdx), 75f);
            }
            position.y += 140f;

            LevelInfo level = curLevelIdx >= 0 ? GameManager.MultiplayerMission.OpenLevel(curLevelIdx) : null;

            if (level != null && level.IsAddOn)
            {
                if (level.LevelDescription != null && level.LevelDescription[0] != null)
                {
                    _UIElement_DrawWrappedText_Method.Invoke(uie, new object[] { level.LevelDescription[0], position, 0.4f, 15f, 150f, StringOffset.CENTER, float.MaxValue, 0f, 0f });
                }
            }
            else if (curLevelIdx >= 0)
            {
                uie.DrawMiniHeader(position, Loc.LS("PLAYERS"), 75f);
                position.y += 22f;
                uie.DrawStringSmall(GameManager.MultiplayerMission.GetLevelMPPlayers(curLevelIdx), position, 0.4f, StringOffset.CENTER, UIManager.m_col_ui2, 1f, -1f);
                position.y += 30f;
                uie.DrawMiniHeader(position, Loc.LS("TEAM"), 75f);
                position.y += 22f;
                uie.DrawStringSmall(GameManager.MultiplayerMission.GetLevelMPPlayersTeam(curLevelIdx), position, 0.4f, StringOffset.CENTER, UIManager.m_col_ui2, 1f, -1f);
            }

            position.x = 0f;
            position.y = UIManager.UI_BOTTOM - 30f;
            uie.SelectAndDrawItem(Loc.LS("BACK"), position, 100, false, 1f, 0.75f);
            return(false);
        }
        // Send a chat message
        // Set connection_id to the ID of a specific client, or to -1 to send to all
        // clients except except_connection_id (if that is >= 0)
        // If authOnly is true, only send to clients which are authenticated for chat
        // commands.
        // If unblockedOnly is true, only send to clients which are not BlockChat-BANNED
        // You need to already know if we are currently in Lobby or not
        public static bool SendTo(bool inLobby, string msg, int connection_id = -1, int except_connection_id = -1, bool authOnly = false, bool unblockedOnly = false, string sender_name = "Server", MpTeam team = MpTeam.TEAM0, bool isTeamMessage = false, int sender_connection_id = -1)
        {
            bool toAll = (connection_id < 0);

            if (!toAll)
            {
                if (connection_id >= NetworkServer.connections.Count || NetworkServer.connections[connection_id] == null)
                {
                    return(false);
                }
            }

            if (inLobby)
            {
                var lmsg = new LobbyChatMessage(sender_connection_id, sender_name, team, msg, isTeamMessage);
                if (toAll)
                {
                    if (except_connection_id < 0 && !authOnly && !unblockedOnly)
                    {
                        NetworkServer.SendToAll(75, lmsg);
                    }
                    else
                    {
                        foreach (NetworkConnection c in NetworkServer.connections)
                        {
                            if (c != null && c.connectionId != except_connection_id)
                            {
                                SendToLobbyHelper(lmsg, c.connectionId, authOnly, unblockedOnly);
                            }
                        }
                    }
                }
                else
                {
                    SendToLobbyHelper(lmsg, connection_id, authOnly, unblockedOnly);
                }
            }
            else
            {
                if (isTeamMessage)
                {
                    msg = Loc.LS("[TEAM]") + " " + msg;
                }
                foreach (var p in Overload.NetworkManager.m_Players)
                {
                    if (p != null && p.connectionToClient != null)
                    {
                        if ((toAll && p.connectionToClient.connectionId != except_connection_id) || (p.connectionToClient.connectionId == connection_id))
                        {
                            bool doSend = true;
                            if (authOnly || unblockedOnly)
                            {
                                MPBanEntry entry = new MPBanEntry(p);
                                if (authOnly)
                                {
                                    doSend = doSend && MPChatCommand.CheckPermission(entry);
                                }
                                if (doSend && unblockedOnly)
                                {
                                    doSend = !MPBanPlayers.IsBanned(entry, MPBanMode.BlockChat);
                                }
                            }
                            if (doSend)
                            {
                                p.CallTargetSendFullChat(p.connectionToClient, connection_id, sender_name, team, msg);
                            }
                        }
                    }
                }
            }
            return(true);
        }
示例#11
0
 static void DrawRearViewOption(UIElement uie, ref Vector2 pos)
 {
     pos.y += 62f;
     uie.SelectAndDrawStringOptionItem(Loc.LS("SHOW REAR VIEW CAMERA"), pos, 11, RearView.MenuManagerEnabled ? "ON" : "OFF", "SHOW REAR VIEW CAMERA ON HUD", 1.5f, false);
 }
示例#12
0
        private static IEnumerator MatchStart(int connectionId)
        {
            if (!MPTweaks.ClientHasMod(connectionId) && MPTweaks.MatchNeedsMod())
            {
                yield break;
            }
            var newPlayer = Server.FindPlayerByConnectionId(connectionId);

            if (newPlayer.m_mp_name.StartsWith("OBSERVER"))
            {
                Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name);
                newPlayer.Networkm_spectator = true;
                Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name);
            }

            int pregameWait = newPlayer.Networkm_spectator ? 0 : 3;

            //Debug.Log("SendLoadoutDataToClients: " + NetworkMatch.m_player_loadout_data.Join());
            // restore lobby_id which got wiped out in Client.OnSetLoadout
            foreach (var idData in NetworkMatch.m_player_loadout_data)
            {
                idData.Value.lobby_id = idData.Key;
            }
            Server.SendLoadoutDataToClients();
            IntegerMessage durationMsg = new IntegerMessage(pregameWait * 1000);

            NetworkServer.SendToClient(connectionId, CustomMsgType.StartPregameCountdown, durationMsg);
            Debug.Log("JIP: sending start pregame countdown");
            yield return(new WaitForSeconds(pregameWait));

            IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode());

            NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg);
            SendMatchState(connectionId);
            NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship);
            MPTweaks.Send(connectionId);
            if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled)
            {
                newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true);
            }
            CTF.SendJoinUpdate(newPlayer);
            Race.SendJoinUpdate(newPlayer);
            foreach (Player player in Overload.NetworkManager.m_Players)
            {
                if (player.connectionToClient.connectionId == connectionId)
                {
                    continue;
                }
                // Resend mode for existing player to move h2h -> anarchy
                NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg);

                if (!newPlayer.m_spectator)
                {
                    player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true);
                }

                //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId);
                NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage
                {
                    m_net_id     = player.netId,
                    lobby_id     = player.connectionToClient.connectionId,
                    m_pos        = player.transform.position,
                    m_rotation   = player.transform.rotation,
                    use_loadout1 = player.m_use_loadout1
                });
            }
            ServerStatLog.Connected(newPlayer.m_mp_name);
        }
示例#13
0
 private static void DrawEditCurveOption(UIElement uie, ref Vector2 position)
 {
     position.y += 62f;
     uie.SelectAndDrawItem(Loc.LS("EDIT CURVE"), position, 12, false, 1f, 0.75f);
     position.y -= 20f;
 }
示例#14
0
 static void DrawCompensation(UIElement uie, ref Vector2 position)
 {
     uie.SelectAndDrawItem(Loc.LS("LAG COMPENSATION SETTINGS"), position, 6, false, 1f, 0.75f);
     position.y += 62f;
 }
示例#15
0
 private static void DrawSuddenDeathToggle(UIElement uie, ref Vector2 position)
 {
     uie.SelectAndDrawStringOptionItem(Loc.LS("SUDDEN DEATH OVERTIME"), position, 10, GetMMSSuddenDeath(), string.Empty, 1f, MenuManager.mms_mode != MatchMode.NUM);
     position.y += 62f;
 }
示例#16
0
        public static void DrawLobby(UIElement uie, Vector2 pos)
        {
            float name_offset     = -250f;
            float highlight_width = 285f;
            float org_x           = pos.x;
            int   max_row_count   = NetworkMatch.GetMaxPlayersForMatch() + MPTeams.NetworkMatchTeamCount;
            int   cur_row_count   = NetworkMatch.m_players.Count() + MPTeams.NetworkMatchTeamCount;
            bool  split           = max_row_count > 10;

            if (split)
            {
                pos.x -= 300f;
                pos.y += 50f + 24f;
            }
            float org_y        = pos.y;
            float first_y      = org_y;
            int   rows_per_col = split ? (cur_row_count + 1) / 2 : cur_row_count;
            int   row_num      = 0;

            foreach (var team in Teams)
            {
                if (row_num >= rows_per_col)
                {
                    first_y      = pos.y;
                    pos.x       += 300f * 2;
                    pos.y        = org_y;
                    rows_per_col = cur_row_count; // no more split
                    row_num      = 0;
                }
                DrawTeamHeader(uie, pos, team, 255f);
                pos.y += 24f;
                row_num++;
                int num = 0;
                foreach (var value in NetworkMatch.m_players.Values)
                {
                    if (value.m_team == team)
                    {
                        uie.DrawPlayerName(pos, value, num % 2 == 0, highlight_width, name_offset, -1f);
                        pos.y += 20f;
                        num++;
                        row_num++;
                    }
                }
                pos.y += 10f;
            }
            pos.y = Mathf.Max(first_y, pos.y) + 10f;
            pos.x = org_x;
            if (MenuManager.m_menu_micro_state != 2 && MenuManager.m_mp_private_match)
            {
                float alpha_mod = (MenuManager.m_mp_cst_timer > 0f) ? 0.2f : 1f;
                uie.DrawStringSmall(ScriptTutorialMessage.ControlString(CCInput.MENU_DELETE) + " - " + Loc.LS("CHANGE TEAMS"), pos, 0.45f, StringOffset.CENTER, UIManager.m_col_ui0, alpha_mod, -1f);
            }
        }
示例#17
0
        private static IEnumerator MatchStart(int connectionId)
        {
            var newPlayer = Server.FindPlayerByConnectionId(connectionId);

            float pregameWait = 3f;

            if (!newPlayer.m_mp_name.StartsWith("OBSERVER"))
            {
                foreach (Player player in Overload.NetworkManager.m_Players)
                {
                    if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip"))
                    {
                        NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage {
                            playerId = newPlayer.netId, ready = false
                        });
                    }
                }
                MPJoinInProgress.SetReady(newPlayer, false);
            }

            pregameWait = SendPreGame(connectionId, pregameWait);
            yield return(new WaitForSeconds(pregameWait));

            Server.SendLoadoutDataToClients();

            if (newPlayer.m_mp_name.StartsWith("OBSERVER"))
            {
                Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name);
                newPlayer.Networkm_spectator = true;
                Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name);

                yield return(null); // make sure spectator change is received before sending MatchStart
            }
            else
            {
                foreach (Player player in Overload.NetworkManager.m_Players)
                {
                    if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip"))
                    {
                        NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage {
                            playerId = newPlayer.netId, ready = true
                        });
                    }
                }
                MPJoinInProgress.SetReady(newPlayer, true);
            }

            if (NetworkMatch.GetMatchState() != MatchState.PLAYING)
            {
                yield break;
            }

            IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode());

            NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg);
            SendMatchState(connectionId);

            NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship);
            MPTweaks.Send(connectionId);
            //if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled)
            //    newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true);
            CTF.SendJoinUpdate(newPlayer);
            Race.SendJoinUpdate(newPlayer);
            foreach (Player player in Overload.NetworkManager.m_Players)
            {
                if (player.connectionToClient.connectionId == connectionId)
                {
                    continue;
                }
                // Resend mode for existing player to move h2h -> anarchy
                NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg);

                if (!newPlayer.m_spectator)
                {
                    player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true);
                }

                //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId);
                NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage
                {
                    m_net_id     = player.netId,
                    lobby_id     = player.connectionToClient.connectionId,
                    m_pos        = player.transform.position,
                    m_rotation   = player.transform.rotation,
                    use_loadout1 = player.m_use_loadout1
                });
            }
            ServerStatLog.Connected(newPlayer.m_mp_name);
        }
 private static void DrawAutoselectMenuOption(UIElement uie, ref Vector2 position)
 {
     uie.SelectAndDrawItem(Loc.LS("CONFIGURE AUTOSELECT"), position, 121, false, 1f, 0.75f);
     //position.y += 55f;
 }