Пример #1
0
        private void ShowBuyPrompt(bool purchaseOnly)
        {
            if (GameMain.GameSession.Campaign.Money < selectedSubmarine.Price)
            {
                new GUIMessageBox(TextManager.Get("purchasesubmarineheader"), TextManager.GetWithVariables("notenoughmoneyforpurchasetext", notEnoughCreditsPurchaseTextVariables,
                                                                                                           new string[2] {
                    currencyLongText, selectedSubmarine.DisplayName
                }));
                return;
            }

            GUIMessageBox msgBox;

            if (!purchaseOnly)
            {
                msgBox = new GUIMessageBox(TextManager.Get("purchaseandswitchsubmarineheader"), TextManager.GetWithVariables("purchaseandswitchsubmarinetext", PurchaseAndSwitchTextVariables,
                                                                                                                             new string[4] {
                    selectedSubmarine.DisplayName, selectedSubmarine.Price.ToString(), currencyLongText, CurrentOrPendingSubmarine().DisplayName
                }), messageBoxOptions);

                msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
                {
                    if (GameMain.Client == null)
                    {
                        GameMain.GameSession.PurchaseSubmarine(selectedSubmarine);
                        SubmarineInfo newSub = GameMain.GameSession.SwitchSubmarine(selectedSubmarine, 0);
                        RefreshSubmarineDisplay(true);
                    }
                    else
                    {
                        GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.PurchaseAndSwitchSub);
                    }
                    return(true);
                };
            }
            else
            {
                msgBox = new GUIMessageBox(TextManager.Get("purchasesubmarineheader"), TextManager.GetWithVariables("purchasesubmarinetext", PurchaseTextVariables,
                                                                                                                    new string[3] {
                    selectedSubmarine.DisplayName, selectedSubmarine.Price.ToString(), currencyLongText
                }), messageBoxOptions);

                msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
                {
                    if (GameMain.Client == null)
                    {
                        GameMain.GameSession.PurchaseSubmarine(selectedSubmarine);
                        RefreshSubmarineDisplay(true);
                    }
                    else
                    {
                        GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.PurchaseSub);
                    }
                    return(true);
                };
            }

            msgBox.Buttons[0].OnClicked += msgBox.Close;
            msgBox.Buttons[1].OnClicked  = msgBox.Close;
        }
        // Selection based on key input
        private void SelectSubmarine(int index, int direction)
        {
            SubmarineInfo nextSub = GetSubToDisplay(index + direction);

            if (nextSub == null)
            {
                return;
            }

            for (int i = 0; i < submarineDisplays.Length; i++)
            {
                if (submarineDisplays[i].displayedSubmarine == nextSub)
                {
                    SelectSubmarine(nextSub, submarineDisplays[i].background.Rect);
                    return;
                }
            }

            ChangePage(direction);

            for (int i = 0; i < submarineDisplays.Length; i++)
            {
                if (submarineDisplays[i].displayedSubmarine == nextSub)
                {
                    SelectSubmarine(nextSub, submarineDisplays[i].background.Rect);
                    return;
                }
            }
        }
Пример #3
0
        private bool TestEvent(OutpostGenerationParams?param, LocationType?type)
        {
            SubmarineInfo subInfo = SubmarineInfo.SavedSubmarines.FirstOrDefault(info => info.HasTag(SubmarineTag.Shuttle));

            XElement?   eventXml = ExportXML();
            EventPrefab?prefab;

            if (eventXml != null)
            {
                prefab = new EventPrefab(eventXml);
            }
            else
            {
                GUI.AddMessage("Unable to open test enviroment because the event contains errors.", GUI.Style.Red);
                return(false);
            }

            GameSession  gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
            TestGameMode gameMode    = (TestGameMode)gameSession.GameMode;

            gameMode.SpawnOutpost   = true;
            gameMode.OutpostParams  = param;
            gameMode.OutpostType    = type;
            gameMode.TriggeredEvent = prefab;
            gameMode.OnRoundEnd     = () =>
            {
                Submarine.Unload();
                GameMain.EventEditorScreen.Select();
            };

            GameMain.GameScreen.Select();
            gameSession.StartRound(null, false);
            return(true);
        }
Пример #4
0
        public SubmarineInfo(SubmarineInfo original)
        {
            Name                      = original.Name;
            DisplayName               = original.DisplayName;
            Description               = original.Description;
            Price                     = original.Price;
            InitialSuppliesSpawned    = original.InitialSuppliesSpawned;
            GameVersion               = original.GameVersion;
            Type                      = original.Type;
            SubmarineClass            = original.SubmarineClass;
            hash                      = !string.IsNullOrEmpty(original.FilePath) ? original.MD5Hash : null;
            Dimensions                = original.Dimensions;
            FilePath                  = original.FilePath;
            RequiredContentPackages   = new HashSet <string>(original.RequiredContentPackages);
            IsFileCorrupted           = original.IsFileCorrupted;
            SubmarineElement          = original.SubmarineElement;
            EqualityCheckVal          = original.EqualityCheckVal;
            RecommendedCrewExperience = original.RecommendedCrewExperience;
            RecommendedCrewSizeMin    = original.RecommendedCrewSizeMin;
            RecommendedCrewSizeMax    = original.RecommendedCrewSizeMax;
            Tags                      = original.Tags;
            if (original.OutpostModuleInfo != null)
            {
                OutpostModuleInfo = new OutpostModuleInfo(original.OutpostModuleInfo);
            }
#if CLIENT
            PreviewImage = original.PreviewImage != null ? new Sprite(original.PreviewImage) : null;
#endif
        }
Пример #5
0
        /// <summary>
        /// Load a game session from the specified XML document. The session will be saved to the specified path.
        /// </summary>
        public GameSession(SubmarineInfo submarineInfo, List <SubmarineInfo> ownedSubmarines, XDocument doc, string saveFile) : this(submarineInfo, ownedSubmarines)
        {
            this.SavePath        = saveFile;
            GameMain.GameSession = this;
            //selectedSub.Name = doc.Root.GetAttributeString("submarine", selectedSub.Name);

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
#if CLIENT
                case "gamemode":     //legacy support
                case "singleplayercampaign":
                    CrewManager = new CrewManager(true);
                    var campaign = SinglePlayerCampaign.Load(subElement);
                    campaign.LoadNewLevel();
                    GameMode = campaign;
                    break;
#endif
                case "multiplayercampaign":
                    CrewManager = new CrewManager(false);
                    var mpCampaign = MultiPlayerCampaign.LoadNew(subElement);
                    GameMode = mpCampaign;
                    if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
                    {
                        mpCampaign.LoadNewLevel();
                        //save to ensure the campaign ID in the save file matches the one that got assigned to this campaign instance
                        SaveUtil.SaveGame(saveFile);
                    }
                    break;
                }
            }
        }
        private Sprite GetPreviewImage(SubmarineInfo info)
        {
            Sprite preview = info.PreviewImage;

            if (preview == null)
            {
                SubmarineInfo potentialMatch;

                if (GameMain.Client == null)
                {
                    potentialMatch = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.EqualityCheckVal == info.EqualityCheckVal);
                }
                else
                {
                    potentialMatch = GameMain.NetLobbyScreen.CampaignSubmarines.FirstOrDefault(s => s.EqualityCheckVal == info.EqualityCheckVal);
                }

                preview = potentialMatch?.PreviewImage;

                // Try from savedsubmarines with name comparison as a backup
                if (preview == null)
                {
                    potentialMatch = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == info.Name);
                    preview        = potentialMatch?.PreviewImage;
                }
            }

            return(preview);
        }
Пример #7
0
 /// <summary>
 /// Start a new GameSession. Will be saved to the specified save path (if playing a game mode that can be saved).
 /// </summary>
 public GameSession(SubmarineInfo submarineInfo, string savePath, GameModePreset gameModePreset, CampaignSettings settings, string seed = null, MissionType missionType = MissionType.None)
     : this(submarineInfo)
 {
     this.SavePath = savePath;
     CrewManager   = new CrewManager(gameModePreset != null && gameModePreset.IsSinglePlayer);
     GameMode      = InstantiateGameMode(gameModePreset, seed, submarineInfo, settings, missionType: missionType);
 }
