public override float GetPriority()
        {
            // TODO: priority list?
            // Ignore items that are being repaired by someone else.
            if (Item.Repairables.Any(r => r.CurrentFixer != null && r.CurrentFixer != character))
            {
                return(0);
            }
            // Vertical distance matters more than horizontal (climbing up/down is harder than moving horizontally)
            float dist           = Math.Abs(character.WorldPosition.X - Item.WorldPosition.X) + Math.Abs(character.WorldPosition.Y - Item.WorldPosition.Y) * 2.0f;
            float distanceFactor = MathHelper.Lerp(1, 0.5f, MathUtils.InverseLerp(0, 10000, dist));
            float damagePriority = MathHelper.Lerp(1, 0, Item.Condition / Item.MaxCondition);
            float successFactor  = MathHelper.Lerp(0, 1, Item.Repairables.Average(r => r.DegreeOfSuccess(character)));
            float isSelected     = character.SelectedConstruction == Item ? 50 : 0;
            float devotion       = (Math.Min(Priority, 10) + isSelected) / 100;
            float max            = MathHelper.Min(AIObjectiveManager.OrderPriority - 1, 90);

            bool isCompleted = Item.IsFullCondition;

            if (isCompleted && character.SelectedConstruction == Item)
            {
                character?.Speak(TextManager.GetWithVariable("DialogItemRepaired", "[itemname]", Item.Name, true), null, 0.0f, "itemrepaired", 10.0f);
            }

            return(MathHelper.Lerp(0, max, MathHelper.Clamp(devotion + damagePriority * distanceFactor * successFactor * PriorityModifier, 0, 1)));
        }
