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; } } }
/// <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; } } }