Пример #8
0
        public void Init()
        {
            CharacterPrefab.LoadAll();
            MissionPrefab.Init();
            TraitorMissionPrefab.Init();
            MapEntityPrefab.Init();
            MapGenerationParams.Init();
            LevelGenerationParams.LoadPresets();
            ScriptedEventSet.LoadPrefabs();
            Order.Init();
            EventManagerSettings.Init();

            AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions));
            SkillSettings.Load(GetFilesOfType(ContentType.SkillSettings));
            StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure));
            ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item));
            JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs));
            CorpsePrefab.LoadAll(GetFilesOfType(ContentType.Corpses));
            NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations));
            ItemAssemblyPrefab.LoadAll();
            LevelObjectPrefab.LoadAll();

            GameModePreset.Init();
            LocationType.Init();

            SubmarineInfo.RefreshSavedSubs();

            Screen.SelectNull();

            NetLobbyScreen = new NetLobbyScreen();

            CheckContentPackage();
        }
Пример #9
0
        public GameSession(SubmarineInfo selectedSubInfo, string saveFile, XDocument doc)
            : this(selectedSubInfo, saveFile)
        {
            Submarine.MainSub = Submarine;

            GameMain.GameSession = this;
            //selectedSub.Name = doc.Root.GetAttributeString("submarine", selectedSub.Name);

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
#if CLIENT
                case "gamemode":     //legacy support
                case "singleplayercampaign":
                    CrewManager = new CrewManager(true);
                    GameMode    = SinglePlayerCampaign.Load(subElement);
                    break;
#endif
                case "multiplayercampaign":
                    CrewManager = new CrewManager(false);
                    GameMode    = MultiPlayerCampaign.LoadNew(subElement);
                    break;
                }
            }
        }
        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(GUI.Style.Red);
                pathBox.Text = filePath;
                return(false);
            }

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

            if (doc == null || doc.Root == null)
            {
                return(false);
            }
            doc.Root.SetAttributeValue("filepath", pathBox.Text);

            pathBox.Flash(GUI.Style.Green);

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

            filePath = pathBox.Text;

            return(true);
        }