Esempio n. 2
0
        public void ShowOpenUrlInWebBrowserPrompt(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return;
            }
            if (GUIMessageBox.VisibleBox?.UserData as string == "verificationprompt")
            {
                return;
            }

            var msgBox = new GUIMessageBox("", TextManager.GetWithVariable("openlinkinbrowserprompt", "[link]", url),
                                           new string[] { TextManager.Get("Yes"), TextManager.Get("No") })
            {
                UserData = "verificationprompt"
            };

            msgBox.Buttons[0].OnClicked = (btn, userdata) =>
            {
                Process.Start(url);
                msgBox.Close();
                return(true);
            };
            msgBox.Buttons[1].OnClicked = msgBox.Close;
        }
        private bool Reload(GUIButton button, object obj)
        {
            var pathBox = obj as GUITextBox;

            if (!File.Exists(pathBox.Text))
            {
                new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariable("ReloadLinkedSubError", "[file]", pathBox.Text));
                pathBox.Flash(Color.Red);
                pathBox.Text = filePath;
                return(false);
            }

            XDocument doc = Submarine.OpenFile(pathBox.Text);

            if (doc == null || doc.Root == null)
            {
                return(false);
            }

            pathBox.Flash(Color.Green);

            GenerateWallVertices(doc.Root);
            saveElement      = doc.Root;
            saveElement.Name = "LinkedSubmarine";

            filePath = pathBox.Text;

            return(true);
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!isRunning || GUI.DisableHUD || GUI.DisableUpperHUD)
            {
                return;
            }

            if (Submarine.MainSub == null)
            {
                return;
            }

            Submarine leavingSub = GetLeavingSub();

            if (leavingSub == null)
            {
                endRoundButton.Visible = false;
            }
            else if (leavingSub.AtEndPosition)
            {
                endRoundButton.Text    = ToolBox.LimitString(TextManager.GetWithVariable("EnterLocation", "[locationname]", Map.SelectedLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5);
                endRoundButton.Visible = true;
            }
            else if (leavingSub.AtStartPosition)
            {
                endRoundButton.Text    = ToolBox.LimitString(TextManager.GetWithVariable("EnterLocation", "[locationname]", Map.CurrentLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5);
                endRoundButton.Visible = true;
            }
            else
            {
                endRoundButton.Visible = false;
            }

            endRoundButton.DrawManually(spriteBatch);
        }
Esempio n. 5
0
        public static string SecondsToReadableTime(float seconds)
        {
            int s = (int)(seconds % 60.0f);

            if (seconds < 60.0f)
            {
                return(TextManager.GetWithVariable("timeformatseconds", "[seconds]", s.ToString()));
            }

            int h = (int)(seconds / (60.0f * 60.0f));
            int m = (int)((seconds / 60.0f) % 60);

            string text = "";

            if (h != 0)
            {
                text = TextManager.GetWithVariable("timeformathours", "[hours]", h.ToString());
            }
            if (m != 0)
            {
                string minutesText = TextManager.GetWithVariable("timeformatminutes", "[minutes]", m.ToString());
                text = string.IsNullOrEmpty(text) ? minutesText : string.Join(" ", text, minutesText);
            }
            if (s != 0)
            {
                string secondsText = TextManager.GetWithVariable("timeformatseconds", "[seconds]", s.ToString());
                text = string.IsNullOrEmpty(text) ? secondsText : string.Join(" ", text, secondsText);
            }
            return(text);
        }
Esempio n. 6
0
        protected override void WatchmanInteract(Character watchman, Character interactor)
        {
            if ((watchman.Submarine == Level.Loaded.StartOutpost && !Submarine.MainSub.AtStartPosition) ||
                (watchman.Submarine == Level.Loaded.EndOutpost && !Submarine.MainSub.AtEndPosition))
            {
                return;
            }

            if (GUIMessageBox.MessageBoxes.Any(mbox => mbox.UserData as string == "watchmanprompt"))
            {
                return;
            }

            if (GameMain.Client != null && interactor == Character.Controlled)
            {
                var msgBox = new GUIMessageBox("", TextManager.GetWithVariable("CampaignEnterOutpostPrompt", "[locationname]",
                                                                               Submarine.MainSub.AtStartPosition ? Map.CurrentLocation.Name : Map.SelectedLocation.Name),
                                               new string[] { TextManager.Get("Yes"), TextManager.Get("No") })
                {
                    UserData = "watchmanprompt"
                };
                msgBox.Buttons[0].OnClicked = (btn, userdata) =>
                {
                    GameMain.Client.RequestRoundEnd();
                    return(true);
                };
                msgBox.Buttons[0].OnClicked += msgBox.Close;
                msgBox.Buttons[1].OnClicked += msgBox.Close;
            }
        }
 protected override bool Check()
 {
     IsCompleted = Item.IsFullCondition;
     if (IsCompleted && IsRepairing)
     {
         character?.Speak(TextManager.GetWithVariable("DialogItemRepaired", "[itemname]", Item.Name, true), null, 0.0f, "itemrepaired", 10.0f);
     }
     return(IsCompleted);
 }
Esempio n. 8
0
        public override void Update(float deltaTime)
        {
            if (isFinished)
            {
                return;
            }

            if (GameMain.GameSession.GameMode is CampaignMode campaign)
            {
                MissionPrefab prefab         = null;
                var           unlockLocation = FindUnlockLocation();
                if (unlockLocation == null && CreateLocationIfNotFound)
                {
                    //find an empty location at least 3 steps away, further on the map
                    var emptyLocation = FindUnlockLocationRecursive(campaign.Map.CurrentLocation, Math.Max(MinLocationDistance, 3), "none", true, new HashSet <Location>());
                    if (emptyLocation != null)
                    {
                        emptyLocation.ChangeType(Barotrauma.LocationType.List.Find(lt => lt.Identifier.Equals(LocationType, StringComparison.OrdinalIgnoreCase)));
                        unlockLocation = emptyLocation;
                    }
                }

                if (unlockLocation != null)
                {
                    if (!string.IsNullOrEmpty(MissionIdentifier))
                    {
                        prefab = unlockLocation.UnlockMissionByIdentifier(MissionIdentifier);
                    }
                    else if (!string.IsNullOrEmpty(MissionTag))
                    {
                        prefab = unlockLocation.UnlockMissionByTag(MissionTag);
                    }
                    if (campaign is MultiPlayerCampaign mpCampaign)
                    {
                        mpCampaign.LastUpdateID++;
                    }
                    if (prefab != null)
                    {
                        DebugConsole.NewMessage($"Unlocked mission \"{prefab.Name}\" in the location \"{unlockLocation.Name}\".");
    #if CLIENT
                        new GUIMessageBox(string.Empty, TextManager.GetWithVariable("missionunlocked", "[missionname]", prefab.Name),
                                          new string[0], type: GUIMessageBox.Type.InGame, icon: prefab.Icon, relativeSize: new Vector2(0.3f, 0.15f), minSize: new Point(512, 128))
                        {
                            IconColor = prefab.IconColor
                        };
    #else
                        NotifyMissionUnlock(prefab);
    #endif
                    }
                }
                else
                {
                    DebugConsole.AddWarning($"Failed to find a suitable location to unlock a mission in (LocationType: {LocationType}, MinLocationDistance: {MinLocationDistance}, UnlockFurtherOnMap: {UnlockFurtherOnMap})");
                }
            }
            isFinished = true;
        }
 protected override bool CheckObjectiveSpecific()
 {
     IsCompleted = Item.IsFullCondition;
     if (character.IsOnPlayerTeam && IsCompleted && IsRepairing())
     {
         character.Speak(TextManager.GetWithVariable("DialogItemRepaired", "[itemname]", Item.Name, true), null, 0.0f, "itemrepaired", 10.0f);
     }
     return(IsCompleted);
 }
Esempio n. 10
0
 private static string GetCachedHudText(string textTag, string keyBind)
 {
     if (cachedHudTexts.TryGetValue(textTag + keyBind, out string text))
     {
         return(text);
     }
     text = TextManager.GetWithVariable(textTag, "[key]", keyBind);
     cachedHudTexts.Add(textTag + keyBind, text);
     return(text);
 }
Esempio n. 11
0
        public override bool IsCompleted()
        {
            bool isCompleted = Item.IsFullCondition;

            if (isCompleted && character.SelectedConstruction == Item)
            {
                character?.Speak(TextManager.GetWithVariable("DialogItemRepaired", "[itemname]", Item.Name, true), null, 0.0f, "itemrepaired", 10.0f);
            }
            return(isCompleted);
        }
Esempio n. 12
0
        public override string GetDescription()
        {
            if (Resized)
            {
                return(TextManager.GetWithVariable("Undo.ResizedItem", "[item]", Receivers.FirstOrDefault()?.Name));
            }

            return(Receivers.Count > 1
                ? TextManager.GetWithVariable("Undo.MovedItemsMultiple", "[count]", Receivers.Count.ToString())
                : TextManager.GetWithVariable("Undo.MovedItem", "[item]", Receivers.FirstOrDefault()?.Name));
        }
Esempio n. 13
0
 protected void InitializeWatchman(Character character)
 {
     character.CharacterHealth.UseHealthWindow = false;
     character.CharacterHealth.Unkillable      = true;
     character.CanInventoryBeAccessed          = false;
     character.CanBeDragged = false;
     character.TeamID       = Character.TeamType.FriendlyNPC;
     character.SetCustomInteract(
         WatchmanInteract,
         hudText: TextManager.GetWithVariable("TalkHint", "[key]", GameMain.Config.KeyBind(InputType.Select).ToString()));
 }
Esempio n. 14
0
        public void UpdateSubList(IEnumerable <SubmarineInfo> submarines)
        {
            var subsToShow = submarines.Where(s => s.IsCampaignCompatibleIgnoreClass).ToList();

            subsToShow.Sort((s1, s2) =>
            {
                int p1 = s1.Price > CampaignMode.MaxInitialSubmarinePrice ? 10 : 0;
                int p2 = s2.Price > CampaignMode.MaxInitialSubmarinePrice ? 10 : 0;
                return(p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name));
            });

            subList.ClearChildren();

            foreach (SubmarineInfo sub in subsToShow)
            {
                var textBlock = new GUITextBlock(
                    new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform)
                {
                    MinSize = new Point(0, 30)
                },
                    ToolBox.LimitString(sub.DisplayName, GUI.Font, subList.Rect.Width - 65), style: "ListBoxElement")
                {
                    ToolTip  = sub.Description,
                    UserData = sub
                };

                if (!sub.RequiredContentPackagesInstalled)
                {
                    textBlock.TextColor = Color.Lerp(textBlock.TextColor, Color.DarkRed, .5f);
                    textBlock.ToolTip   = TextManager.Get("ContentPackageMismatch") + "\n\n" + textBlock.RawToolTip;
                }

                var priceText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight),
                                                 TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.CenterRight, font: GUI.SmallFont)
                {
                    TextColor = sub.Price > CampaignMode.MaxInitialSubmarinePrice ? GUI.Style.Red : textBlock.TextColor * 0.8f,
                    ToolTip   = textBlock.ToolTip
                };
#if !DEBUG
                if (sub.Price > CampaignMode.MaxInitialSubmarinePrice && !GameMain.DebugDraw)
                {
                    textBlock.CanBeFocused = false;
                }
#endif
            }
            if (SubmarineInfo.SavedSubmarines.Any())
            {
                var nonShuttles = subsToShow.Where(s => s.Type == SubmarineType.Player && !s.HasTag(SubmarineTag.Shuttle) && s.Price <= CampaignMode.MaxInitialSubmarinePrice).ToList();
                if (nonShuttles.Count > 0)
                {
                    subList.Select(nonShuttles[Rand.Int(nonShuttles.Count)]);
                }
            }
        }
Esempio n. 15
0
        public bool ValidatePendingHires(bool createNetworkEvent = false)
        {
            List <CharacterInfo> hires = new List <CharacterInfo>();
            int total = 0;

            foreach (GUIComponent c in pendingList.Content.Children.ToList())
            {
                if (c.UserData is Tuple <CharacterInfo, float> info)
                {
                    hires.Add(info.Item1);
                    total += info.Item1.Salary;
                }
            }

            if (hires.None() || total > campaign.Money)
            {
                return(false);
            }

            bool atLeastOneHired = false;

            foreach (CharacterInfo ci in hires)
            {
                if (campaign.TryHireCharacter(campaign.Map.CurrentLocation, ci))
                {
                    atLeastOneHired = true;
                    PendingHires.Remove(ci);
                    pendingList.Content.RemoveChild(pendingList.Content.FindChild(c => (c.UserData as Tuple <CharacterInfo, float>).Item1 == ci));
                }
                else
                {
                    break;
                }
            }

            if (atLeastOneHired)
            {
                UpdateLocationView(campaign.Map.CurrentLocation, true);
                SelectCharacter(null, null, null);
                var dialog = new GUIMessageBox(
                    TextManager.Get("newcrewmembers"),
                    TextManager.GetWithVariable("crewhiredmessage", "[location]", campaignUI?.Campaign?.Map?.CurrentLocation?.Name),
                    new string[] { TextManager.Get("Ok") });
                dialog.Buttons[0].OnClicked += dialog.Close;
            }

            if (createNetworkEvent)
            {
                SendCrewState(true, validateHires: true);
            }

            return(false);
        }
