Ejemplo n.º 1
0
        public GameSession(Submarine selectedSub, string saveFile, XDocument doc)
            : this(selectedSub, saveFile)
        {
            Submarine.MainSub = submarine;

            GameMain.GameSession = this;
            selectedSub.Name     = doc.Root.GetAttributeString("submarine", selectedSub.Name);
#if CLIENT
            CrewManager = new CrewManager();
#endif

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
#if CLIENT
                case "gamemode":     //legacy support
                case "singleplayercampaign":
                    GameMode = SinglePlayerCampaign.Load(subElement);
                    break;
#endif
                case "multiplayercampaign":
                    GameMode = MultiplayerCampaign.LoadNew(subElement);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public void Load(XElement saveElement)
        {
            foreach (XElement subElement in saveElement.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
#if CLIENT
                case "gamemode":     //legacy support
                case "singleplayercampaign":
                    GameMode = SinglePlayerCampaign.Load(subElement);
                    break;
#endif
                case "multiplayercampaign":
                    MultiplayerCampaign mpCampaign = GameMode as MultiplayerCampaign;
                    if (mpCampaign == null)
                    {
                        DebugConsole.ThrowError("Error while loading a save file: the save file is for a multiplayer campaign but the current gamemode is " + GameMode.GetType().ToString());
                        break;
                    }

                    mpCampaign.Load(subElement);
                    break;
                }
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }