Пример #1
0
        public override void End(TransitionType transitionType = TransitionType.None)
        {
            base.End(transitionType);
            ForceMapUI = ShowCampaignUI = false;
            UpgradeManager.CanUpgrade = true;

            // remove all event dialogue boxes
            GUIMessageBox.MessageBoxes.ForEachMod(mb =>
            {
                if (mb is GUIMessageBox msgBox)
                {
                    if (ReadyCheck.IsReadyCheck(mb) || mb.UserData is Pair <string, ushort> pair && pair.First.Equals("conversationaction", StringComparison.OrdinalIgnoreCase))
                    {
                        msgBox.Close();
                    }
                }
            });

            if (transitionType == TransitionType.End)
            {
                EndCampaign();
            }
            else
            {
                IsFirstRound = false;
                CoroutineManager.StartCoroutine(DoLevelTransition(), "LevelTransition");
                bool success = CrewManager.GetCharacters().Any(c => !c.IsDead);
                GUI.SetSavingIndicatorState(success && (Level.IsLoadedOutpost || transitionType != TransitionType.None));
            }
        }
Пример #2
0
        public override void End(TransitionType transitionType = TransitionType.None)
        {
            base.End(transitionType);
            ForceMapUI = ShowCampaignUI = false;
            UpgradeManager.CanUpgrade = true;

            // remove all event dialogue boxes
            GUIMessageBox.MessageBoxes.ForEachMod(mb =>
            {
                if (mb is GUIMessageBox msgBox)
                {
                    if (ReadyCheck.IsReadyCheck(mb) || mb.UserData is Pair <string, ushort> pair && pair.First.Equals("conversationaction", StringComparison.OrdinalIgnoreCase))
                    {
                        msgBox.Close();
                    }
                }
            });

            if (transitionType == TransitionType.End)
            {
                EndCampaign();
            }
            else
            {
                IsFirstRound = false;
                CoroutineManager.StartCoroutine(DoLevelTransition(), "LevelTransition");
            }
        }
Пример #3
0
        public static void StartReadyCheck(string author, Client?sender = null)
        {
            if (GameMain.GameSession?.CrewManager == null || GameMain.GameSession.CrewManager.ActiveReadyCheck != null)
            {
                return;
            }

            List <Client> connectedClients = GameMain.Server.ConnectedClients;
            ReadyCheck    newReadyCheck    = new ReadyCheck(connectedClients.Where(c => !c.Spectating).Select(c => c.ID).ToList(), 30);

            GameMain.GameSession.CrewManager.ActiveReadyCheck = newReadyCheck;
            newReadyCheck.InitializeReadyCheck(author, sender);
        }
        public void Update(float deltaTime)
        {
            foreach (Pair <Order, float?> order in ActiveOrders)
            {
                if (order.Second.HasValue)
                {
                    order.Second -= deltaTime;
                }
            }
            ActiveOrders.RemoveAll(o => o.Second.HasValue && o.Second <= 0.0f);

            UpdateConversations(deltaTime);
            UpdateProjectSpecific(deltaTime);
            ActiveReadyCheck?.Update(deltaTime);
            if (ActiveReadyCheck != null && ActiveReadyCheck.IsFinished)
            {
                ActiveReadyCheck = null;
            }
        }
Пример #5
0
        public static void ClientRead(IReadMessage inc)
        {
            ReadyCheckState state        = (ReadyCheckState)inc.ReadByte();
            CrewManager?    crewManager  = GameMain.GameSession?.CrewManager;
            List <Client>   otherClients = GameMain.Client.ConnectedClients;

            if (crewManager == null || otherClients == null)
            {
                if (state == ReadyCheckState.Start)
                {
                    SendState(ReadyStatus.No);
                }
                return;
            }

            switch (state)
            {
            case ReadyCheckState.Start:
                bool isOwn    = false;
                byte authorId = 0;

                float  duration  = inc.ReadSingle();
                string author    = inc.ReadString();
                bool   hasAuthor = inc.ReadBoolean();

                if (hasAuthor)
                {
                    authorId = inc.ReadByte();
                    isOwn    = authorId == GameMain.Client.ID;
                }

                ushort      clientCount = inc.ReadUInt16();
                List <byte> clients     = new List <byte>();
                for (int i = 0; i < clientCount; i++)
                {
                    clients.Add(inc.ReadByte());
                }

                ReadyCheck rCheck = new ReadyCheck(clients, duration);
                crewManager.ActiveReadyCheck = rCheck;

                if (isOwn)
                {
                    SendState(ReadyStatus.Yes);
                    rCheck.CreateResultsMessage();
                }
                else
                {
                    rCheck.CreateMessageBox(author);
                }

                if (hasAuthor && rCheck.Clients.ContainsKey(authorId))
                {
                    rCheck.Clients[authorId] = ReadyStatus.Yes;
                }
                break;

            case ReadyCheckState.Update:
                float       time     = inc.ReadSingle();
                ReadyStatus newState = (ReadyStatus)inc.ReadByte();
                byte        targetId = inc.ReadByte();
                if (crewManager.ActiveReadyCheck != null)
                {
                    crewManager.ActiveReadyCheck.time = time;
                    crewManager.ActiveReadyCheck?.UpdateState(targetId, newState);
                }
                break;

            case ReadyCheckState.End:
                ushort count = inc.ReadUInt16();
                for (int i = 0; i < count; i++)
                {
                    byte        id     = inc.ReadByte();
                    ReadyStatus status = (ReadyStatus)inc.ReadByte();
                    crewManager.ActiveReadyCheck?.UpdateState(id, status);
                }

                crewManager.ActiveReadyCheck?.EndReadyCheck();
                crewManager.ActiveReadyCheck?.msgBox?.Close();
                crewManager.ActiveReadyCheck = null;
                break;
            }
        }
        partial void InitProjSpecific()
        {
            var buttonContainer = new GUILayoutGroup(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ButtonAreaTop, GUICanvas.Instance),
                                                     isHorizontal: true, childAnchor: Anchor.CenterRight)
            {
                CanBeFocused = false
            };

            int buttonHeight = (int)(GUI.Scale * 40),
                buttonWidth  = GUI.IntScale(450),
                buttonCenter = buttonHeight / 2,
                screenMiddle = GameMain.GraphicsWidth / 2;

            endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(screenMiddle - buttonWidth / 2, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonCenter, buttonWidth, buttonHeight), GUICanvas.Instance),
                                           TextManager.Get("EndRound"), textAlignment: Alignment.Center, style: "EndRoundButton")
            {
                Pulse     = true,
                TextBlock =
                {
                    Shadow              = true,
                    AutoScaleHorizontal = true
                },
                OnClicked = (btn, userdata) =>
                {
                    var availableTransition = GetAvailableTransition(out _, out _);
                    if (Character.Controlled != null &&
                        availableTransition == TransitionType.ReturnToPreviousLocation &&
                        Character.Controlled?.Submarine == Level.Loaded?.StartOutpost)
                    {
                        GameMain.Client.RequestStartRound();
                    }
                    else if (Character.Controlled != null &&
                             availableTransition == TransitionType.ProgressToNextLocation &&
                             Character.Controlled?.Submarine == Level.Loaded?.EndOutpost)
                    {
                        GameMain.Client.RequestStartRound();
                    }
                    else
                    {
                        ShowCampaignUI = true;
                        if (CampaignUI == null)
                        {
                            InitCampaignUI();
                        }
                        CampaignUI.SelectTab(InteractionType.Map);
                    }
                    return(true);
                }
            };

            int readyButtonHeight = buttonHeight;
            int readyButtonWidth  = (int)(GUI.Scale * 50);

            ReadyCheckButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(screenMiddle + (buttonWidth / 2) + GUI.IntScale(16), HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonCenter, readyButtonWidth, readyButtonHeight), GUICanvas.Instance),
                                             style: "RepairBuyButton")
            {
                ToolTip   = TextManager.Get("ReadyCheck.Tooltip"),
                OnClicked = delegate
                {
                    if (CrewManager != null && CrewManager.ActiveReadyCheck == null)
                    {
                        ReadyCheck.CreateReadyCheck();
                    }
                    return(true);
                },
                UserData = "ReadyCheckButton"
            };

            buttonContainer.Recalculate();
        }