Esempio n. 16
0
        private bool SaveProjectToFile(GUIButton button, object o)
        {
            string directory = Path.GetFullPath("EventProjects");

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            var        msgBox    = new GUIMessageBox(TextManager.Get("EventEditor.NameFilePrompt"), "", new[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
            var        layout    = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true);
            GUITextBox nameInput = new GUITextBox(new RectTransform(Vector2.One, layout.RectTransform))
            {
                Text = projectName
            };

            // Cancel button
            msgBox.Buttons[0].OnClicked = delegate
            {
                msgBox.Close();
                return(true);
            };

            // Ok button
            msgBox.Buttons[1].OnClicked = delegate
            {
                foreach (var illegalChar in Path.GetInvalidFileNameChars())
                {
                    if (!nameInput.Text.Contains(illegalChar))
                    {
                        continue;
                    }

                    GUI.AddMessage(TextManager.GetWithVariable("SubNameIllegalCharsWarning", "[illegalchar]", illegalChar.ToString()), GUI.Style.Red);
                    return(false);
                }

                msgBox.Close();
                projectName = nameInput.Text;
                XElement save     = SaveEvent(projectName);
                string   filePath = System.IO.Path.Combine(directory, $"{projectName}.sevproj");
                File.WriteAllText(Path.Combine(directory, $"{projectName}.sevproj"), save.ToString());
                GUI.AddMessage($"Project saved to {filePath}", GUI.Style.Green);

                AskForConfirmation(TextManager.Get("EventEditor.TestPromptHeader"), TextManager.Get("EventEditor.TestPromptBody"), CreateTestSetupMenu);
                return(true);
            };
            return(true);
        }
Esempio n. 17
0
        public void RefreshMissionTab(Mission selectedMission)
        {
            System.Diagnostics.Debug.Assert(
                selectedMission == null ||
                (GameMain.GameSession.Map?.SelectedConnection != null &&
                 GameMain.GameSession.Map.CurrentLocation.AvailableMissions.Contains(selectedMission)));

            GameMain.GameSession.Map.CurrentLocation.SelectedMission = selectedMission;

            foreach (GUITickBox missionTickBox in missionTickBoxes)
            {
                missionTickBox.Selected = missionTickBox.UserData == selectedMission;
            }

            selectedMissionInfo.ClearChildren();
            var container = selectedMissionInfo.Content;

            selectedMissionInfo.Visible = selectedMission != null;
            selectedMissionInfo.Spacing = 10;
            if (selectedMission == null)
            {
                return;
            }

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform),
                             selectedMission.Name, font: GUI.LargeFont)
            {
                AutoScale    = true,
                CanBeFocused = false
            };
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform),
                             TextManager.GetWithVariable("Reward", "[reward]", selectedMission.Reward.ToString()))
            {
                CanBeFocused = false
            };
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform),
                             selectedMission.Description, wrap: true)
            {
                CanBeFocused = false
            };

            if (StartButton != null)
            {
                StartButton.Enabled = true;
                StartButton.Visible = GameMain.Client == null ||
                                      GameMain.Client.HasPermission(Networking.ClientPermissions.ManageRound) ||
                                      GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign);
            }
        }
Esempio n. 18
0
        public override bool IsCompleted()
        {
            if (targetCharacter == null || targetCharacter.Removed)
            {
                abandon = true;
                return(true);
            }

            bool isCompleted = targetCharacter.Bleeding <= 0 && targetCharacter.Vitality / targetCharacter.MaxVitality > AIObjectiveRescueAll.GetVitalityThreshold(objectiveManager);

            if (isCompleted)
            {
                character.Speak(TextManager.GetWithVariable("DialogTargetHealed", "[targetname]", targetCharacter.Name),
                                null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f);
            }
            return(isCompleted || targetCharacter.IsDead);
        }
Esempio n. 19
0
        private void UpdateSpeaking()
        {
            if (Character.Oxygen < 20.0f)
            {
                Character.Speak(TextManager.Get("DialogLowOxygen"), null, 0, "lowoxygen", 30.0f);
            }

            if (Character.Bleeding > 2.0f)
            {
                Character.Speak(TextManager.Get("DialogBleeding"), null, 0, "bleeding", 30.0f);
            }

            if (Character.PressureTimer > 50.0f && Character.CurrentHull != null)
            {
                Character.Speak(TextManager.GetWithVariable("DialogPressure", "[roomname]", Character.CurrentHull.DisplayName, true), null, 0, "pressure", 30.0f);
            }
        }
Esempio n. 20
0
        public override string GetMissionRewardText(Submarine sub)
        {
            string rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetReward(sub)));

            if (rewardPerCrate.HasValue)
            {
                string rewardPerCrateText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", rewardPerCrate.Value));
                return(TextManager.GetWithVariables("missionrewardcargopercrate",
                                                    new string[] { "[rewardpercrate]", "[itemcount]", "[maxitemcount]", "[totalreward]" },
                                                    new string[] { rewardPerCrateText, itemsToSpawn.Count.ToString(), maxItemCount.ToString(), $"‖color:gui.orange‖{rewardText}‖end‖" }));
            }
            else
            {
                return(TextManager.GetWithVariables("missionrewardcargo",
                                                    new string[] { "[totalreward]", "[itemcount]", "[maxitemcount]" },
                                                    new string[] { $"‖color:gui.orange‖{rewardText}‖end‖", itemsToSpawn.Count.ToString(), maxItemCount.ToString() }));
            }
        }
Esempio n. 21
0
        public override string GetDescription()
        {
            if (wasDropped)
            {
                return(TextManager.GetWithVariable("Undo.DroppedItem", "[item]", Receivers.FirstOrDefault().Item.Name));
            }

            string container = "[ERROR]";

            if (Inventory.Owner is Item item)
            {
                container = item.Name;
            }

            return(Receivers.Count > 1
                ? TextManager.GetWithVariables("Undo.ContainedItemsMultiple", new[] { "[count]", "[container]" }, new[] { Receivers.Count.ToString(), container })
                : TextManager.GetWithVariables("Undo.ContainedItem", new[] { "[item]", "[container]" }, new[] { Receivers.FirstOrDefault().Item.Name, container }));
        }
        protected override void WatchmanInteract(Character watchman, Character interactor)
        {
            if (interactor != null)
            {
                interactor.FocusedCharacter = null;
            }

            Submarine leavingSub = GetLeavingSub();

            if (leavingSub == null)
            {
                CreateDialog(new List <Character> {
                    watchman
                }, "WatchmanInteractNoLeavingSub", 5.0f);
                return;
            }

            CreateDialog(new List <Character> {
                watchman
            }, "WatchmanInteract", 1.0f);

            if (GUIMessageBox.MessageBoxes.Any(mbox => mbox.UserData as string == "watchmanprompt"))
            {
                return;
            }
            var msgBox = new GUIMessageBox("", TextManager.GetWithVariable("CampaignEnterOutpostPrompt", "[locationname]",
                                                                           leavingSub.AtStartPosition ? Map.CurrentLocation.Name : Map.SelectedLocation.Name),
                                           new string[] { TextManager.Get("Yes"), TextManager.Get("No") })
            {
                UserData = "watchmanprompt"
            };

            msgBox.Buttons[0].OnClicked = (btn, userdata) =>
            {
                if (!isRunning)
                {
                    return(true);
                }
                TryEndRound(GetLeavingSub());
                return(true);
            };
            msgBox.Buttons[0].OnClicked += msgBox.Close;
            msgBox.Buttons[1].OnClicked += msgBox.Close;
        }
Esempio n. 23
0
        public string GetChatMessage(string targetCharacterName, string targetRoomName, bool givingOrderToSelf, string orderOption = "", int?priority = null)
        {
            priority ??= CharacterInfo.HighestManualOrderPriority;
            // If the order has a lesser priority, it means we are rearranging character orders
            if (!TargetAllCharacters && priority != CharacterInfo.HighestManualOrderPriority && Identifier != "dismissed")
            {
                return(TextManager.GetWithVariable("rearrangedorders", "[name]", targetCharacterName ?? string.Empty, returnNull: true) ?? string.Empty);
            }
            string messageTag = $"{(givingOrderToSelf && !TargetAllCharacters ? "OrderDialogSelf" : "OrderDialog")}";

            messageTag += $".{Identifier}";
            if (!string.IsNullOrEmpty(orderOption))
            {
                if (Identifier != "dismissed")
                {
                    messageTag += $".{orderOption}";
                }
                else
                {
                    string[] splitOption = orderOption.Split('.');
                    if (splitOption.Length > 0)
                    {
                        messageTag += $".{splitOption[0]}";
                    }
                }
            }
            string msg = TextManager.GetWithVariables(messageTag,
                                                      new string[2] {
                "[name]", "[roomname]"
            },
                                                      new string[2] {
                targetCharacterName ?? string.Empty, targetRoomName ?? string.Empty
            },
                                                      formatCapitals: new bool[2] {
                false, true
            },
                                                      returnNull: true);

            return(msg ?? string.Empty);
        }
        public void Greet(GameServer server, string codeWords, string codeResponse)
        {
            string greetingMessage   = TextManager.GetWithVariable("TraitorStartMessage", "[targetname]", TargetCharacter.Name);
            string moreAgentsMessage = TextManager.GetWithVariables("TraitorMoreAgentsMessage",
                                                                    new string[2] {
                "[codewords]", "[coderesponse]"
            }, new string[2] {
                codeWords, codeResponse
            });

            var greetingChatMsg   = ChatMessage.Create(null, greetingMessage, ChatMessageType.Server, null);
            var moreAgentsChatMsg = ChatMessage.Create(null, moreAgentsMessage, ChatMessageType.Server, null);

            var greetingMsgBox   = ChatMessage.Create(null, greetingMessage, ChatMessageType.MessageBox, null);
            var moreAgentsMsgBox = ChatMessage.Create(null, moreAgentsMessage, ChatMessageType.MessageBox, null);

            Client traitorClient = server.ConnectedClients.Find(c => c.Character == Character);

            GameMain.Server.SendDirectChatMessage(greetingChatMsg, traitorClient);
            GameMain.Server.SendDirectChatMessage(moreAgentsChatMsg, traitorClient);
            GameMain.Server.SendDirectChatMessage(greetingMsgBox, traitorClient);
            GameMain.Server.SendDirectChatMessage(moreAgentsMsgBox, traitorClient);

            Client ownerClient = server.ConnectedClients.Find(c => c.Connection == server.OwnerConnection);

            if (traitorClient != ownerClient && ownerClient != null && ownerClient.Character == null)
            {
                var ownerMsg = ChatMessage.Create(
                    null,//TextManager.Get("NewTraitor"),
                    TextManager.GetWithVariables("TraitorStartMessageServer", new string[2] {
                    "[targetname]", "[traitorname]"
                }, new string[2] {
                    TargetCharacter.Name, Character.Name
                }),
                    ChatMessageType.MessageBox,
                    null
                    );
                GameMain.Server.SendDirectChatMessage(ownerMsg, ownerClient);
            }
        }
 partial void UpdateMessages(float prevStrength, Character character)
 {
     if (Strength < Prefab.MaxStrength * 0.5f)
     {
         if (prevStrength % 10.0f > 0.05f && Strength % 10.0f < 0.05f)
         {
             GUI.AddMessage(TextManager.Get("HuskDormant"), Color.Red);
         }
     }
     else if (Strength < Prefab.MaxStrength)
     {
         if (state == InfectionState.Dormant && Character.Controlled == character)
         {
             GUI.AddMessage(TextManager.Get("HuskCantSpeak"), Color.Red);
         }
     }
     else if (state != InfectionState.Active && Character.Controlled == character)
     {
         GUI.AddMessage(TextManager.GetWithVariable("HuskActivate", "[Attack]", GameMain.Config.KeyBind(InputType.Attack).ToString()),
                        Color.Red);
     }
 }
        protected override bool Check()
        {
            if (character.LockHands || targetCharacter == null || targetCharacter.CurrentHull == null || targetCharacter.Removed || targetCharacter.IsDead)
            {
                Abandon = true;
                return(false);
            }
            // Don't go into rooms that have enemies
            if (Character.CharacterList.Any(c => c.CurrentHull == targetCharacter.CurrentHull && !HumanAIController.IsFriendly(character, c) && HumanAIController.IsActive(c)))
            {
                Abandon = true;
                return(false);
            }
            bool isCompleted = AIObjectiveRescueAll.GetVitalityFactor(targetCharacter) >= AIObjectiveRescueAll.GetVitalityThreshold(objectiveManager, character, targetCharacter);

            if (isCompleted && targetCharacter != character)
            {
                character.Speak(TextManager.GetWithVariable("DialogTargetHealed", "[targetname]", targetCharacter.Name),
                                null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f);
            }
            return(isCompleted);
        }
        private bool DeleteSave(GUIButton button, object obj)
        {
            string saveFile = obj as string;

            if (obj == null)
            {
                return(false);
            }

            string header = TextManager.Get("deletedialoglabel");
            string body   = TextManager.GetWithVariable("deletedialogquestion", "[file]", Path.GetFileNameWithoutExtension(saveFile));

            EventEditorScreen.AskForConfirmation(header, body, () =>
            {
                SaveUtil.DeleteSave(saveFile);
                prevSaveFiles?.RemoveAll(s => s.StartsWith(saveFile));
                UpdateLoadMenu(prevSaveFiles.ToList());
                return(true);
            });

            return(true);
        }