Пример #11
0
        public NetLobbyScreen()
        {
            LevelSeed = ToolBox.RandomSeed(8);

            subs = SubmarineInfo.SavedSubmarines.Where(s => s.Type == SubmarineType.Player && !s.HasTag(SubmarineTag.HideInMenus)).ToList();

            if (subs == null || subs.Count() == 0)
            {
                throw new Exception("No submarines are available.");
            }

            selectedSub = subs.FirstOrDefault(s => !s.HasTag(SubmarineTag.Shuttle));
            if (selectedSub == null)
            {
                //no subs available, use a shuttle
                DebugConsole.ThrowError("No full-size submarines available - choosing a shuttle as the main submarine.");
                selectedSub = subs[0];
            }

            selectedShuttle = subs.First(s => s.HasTag(SubmarineTag.Shuttle));
            if (selectedShuttle == null)
            {
                //no shuttles available, use a sub
                DebugConsole.ThrowError("No shuttles available - choosing a full-size submarine as the shuttle.");
                selectedShuttle = subs[0];
            }

            DebugConsole.NewMessage("Selected sub: " + SelectedSub.Name, Color.White);
            DebugConsole.NewMessage("Selected shuttle: " + SelectedShuttle.Name, Color.White);

            GameModes = GameModePreset.List.ToArray();
        }
        public static string GetSubmarineVoteResultMessage(SubmarineInfo info, VoteType type, string yesVoteString, string noVoteString, bool votePassed)
        {
            string result = string.Empty;

            switch (type)
            {
            case VoteType.PurchaseAndSwitchSub:
                result = TextManager.GetWithVariables(votePassed ? "submarinepurchaseandswitchvotepassed" : "submarinepurchaseandswitchvotefailed", new string[] { "[submarinename]", "[amount]", "[currencyname]", "[yesvotecount]", "[novotecount]" }, new string[] { info.DisplayName, info.Price.ToString(), TextManager.Get("credit").ToLower(), yesVoteString, noVoteString });
                break;

            case VoteType.PurchaseSub:
                result = TextManager.GetWithVariables(votePassed ? "submarinepurchasevotepassed" : "submarinepurchasevotefailed", new string[] { "[submarinename]", "[amount]", "[currencyname]", "[yesvotecount]", "[novotecount]" }, new string[] { info.DisplayName, info.Price.ToString(), TextManager.Get("credit").ToLower(), yesVoteString, noVoteString });
                break;

            case VoteType.SwitchSub:
                int deliveryFee = SubmarineSelection.DeliveryFeePerDistanceTravelled * GameMain.GameSession.Map.DistanceToClosestLocationWithOutpost(GameMain.GameSession.Map.CurrentLocation, out Location endLocation);

                if (deliveryFee > 0)
                {
                    result = TextManager.GetWithVariables(votePassed ? "submarineswitchfeevotepassed" : "submarineswitchfeevotefailed", new string[] { "[submarinename]", "[locationname]", "[amount]", "[currencyname]", "[yesvotecount]", "[novotecount]" }, new string[] { info.DisplayName, endLocation.Name, deliveryFee.ToString(), TextManager.Get("credit").ToLower(), yesVoteString, noVoteString });
                }
                else
                {
                    result = TextManager.GetWithVariables(votePassed ? "submarineswitchnofeevotepassed" : "submarineswitchnofeevotefailed", new string[] { "[submarinename]", "[yesvotecount]", "[novotecount]" }, new string[] { info.DisplayName, yesVoteString, noVoteString });
                }
                break;

            default:
                break;
            }
            return(result);
        }
        private void SetSubmarineVotingText(Client starter, SubmarineInfo info, VoteType type)
        {
            string    name                = starter.Name;
            JobPrefab prefab              = starter?.Character?.Info?.Job?.Prefab;
            Color     nameColor           = prefab != null ? prefab.UIColor : Color.White;
            string    characterRichString = $"‖color:{nameColor.R},{nameColor.G},{nameColor.B}‖{name}‖color:end‖";
            string    submarineRichString = $"‖color:{submarineColor.R},{submarineColor.G},{submarineColor.B}‖{info.DisplayName}‖color:end‖";

            switch (type)
            {
            case VoteType.PurchaseAndSwitchSub:
                votingOnText = TextManager.GetWithVariables("submarinepurchaseandswitchvote", new string[] { "[playername]", "[submarinename]", "[amount]", "[currencyname]" }, new string[] { characterRichString, submarineRichString, info.Price.ToString(), TextManager.Get("credit").ToLower() });
                break;

            case VoteType.PurchaseSub:
                votingOnText = TextManager.GetWithVariables("submarinepurchasevote", new string[] { "[playername]", "[submarinename]", "[amount]", "[currencyname]" }, new string[] { characterRichString, submarineRichString, info.Price.ToString(), TextManager.Get("credit").ToLower() });
                break;

            case VoteType.SwitchSub:
                int deliveryFee = SubmarineSelection.DeliveryFeePerDistanceTravelled * GameMain.GameSession.Map.DistanceToClosestLocationWithOutpost(GameMain.GameSession.Map.CurrentLocation, out Location endLocation);

                if (deliveryFee > 0)
                {
                    votingOnText = TextManager.GetWithVariables("submarineswitchfeevote", new string[] { "[playername]", "[submarinename]", "[locationname]", "[amount]", "[currencyname]" }, new string[] { characterRichString, submarineRichString, endLocation.Name, deliveryFee.ToString(), TextManager.Get("credit").ToLower() });
                }
                else
                {
                    votingOnText = TextManager.GetWithVariables("submarineswitchnofeevote", new string[] { "[playername]", "[submarinename]" }, new string[] { characterRichString, submarineRichString });
                }
                break;
            }

            votingOnTextData = RichTextData.GetRichTextData(votingOnText, out votingOnText);
        }
Пример #14
0
        public void ClientRead(IReadMessage inc)
        {
            AllowSubVoting = inc.ReadBoolean();
            if (allowSubVoting)
            {
                UpdateVoteTexts(null, VoteType.Sub);
                int votableCount = inc.ReadByte();
                for (int i = 0; i < votableCount; i++)
                {
                    int    votes   = inc.ReadByte();
                    string subName = inc.ReadString();
                    List <SubmarineInfo> serversubs = new List <SubmarineInfo>();
                    foreach (GUIComponent item in GameMain.NetLobbyScreen?.SubList?.Content?.Children)
                    {
                        if (item.UserData != null && item.UserData is SubmarineInfo)
                        {
                            serversubs.Add(item.UserData as SubmarineInfo);
                        }
                    }
                    SubmarineInfo sub = serversubs.FirstOrDefault(s => s.Name == subName);
                    SetVoteText(GameMain.NetLobbyScreen.SubList, sub, votes);
                }
            }
            AllowModeVoting = inc.ReadBoolean();
            if (allowModeVoting)
            {
                UpdateVoteTexts(null, VoteType.Mode);
                int votableCount = inc.ReadByte();
                for (int i = 0; i < votableCount; i++)
                {
                    int            votes          = inc.ReadByte();
                    string         modeIdentifier = inc.ReadString();
                    GameModePreset mode           = GameModePreset.List.Find(m => m.Identifier == modeIdentifier);
                    SetVoteText(GameMain.NetLobbyScreen.ModeList, mode, votes);
                }
            }
            AllowEndVoting = inc.ReadBoolean();
            if (AllowEndVoting)
            {
                GameMain.NetworkMember.EndVoteCount = inc.ReadByte();
                GameMain.NetworkMember.EndVoteMax   = inc.ReadByte();
            }
            AllowVoteKick = inc.ReadBoolean();

            GameMain.NetworkMember.ConnectedClients.ForEach(c => c.SetVote(VoteType.StartRound, false));
            byte readyClientCount = inc.ReadByte();

            for (int i = 0; i < readyClientCount; i++)
            {
                byte clientID       = inc.ReadByte();
                var  matchingClient = GameMain.NetworkMember.ConnectedClients.Find(c => c.ID == clientID);
                matchingClient?.SetVote(VoteType.StartRound, true);
            }
            UpdateVoteTexts(GameMain.NetworkMember.ConnectedClients, VoteType.StartRound);

            inc.ReadPadBits();
        }
Пример #15
0
 public OutpostModuleInfo(SubmarineInfo submarineInfo, XElement element)
 {
     Name = $"OutpostModuleInfo ({submarineInfo.Name})";
     SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
     SetFlags(
         element.GetAttributeStringArray("flags", null, convertToLowerInvariant: true) ??
         element.GetAttributeStringArray("moduletypes", new string[0], convertToLowerInvariant: true));
     SetAllowAttachTo(element.GetAttributeStringArray("allowattachto", new string[0], convertToLowerInvariant: true));
     allowedLocationTypes = new HashSet <string>(element.GetAttributeStringArray("allowedlocationtypes", new string[0], convertToLowerInvariant: true));
 }
Пример #16
0
        public void ClientWrite(IWriteMessage msg, VoteType voteType, object data)
        {
            msg.Write((byte)voteType);

            switch (voteType)
            {
            case VoteType.Sub:
                SubmarineInfo sub = data as SubmarineInfo;
                if (sub == null)
                {
                    return;
                }

                msg.Write(sub.Name);
                break;

            case VoteType.Mode:
                GameModePreset gameMode = data as GameModePreset;
                if (gameMode == null)
                {
                    return;
                }
                msg.Write(gameMode.Identifier);
                break;

            case VoteType.EndRound:
                if (!(data is bool))
                {
                    return;
                }
                msg.Write((bool)data);
                break;

            case VoteType.Kick:
                Client votedClient = data as Client;
                if (votedClient == null)
                {
                    return;
                }

                msg.Write(votedClient.ID);
                break;

            case VoteType.StartRound:
                if (!(data is bool))
                {
                    return;
                }
                msg.Write((bool)data);
                break;
            }

            msg.WritePadBits();
        }
Пример #17
0
        private GameSession(SubmarineInfo submarineInfo, string savePath)
        {
            InitProjSpecific();
            SubmarineInfo = submarineInfo;

            /*Submarine = new Submarine(submarineInfo);
             * Submarine.MainSub = Submarine;*/
            GameMain.GameSession = this;
            EventManager         = new EventManager();
            this.SavePath        = savePath;
        }
Пример #18
0
        public static MultiPlayerCampaign StartNew(string mapSeed, SubmarineInfo selectedSub)
        {
            MultiPlayerCampaign campaign = new MultiPlayerCampaign();

            //only the server generates the map, the clients load it from a save file
            if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
            {
                campaign.map = new Map(campaign, mapSeed);
            }
            campaign.InitProjSpecific();
            return(campaign);
        }
Пример #19
0
 public void PurchaseSubmarine(SubmarineInfo newSubmarine)
 {
     if (Campaign == null)
     {
         return;
     }
     if (!OwnedSubmarines.Any(s => s.Name == newSubmarine.Name))
     {
         Campaign.Money -= newSubmarine.Price;
         OwnedSubmarines.Add(newSubmarine);
     }
 }
Пример #20
0
        public GameSession(SubmarineInfo submarineInfo, string savePath, GameModePreset gameModePreset, MissionPrefab missionPrefab)
            : this(submarineInfo, savePath)
        {
            CrewManager = new CrewManager(gameModePreset != null && gameModePreset.IsSinglePlayer);
            GameMode    = gameModePreset.Instantiate(missionPrefab);

#if CLIENT
            if (GameMode is SubTestMode)
            {
                EventManager = null;
            }
#endif
        }
        public VotingInterface(Client starter, SubmarineInfo info, VoteType type, float votingTime)
        {
            if (starter == null || info == null)
            {
                return;
            }
            SetSubmarineVotingText(starter, info, type);
            this.votingTime = votingTime;
            getYesVotes     = SubmarineYesVotes;
            getNoVotes      = SubmarineNoVotes;
            getMaxVotes     = SubmarineMaxVotes;
            onVoteEnd       = () => SendSubmarineVoteEndMessage(info, type);

            Initialize(starter, type);
        }
Пример #22
0
        public static LinkedSubmarine CreateDummy(Submarine mainSub, string filePath, Vector2 position)
        {
            XDocument doc = SubmarineInfo.OpenFile(filePath);

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

            LinkedSubmarine sl = CreateDummy(mainSub, doc.Root, position);

            sl.filePath = filePath;

            return(sl);
        }
Пример #23
0
 public RoundSummary(SubmarineInfo sub, GameMode gameMode, Mission selectedMission, Location startLocation, Location endLocation)
 {
     this.sub                  = sub;
     this.gameMode             = gameMode;
     this.selectedMission      = selectedMission;
     this.startLocation        = startLocation;
     this.endLocation          = endLocation;
     initialLocationReputation = startLocation?.Reputation?.Value ?? 0.0f;
     if (gameMode is CampaignMode campaignMode)
     {
         foreach (Faction faction in campaignMode.Factions)
         {
             initialFactionReputations.Add(faction, faction.Reputation.Value);
         }
     }
 }
Пример #24
0
        public void RemoveCampaignSubmarine(SubmarineInfo sub)
        {
            if (campaignSubmarines.Contains(sub))
            {
                campaignSubmarines.Remove(sub);
            }
            else
            {
                return;
            }

            lastUpdateID++;
            if (GameMain.NetworkMember?.ServerSettings != null)
            {
                GameMain.NetworkMember.ServerSettings.ServerDetailsChanged = true;
            }
        }
Пример #25
0
        public static LinkedSubmarine CreateDummy(Submarine mainSub, string filePath, Vector2 position)
        {
            XDocument doc = SubmarineInfo.OpenFile(filePath);

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

            LinkedSubmarine sl = CreateDummy(mainSub, doc.Root, position);

            sl.filePath         = filePath;
            sl.saveElement      = doc.Root;
            sl.saveElement.Name = "LinkedSubmarine";
            sl.saveElement.SetAttributeValue("filepath", filePath);

            return(sl);
        }
Пример #26
0
        private void ShowTransferPrompt()
        {
            if (GameMain.GameSession.Campaign.Money < deliveryFee && deliveryFee > 0)
            {
                new GUIMessageBox(TextManager.Get("deliveryrequestheader"), TextManager.GetWithVariables("notenoughmoneyfordeliverytext", notEnoughCreditsDeliveryTextVariables,
                                                                                                         new string[] { currencyLongText, selectedSubmarine.DisplayName, deliveryLocationName, GameMain.GameSession.Map.CurrentLocation.Name }));
                return;
            }

            GUIMessageBox msgBox;

            if (deliveryFee > 0)
            {
                msgBox = new GUIMessageBox(TextManager.Get("deliveryrequestheader"), TextManager.GetWithVariables("deliveryrequesttext", DeliveryTextVariables,
                                                                                                                  new string[6] {
                    selectedSubmarine.DisplayName, deliveryLocationName, GameMain.GameSession.Map.CurrentLocation.Name, CurrentOrPendingSubmarine().DisplayName, deliveryFee.ToString(), currencyLongText
                }), messageBoxOptions);
            }
            else
            {
                msgBox = new GUIMessageBox(TextManager.Get("switchsubmarineheader"), TextManager.GetWithVariables("switchsubmarinetext", SwitchTextVariables,
                                                                                                                  new string[2] {
                    CurrentOrPendingSubmarine().DisplayName, selectedSubmarine.DisplayName
                }), messageBoxOptions);
            }

            msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
            {
                if (GameMain.Client == null)
                {
                    SubmarineInfo newSub = GameMain.GameSession.SwitchSubmarine(selectedSubmarine, deliveryFee);
                    GameMain.GameSession.Campaign.UpgradeManager.RefundResetAndReload(newSub);
                    RefreshSubmarineDisplay(true);
                }
                else
                {
                    GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.SwitchSub);
                }
                return(true);
            };
            msgBox.Buttons[0].OnClicked += msgBox.Close;
            msgBox.Buttons[1].OnClicked  = msgBox.Close;
        }
Пример #27
0
        private bool OnSubSelected(GUIComponent component, object obj)
        {
            if (subPreviewContainer == null)
            {
                return(false);
            }
            (subPreviewContainer.Parent as GUILayoutGroup)?.Recalculate();
            subPreviewContainer.ClearChildren();

            SubmarineInfo sub = obj as SubmarineInfo;

            if (sub == null)
            {
                return(true);
            }

            sub.CreatePreviewWindow(subPreviewContainer);
            return(true);
        }
Пример #28
0
        private GameSession(SubmarineInfo submarineInfo, List <SubmarineInfo> ownedSubmarines = null)
        {
            InitProjSpecific();
            SubmarineInfo = submarineInfo;

#if CLIENT
            if (ownedSubmarines == null && GameMode is MultiPlayerCampaign && GameMain.NetLobbyScreen.ServerOwnedSubmarines != null)
            {
                ownedSubmarines = GameMain.NetLobbyScreen.ServerOwnedSubmarines;
            }
#endif

            OwnedSubmarines = ownedSubmarines ?? new List <SubmarineInfo>();
            if (!OwnedSubmarines.Any(s => s.Name == submarineInfo.Name))
            {
                OwnedSubmarines.Add(submarineInfo);
            }
            GameMain.GameSession = this;
            EventManager         = new EventManager();
        }
Пример #29
0
        public void Init()
        {
            NPCSet.LoadSets();
            FactionPrefab.LoadFactions();
            CharacterPrefab.LoadAll();
            MissionPrefab.Init();
            TraitorMissionPrefab.Init();
            MapEntityPrefab.Init();
            MapGenerationParams.Init();
            LevelGenerationParams.LoadPresets();
            CaveGenerationParams.LoadPresets();
            OutpostGenerationParams.LoadPresets();
            EventSet.LoadPrefabs();
            Order.Init();
            EventManagerSettings.Init();
            ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item));
            AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions));
            SkillSettings.Load(GetFilesOfType(ContentType.SkillSettings));
            StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure));
            UpgradePrefab.LoadAll(GetFilesOfType(ContentType.UpgradeModules));
            JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs));
            CorpsePrefab.LoadAll(GetFilesOfType(ContentType.Corpses));
            NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations));
            ItemAssemblyPrefab.LoadAll();
            LevelObjectPrefab.LoadAll();
            BallastFloraPrefab.LoadAll(GetFilesOfType(ContentType.MapCreature));
            TalentPrefab.LoadAll(GetFilesOfType(ContentType.Talents));
            TalentTree.LoadAll(GetFilesOfType(ContentType.TalentTrees));

            GameModePreset.Init();
            DecalManager = new DecalManager();
            LocationType.Init();

            SubmarineInfo.RefreshSavedSubs();

            Screen.SelectNull();

            NetLobbyScreen = new NetLobbyScreen();

            CheckContentPackage();
        }
Пример #30
0
        public SubmarineInfo(SubmarineInfo original)
        {
            Name                      = original.Name;
            DisplayName               = original.DisplayName;
            Description               = original.Description;
            GameVersion               = original.GameVersion;
            Type                      = original.Type;
            hash                      = !string.IsNullOrEmpty(original.FilePath) ? original.MD5Hash : null;
            Dimensions                = original.Dimensions;
            FilePath                  = original.FilePath;
            RequiredContentPackages   = new HashSet <string>(original.RequiredContentPackages);
            IsFileCorrupted           = original.IsFileCorrupted;
            SubmarineElement          = original.SubmarineElement;
            RecommendedCrewExperience = original.RecommendedCrewExperience;
            RecommendedCrewSizeMin    = original.RecommendedCrewSizeMin;
            RecommendedCrewSizeMax    = original.RecommendedCrewSizeMax;
            Tags                      = original.Tags;
#if CLIENT
            PreviewImage = original.PreviewImage != null ? new Sprite(original.PreviewImage.Texture, null, null) : null;
#endif
        }