Пример #7
0
        public void EndRound(string endMessage, List <TraitorMissionResult> traitorResults = null, CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None)
        {
            RoundEnding = true;

            try
            {
                IEnumerable <Character> crewCharacters = GetSessionCrewCharacters();

                foreach (Mission mission in missions)
                {
                    mission.End();
                }

                foreach (Character character in crewCharacters)
                {
                    character.CheckTalents(AbilityEffectType.OnRoundEnd);
                }

                if (missions.Any())
                {
                    if (missions.Any(m => m.Completed))
                    {
                        foreach (Character character in crewCharacters)
                        {
                            character.CheckTalents(AbilityEffectType.OnAnyMissionCompleted);
                        }
                    }

                    if (missions.All(m => m.Completed))
                    {
                        foreach (Character character in crewCharacters)
                        {
                            character.CheckTalents(AbilityEffectType.OnAllMissionsCompleted);
                        }
                    }
                }

#if CLIENT
                if (GUI.PauseMenuOpen)
                {
                    GUI.TogglePauseMenu();
                }
                GUI.PreventPauseMenuToggle = true;

                if (!(GameMode is TestGameMode) && Screen.Selected == GameMain.GameScreen && RoundSummary != null)
                {
                    GUI.ClearMessages();
                    GUIMessageBox.MessageBoxes.RemoveAll(mb => mb.UserData is RoundSummary);
                    GUIFrame summaryFrame = RoundSummary.CreateSummaryFrame(this, endMessage, traitorResults, transitionType);
                    GUIMessageBox.MessageBoxes.Add(summaryFrame);
                    RoundSummary.ContinueButton.OnClicked = (_, __) => { GUIMessageBox.MessageBoxes.Remove(summaryFrame); return(true); };
                }

                if (GameMain.NetLobbyScreen != null)
                {
                    GameMain.NetLobbyScreen.OnRoundEnded();
                }
                TabMenu.OnRoundEnded();
                GUIMessageBox.MessageBoxes.RemoveAll(mb => mb.UserData as string == "ConversationAction" || ReadyCheck.IsReadyCheck(mb));
#endif
                SteamAchievementManager.OnRoundEnded(this);

                GameMode?.End(transitionType);
                EventManager?.EndRound();
                StatusEffect.StopAll();
                missions.Clear();
                IsRunning = false;

#if CLIENT
                HintManager.OnRoundEnded();
#endif
            }
            finally
            {
                RoundEnding = false;
            }
        }
        public void EndRound(string endMessage, List <TraitorMissionResult> traitorResults = null, CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None)
        {
            if (Mission != null)
            {
                Mission.End();
            }
            GameAnalyticsManager.AddProgressionEvent(
                (Mission == null || Mission.Completed) ? GameAnalyticsSDK.Net.EGAProgressionStatus.Complete : GameAnalyticsSDK.Net.EGAProgressionStatus.Fail,
                GameMode.Preset.Identifier,
                Mission == null ? "None" : Mission.GetType().ToString());

#if CLIENT
            if (GUI.PauseMenuOpen)
            {
                GUI.TogglePauseMenu();
            }
            GUI.PreventPauseMenuToggle = true;

            if (!(GameMode is TestGameMode) && Screen.Selected == GameMain.GameScreen && RoundSummary != null)
            {
                GUI.ClearMessages();
                GUIMessageBox.MessageBoxes.RemoveAll(mb => mb.UserData is RoundSummary);
                GUIFrame summaryFrame = RoundSummary.CreateSummaryFrame(this, endMessage, traitorResults, transitionType);
                GUIMessageBox.MessageBoxes.Add(summaryFrame);
                RoundSummary.ContinueButton.OnClicked = (_, __) => { GUIMessageBox.MessageBoxes.Remove(summaryFrame); return(true); };
            }

            if (GameMain.NetLobbyScreen != null)
            {
                GameMain.NetLobbyScreen.OnRoundEnded();
            }
            TabMenu.OnRoundEnded();
            GUIMessageBox.MessageBoxes.RemoveAll(mb => mb.UserData as string == "ConversationAction" || ReadyCheck.IsReadyCheck(mb));
#endif
            SteamAchievementManager.OnRoundEnded(this);

            GameMode?.End(transitionType);
            EventManager?.EndRound();
            StatusEffect.StopAll();
            Mission   = null;
            IsRunning = false;
        }