Esempio n. 28
0
        public override void Update(float deltaTime)
        {
            if (isFinished)
            {
                return;
            }

            if (GameMain.GameSession.GameMode is CampaignMode campaign)
            {
                MissionPrefab prefab = null;
                if (!string.IsNullOrEmpty(MissionIdentifier))
                {
                    prefab = campaign.Map.CurrentLocation.UnlockMissionByIdentifier(MissionIdentifier);
                }
                else if (!string.IsNullOrEmpty(MissionTag))
                {
                    prefab = campaign.Map.CurrentLocation.UnlockMissionByTag(MissionTag);
                }
                if (campaign is MultiPlayerCampaign mpCampaign)
                {
                    mpCampaign.LastUpdateID++;
                }

                if (prefab != null)
                {
#if CLIENT
                    new GUIMessageBox(string.Empty, TextManager.GetWithVariable("missionunlocked", "[missionname]", prefab.Name),
                                      new string[0], type: GUIMessageBox.Type.InGame, icon: prefab.Icon, relativeSize: new Vector2(0.3f, 0.15f), minSize: new Point(512, 128))
                    {
                        IconColor = prefab.IconColor
                    };
#else
                    NotifyMissionUnlock(prefab);
#endif
                }
            }
            isFinished = true;
        }
Esempio n. 29
0
        protected override bool CheckObjectiveSpecific()
        {
            if (character.LockHands || targetCharacter == null || targetCharacter.CurrentHull == null || targetCharacter.Removed || targetCharacter.IsDead)
            {
                Abandon = true;
                return(false);
            }
            // Don't go into rooms that have enemies
            if (Character.CharacterList.Any(c => c.CurrentHull == targetCharacter.CurrentHull && !HumanAIController.IsFriendly(character, c) && HumanAIController.IsActive(c)))
            {
                Abandon = true;
                return(false);
            }
            bool isCompleted =
                AIObjectiveRescueAll.GetVitalityFactor(targetCharacter) >= AIObjectiveRescueAll.GetVitalityThreshold(objectiveManager, character, targetCharacter) ||
                targetCharacter.CharacterHealth.GetAllAfflictions().All(a => a.Prefab.IsBuff || a.Strength <= a.Prefab.TreatmentThreshold);

            if (isCompleted && targetCharacter != character && character.IsOnPlayerTeam)
            {
                character.Speak(TextManager.GetWithVariable("DialogTargetHealed", "[targetname]", targetCharacter.Name),
                                null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f);
            }
            return(isCompleted);
        }
Esempio n. 30
0
        partial void UpdateMessages()
        {
            switch (State)
            {
            case InfectionState.Dormant:
                GUI.AddMessage(TextManager.Get("HuskDormant"), GUI.Style.Red);
                break;

            case InfectionState.Transition:
                GUI.AddMessage(TextManager.Get("HuskCantSpeak"), GUI.Style.Red);
                break;

            case InfectionState.Active:
                if (character.Params.UseHuskAppendage)
                {
                    GUI.AddMessage(TextManager.GetWithVariable("HuskActivate", "[Attack]", GameMain.Config.KeyBindText(InputType.Attack)), GUI.Style.Red);
                }
                break;

            case InfectionState.Final:
            default:
                break;
            }
        }