Esempio n. 1
0
        public void Init()
        {
            MissionPrefab.Init();
            MapEntityPrefab.Init();
            MapGenerationParams.Init();
            LevelGenerationParams.LoadPresets();
            ScriptedEventSet.LoadPrefabs();

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

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

            Submarine.RefreshSavedSubs();

            Screen.SelectNull();

            NetLobbyScreen = new NetLobbyScreen();

            CheckContentPackage();
        }
Esempio n. 2
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);
 }
Esempio n. 3
0
        private GameMode InstantiateGameMode(GameModePreset gameModePreset, string seed, MissionPrefab missionPrefab = null, MissionType missionType = MissionType.None)
        {
            if (gameModePreset.GameModeType == typeof(MissionMode))
            {
                return(missionPrefab != null ?
                       new MissionMode(gameModePreset, missionPrefab) :
                       new MissionMode(gameModePreset, missionType, seed ?? ToolBox.RandomSeed(8)));
            }
            else if (gameModePreset.GameModeType == typeof(MultiPlayerCampaign))
            {
                return(MultiPlayerCampaign.StartNew(seed ?? ToolBox.RandomSeed(8)));
            }
#if CLIENT
            else if (gameModePreset.GameModeType == typeof(SinglePlayerCampaign))
            {
                return(SinglePlayerCampaign.StartNew(seed ?? ToolBox.RandomSeed(8)));
            }
            else if (gameModePreset.GameModeType == typeof(TutorialMode))
            {
                return(new TutorialMode(gameModePreset));
            }
            else if (gameModePreset.GameModeType == typeof(TestGameMode))
            {
                return(new TestGameMode(gameModePreset));
            }
#endif
            else if (gameModePreset.GameModeType == typeof(GameMode))
            {
                return(new GameMode(gameModePreset));
            }
            else
            {
                throw new Exception($"Could not find a game mode of the type \"{gameModePreset.GameModeType}\"");
            }
        }
Esempio n. 4
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();
        }
        public SinglePlayerCampaign(GameModePreset preset, object param)
            : base(preset, param)
        {
            int buttonHeight = (int)(HUDLayoutSettings.ButtonAreaTop.Height * 0.7f);

            endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(HUDLayoutSettings.ButtonAreaTop.Right - 200, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonHeight / 2, 200, buttonHeight), GUICanvas.Instance),
                                           TextManager.Get("EndRound"), textAlignment: Alignment.Center)
            {
                Font      = GUI.SmallFont,
                OnClicked = (btn, userdata) => { TryEndRound(GetLeavingSub()); return(true); }
            };

            foreach (JobPrefab jobPrefab in JobPrefab.List)
            {
                for (int i = 0; i < jobPrefab.InitialCount; i++)
                {
                    CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanConfigFile, "", jobPrefab));
                }
            }

            ContextualTutorial = Tutorial.Tutorials.Find(t => t is ContextualTutorial) as ContextualTutorial;

            if (ContextualTutorial.Selected) // Selected when starting a new game -> initialize
            {
                ContextualTutorial.Initialize();
            }
        }
Esempio n. 6
0
        public SinglePlayerMode(GameModePreset preset, object param)
            : base(preset, param)
        {
            CargoManager = new CargoManager();

            endShiftButton           = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 220, 20, 200, 25), "End shift", null, Alignment.TopLeft, Alignment.Center, "");
            endShiftButton.Font      = GUI.SmallFont;
            endShiftButton.OnClicked = TryEndShift;

            for (int i = 0; i < 3; i++)
            {
                JobPrefab jobPrefab = null;
                switch (i)
                {
                case 0:
                    jobPrefab = JobPrefab.List.Find(jp => jp.Name == "Captain");
                    break;

                case 1:
                    jobPrefab = JobPrefab.List.Find(jp => jp.Name == "Engineer");
                    break;

                case 2:
                    jobPrefab = JobPrefab.List.Find(jp => jp.Name == "Mechanic");
                    break;
                }

                CharacterInfo characterInfo =
                    new CharacterInfo(Character.HumanConfigFile, "", Gender.None, jobPrefab);
                CrewManager.characterInfos.Add(characterInfo);
            }
        }
Esempio n. 7
0
        public void ClientWrite(NetBuffer msg, VoteType voteType, object data)
        {
            if (GameMain.Server != null)
            {
                return;
            }

            msg.Write((byte)voteType);

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

                msg.Write(sub.Name);
                break;

            case VoteType.Mode:
                GameModePreset gameMode = data as GameModePreset;
                if (gameMode == null)
                {
                    return;
                }
                msg.Write(gameMode.Name);
                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();
        }
Esempio n. 8
0
 public MissionMode(GameModePreset preset, IEnumerable <MissionPrefab> missionPrefabs)
     : base(preset)
 {
     Location[] locations = { GameMain.GameSession.StartLocation, GameMain.GameSession.EndLocation };
     foreach (MissionPrefab missionPrefab in missionPrefabs)
     {
         missions.Add(missionPrefab.Instantiate(locations));
     }
 }
Esempio n. 9
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 <Submarine> serversubs = new List <Submarine>();
                    foreach (GUIComponent item in GameMain.NetLobbyScreen?.SubList?.Content?.Children)
                    {
                        if (item.UserData != null && item.UserData is Submarine)
                        {
                            serversubs.Add(item.UserData as Submarine);
                        }
                    }
                    Submarine sub = serversubs.FirstOrDefault(sm => sm.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();
        }
Esempio n. 10
0
        public MissionMode(GameModePreset preset, object param)
            : base(preset, param)
        {
            Location[] locations = { GameMain.GameSession.StartLocation, GameMain.GameSession.EndLocation };

            MTRandom rand = new MTRandom(ToolBox.StringToInt(GameMain.NetLobbyScreen.LevelSeed));

            mission = Mission.LoadRandom(locations, rand, param as string);
        }
 public MultiPlayerCampaign(GameModePreset preset, object param) :
     base(preset, param)
 {
     currentCampaignID++;
     CampaignID = currentCampaignID;
     if (CampaignID > 127)
     {
         currentCampaignID = 0;
         CampaignID        = 0;
     }
 }
Esempio n. 12
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();
        }
Esempio n. 13
0
 public TestGameMode(GameModePreset preset) : base(preset)
 {
     foreach (JobPrefab jobPrefab in JobPrefab.Prefabs)
     {
         for (int i = 0; i < jobPrefab.InitialCount; i++)
         {
             var variant = Rand.Range(0, jobPrefab.Variants);
             CrewManager.AddCharacterInfo(new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: jobPrefab, variant: variant));
         }
     }
 }
Esempio n. 14
0
        public static void Init()
        {
#if CLIENT
            Tutorial             = new GameModePreset("tutorial", typeof(TutorialMode), true);
            DevSandbox           = new GameModePreset("devsandbox", typeof(GameMode), true);
            SinglePlayerCampaign = new GameModePreset("singleplayercampaign", typeof(SinglePlayerCampaign), true);
            TestMode             = new GameModePreset("testmode", typeof(TestGameMode), true);
#endif
            Sandbox             = new GameModePreset("sandbox", typeof(GameMode), false);
            Mission             = new GameModePreset("mission", typeof(MissionMode), false);
            MultiPlayerCampaign = new GameModePreset("multiplayercampaign", typeof(MultiPlayerCampaign), false, false);
        }
Esempio n. 15
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
        }
Esempio n. 16
0
        private GameMode InstantiateGameMode(GameModePreset gameModePreset, string seed, SubmarineInfo selectedSub, CampaignSettings settings, IEnumerable <MissionPrefab> missionPrefabs = null, MissionType missionType = MissionType.None)
        {
            if (gameModePreset.GameModeType == typeof(CoOpMode))
            {
                return(missionPrefabs != null ?
                       new CoOpMode(gameModePreset, missionPrefabs) :
                       new CoOpMode(gameModePreset, missionType, seed ?? ToolBox.RandomSeed(8)));
            }
            else if (gameModePreset.GameModeType == typeof(PvPMode))
            {
                return(missionPrefabs != null ?
                       new PvPMode(gameModePreset, missionPrefabs) :
                       new PvPMode(gameModePreset, missionType, seed ?? ToolBox.RandomSeed(8)));
            }
            else if (gameModePreset.GameModeType == typeof(MultiPlayerCampaign))
            {
                var campaign = MultiPlayerCampaign.StartNew(seed ?? ToolBox.RandomSeed(8), selectedSub, settings);
                if (campaign != null && selectedSub != null)
                {
                    campaign.Money = Math.Max(MultiPlayerCampaign.MinimumInitialMoney, campaign.Money - selectedSub.Price);
                }
                return(campaign);
            }
#if CLIENT
            else if (gameModePreset.GameModeType == typeof(SinglePlayerCampaign))
            {
                var campaign = SinglePlayerCampaign.StartNew(seed ?? ToolBox.RandomSeed(8), selectedSub, settings);
                if (campaign != null && selectedSub != null)
                {
                    campaign.Money = Math.Max(SinglePlayerCampaign.MinimumInitialMoney, campaign.Money - selectedSub.Price);
                }
                return(campaign);
            }
            else if (gameModePreset.GameModeType == typeof(TutorialMode))
            {
                return(new TutorialMode(gameModePreset));
            }
            else if (gameModePreset.GameModeType == typeof(TestGameMode))
            {
                return(new TestGameMode(gameModePreset));
            }
#endif
            else if (gameModePreset.GameModeType == typeof(GameMode))
            {
                return(new GameMode(gameModePreset));
            }
            else
            {
                throw new Exception($"Could not find a game mode of the type \"{gameModePreset.GameModeType}\"");
            }
        }
Esempio n. 17
0
        public void ClientRead(NetIncomingMessage inc)
        {
            if (GameMain.Server != null)
            {
                return;
            }

            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 <Submarine> serversubs = new List <Submarine>();
                    foreach (GUIComponent item in GameMain.NetLobbyScreen?.SubList?.children)
                    {
                        if (item.UserData != null && item.UserData is Submarine)
                        {
                            serversubs.Add(item.UserData as Submarine);
                        }
                    }
                    Submarine sub = serversubs.FirstOrDefault(sm => sm.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         modeName = inc.ReadString();
                    GameModePreset mode     = GameModePreset.list.Find(m => m.Name == modeName);
                    SetVoteText(GameMain.NetLobbyScreen.ModeList, mode, votes);
                }
            }
            AllowEndVoting = inc.ReadBoolean();
            if (AllowEndVoting)
            {
                GameMain.NetworkMember.EndVoteCount = inc.ReadByte();
                GameMain.NetworkMember.EndVoteMax   = inc.ReadByte();
            }
            AllowVoteKick = inc.ReadBoolean();

            inc.ReadPadBits();
        }
Esempio n. 18
0
        public SinglePlayerCampaign(GameModePreset preset, object param)
            : base(preset, param)
        {
            endRoundButton           = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 220, 20, 200, 25), TextManager.Get("EndRound"), null, Alignment.TopLeft, Alignment.Center, "");
            endRoundButton.Font      = GUI.SmallFont;
            endRoundButton.OnClicked = TryEndRound;

            foreach (JobPrefab jobPrefab in JobPrefab.List)
            {
                for (int i = 0; i < jobPrefab.InitialCount; i++)
                {
                    CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanConfigFile, "", Gender.None, jobPrefab));
                }
            }
        }
Esempio n. 19
0
        public static void Init()
        {
#if CLIENT
            new GameModePreset("Single Player", typeof(SinglePlayerCampaign), true);
            new GameModePreset("Tutorial", typeof(TutorialMode), true);
#endif

            var mode = new GameModePreset("SandBox", typeof(GameMode), false);
            mode.Description = "A game mode with no specific objectives.";

            mode             = new GameModePreset("Mission", typeof(MissionMode), false);
            mode.Description = "The crew must work together to complete a specific task, such as retrieving "
                               + "an alien artifact or killing a creature that's terrorizing nearby outposts. The game ends "
                               + "when the task is completed or everyone in the crew has died.";

            new GameModePreset("Campaign", typeof(MultiPlayerCampaign), false, false);
        }
Esempio n. 20
0
        public void ClientRead(NetIncomingMessage inc)
        {
            if (GameMain.Server != null)
            {
                return;
            }

            AllowSubVoting = inc.ReadBoolean();
            if (allowSubVoting)
            {
                foreach (Submarine sub in Submarine.SavedSubmarines)
                {
                    SetVoteText(GameMain.NetLobbyScreen.SubList, sub, 0);
                }
                int votableCount = inc.ReadByte();
                for (int i = 0; i < votableCount; i++)
                {
                    int       votes   = inc.ReadByte();
                    string    subName = inc.ReadString();
                    Submarine sub     = Submarine.SavedSubmarines.Find(sm => sm.Name == subName);
                    SetVoteText(GameMain.NetLobbyScreen.SubList, sub, votes);
                }
            }
            AllowModeVoting = inc.ReadBoolean();
            if (allowModeVoting)
            {
                int votableCount = inc.ReadByte();
                for (int i = 0; i < votableCount; i++)
                {
                    int            votes    = inc.ReadByte();
                    string         modeName = inc.ReadString();
                    GameModePreset mode     = GameModePreset.list.Find(m => m.Name == modeName);
                    SetVoteText(GameMain.NetLobbyScreen.ModeList, mode, votes);
                }
            }
            AllowEndVoting = inc.ReadBoolean();
            if (AllowEndVoting)
            {
                GameMain.NetworkMember.EndVoteCount = inc.ReadByte();
                GameMain.NetworkMember.EndVoteMax   = inc.ReadByte();
            }
            AllowVoteKick = inc.ReadBoolean();

            inc.ReadPadBits();
        }
Esempio n. 21
0
        public static void Init()
        {
            new GameModePreset("Single Player", typeof(SinglePlayerMode), true);
            new GameModePreset("Tutorial", typeof(TutorialMode), true);

            var mode = new GameModePreset("SandBox", typeof(GameMode), false);

            mode.Description = "A game mode with no specific objectives.";

            //mode = new GameModePreset("Traitor", typeof(TraitorMode), false);
            //mode.Description = "One of the players is selected as a traitor and given a secret objective. "
            //    + "The rest of the crew will win if they reach the end of the level or kill the traitor "
            //    + "before the objective is completed.";

            mode             = new GameModePreset("Mission", typeof(MissionMode), false);
            mode.Description = "The crew must work together to complete a specific task, such as retrieving "
                               + "an alien artifact or killing a creature that's terrorizing nearby outposts. The game ends "
                               + "when the task is completed or everyone in the crew has died.";
        }
        public SinglePlayerCampaign(GameModePreset preset, object param)
            : base(preset, param)
        {
            int buttonHeight = (int)(HUDLayoutSettings.ButtonAreaTop.Height * 0.7f);

            endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(HUDLayoutSettings.ButtonAreaTop.Right - 200, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonHeight / 2, 200, buttonHeight), GUICanvas.Instance),
                                           TextManager.Get("EndRound"), textAlignment: Alignment.Center)
            {
                Font      = GUI.SmallFont,
                OnClicked = (btn, userdata) => { TryEndRound(GetLeavingSub()); return(true); }
            };

            foreach (JobPrefab jobPrefab in JobPrefab.List.Values)
            {
                for (int i = 0; i < jobPrefab.InitialCount; i++)
                {
                    CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanSpeciesName, "", jobPrefab));
                }
            }
        }
Esempio n. 23
0
        public SinglePlayerCampaign(GameModePreset preset, object param)
            : base(preset, param)
        {
            int buttonHeight = (int)(HUDLayoutSettings.ButtonAreaTop.Height * 0.7f);

            endRoundButton = new GUIButton(HUDLayoutSettings.ToRectTransform(new Rectangle(HUDLayoutSettings.ButtonAreaTop.Right - 200, HUDLayoutSettings.ButtonAreaTop.Center.Y - buttonHeight / 2, 200, buttonHeight), GUICanvas.Instance),
                                           TextManager.Get("EndRound"), textAlignment: Alignment.Center)
            {
                Font      = GUI.SmallFont,
                OnClicked = TryEndRound
            };

            foreach (JobPrefab jobPrefab in JobPrefab.List)
            {
                for (int i = 0; i < jobPrefab.InitialCount; i++)
                {
                    CrewManager.AddCharacterInfo(new CharacterInfo(Character.HumanConfigFile, "", Gender.None, jobPrefab));
                }
            }
        }
Esempio n. 24
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();
        }
Esempio n. 25
0
        public void Init()
        {
            Mission.Init();
            MapEntityPrefab.Init();
            LevelGenerationParams.LoadPresets();

            JobPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Jobs));
            StructurePrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Structure));

            ItemPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Item));

            GameModePreset.Init();

            LocationType.Init();

            Submarine.RefreshSavedSubs();

            Screen.SelectNull();

            NetLobbyScreen = new NetLobbyScreen();
        }
Esempio n. 26
0
        public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset = null, string missionType = "")
        {
            Submarine.MainSub = submarine;

            GameMain.GameSession = this;

            CrewManager = new CrewManager();

            TaskManager = new TaskManager(this);

            this.saveFile = saveFile;

            infoButton           = new GUIButton(new Rectangle(10, 10, 100, 20), "Info", "", null);
            infoButton.OnClicked = ToggleInfoFrame;

            if (gameModePreset != null)
            {
                gameMode = gameModePreset.Instantiate(missionType);
            }
            this.submarine = submarine;
        }
Esempio n. 27
0
        public GameSession(Submarine submarine, string savePath, GameModePreset gameModePreset = null, string missionType = "")
        {
            Submarine.MainSub = submarine;

            GameMain.GameSession = this;

            EventManager = new EventManager(this);

            this.savePath = savePath;

#if CLIENT
            CrewManager = new CrewManager();

            infoButton           = new GUIButton(new Rectangle(10, 10, 100, 20), "Info", "", null);
            infoButton.OnClicked = ToggleInfoFrame;
#endif

            if (gameModePreset != null)
            {
                GameMode = gameModePreset.Instantiate(missionType);
            }
            this.submarine = submarine;
        }
Esempio n. 28
0
 public GameMode(GameModePreset preset, object param)
 {
     this.preset = preset;
 }
Esempio n. 29
0
        private IEnumerable <object> Load(bool isSeparateThread)
        {
            if (GameSettings.VerboseLogging)
            {
                DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime);
            }

            while (TitleScreen.WaitForLanguageSelection)
            {
                yield return(CoroutineStatus.Running);
            }

            SoundManager = new Sounds.SoundManager();
            SoundManager.SetCategoryGainMultiplier("default", Config.SoundVolume, 0);
            SoundManager.SetCategoryGainMultiplier("ui", Config.SoundVolume, 0);
            SoundManager.SetCategoryGainMultiplier("waterambience", Config.SoundVolume, 0);
            SoundManager.SetCategoryGainMultiplier("music", Config.MusicVolume, 0);
            SoundManager.SetCategoryGainMultiplier("voip", Math.Min(Config.VoiceChatVolume, 1.0f), 0);

            if (Config.EnableSplashScreen && !ConsoleArguments.Contains("-skipintro"))
            {
                var   pendingSplashScreens = TitleScreen.PendingSplashScreens;
                float baseVolume           = MathHelper.Clamp(Config.SoundVolume * 2.0f, 0.0f, 1.0f);
                pendingSplashScreens?.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_UTG.webm", baseVolume * 0.5f));
                pendingSplashScreens?.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_FF.webm", baseVolume));
                pendingSplashScreens?.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_Daedalic.webm", baseVolume * 0.1f));
            }

            //if not loading in a separate thread, wait for the splash screens to finish before continuing the loading
            //otherwise the videos will look extremely choppy
            if (!isSeparateThread)
            {
                while (TitleScreen.PlayingSplashScreen || TitleScreen.PendingSplashScreens.Count > 0)
                {
                    yield return(CoroutineStatus.Running);
                }
            }

            GUI.Init(Window, Config.AllEnabledPackages, GraphicsDevice);
            DebugConsole.Init();

            if (Config.AutoUpdateWorkshopItems)
            {
                Config.WaitingForAutoUpdate = true;
                TaskPool.Add("AutoUpdateWorkshopItemsAsync",
                             SteamManager.AutoUpdateWorkshopItemsAsync(), (task) =>
                {
                    bool result = ((Task <bool>)task).Result;

                    Config.WaitingForAutoUpdate = false;
                });

                while (Config.WaitingForAutoUpdate)
                {
                    yield return(CoroutineStatus.Running);
                }
            }

#if DEBUG
            if (Config.ModBreakerMode)
            {
                Config.SelectCorePackage(ContentPackage.CorePackages.GetRandom());
                foreach (var regularPackage in ContentPackage.RegularPackages)
                {
                    if (Rand.Range(0.0, 1.0) <= 0.5)
                    {
                        Config.EnableRegularPackage(regularPackage);
                    }
                    else
                    {
                        Config.DisableRegularPackage(regularPackage);
                    }
                }
                ContentPackage.SortContentPackages(p =>
                {
                    return(Rand.Int(int.MaxValue));
                });
            }
#endif

            if (Config.AllEnabledPackages.None())
            {
                DebugConsole.Log("No content packages selected");
            }
            else
            {
                DebugConsole.Log("Selected content packages: " + string.Join(", ", Config.AllEnabledPackages.Select(cp => cp.Name)));
            }

#if DEBUG
            GameSettings.ShowUserStatisticsPrompt = false;
            GameSettings.SendUserStatistics       = false;
#endif

            InitUserStats();

            yield return(CoroutineStatus.Running);

            Debug.WriteLine("sounds");

            int i = 0;
            foreach (object crObj in SoundPlayer.Init())
            {
                CoroutineStatus status = (CoroutineStatus)crObj;
                if (status == CoroutineStatus.Success)
                {
                    break;
                }

                i++;
                TitleScreen.LoadState = SoundPlayer.SoundCount == 0 ?
                                        1.0f :
                                        Math.Min(40.0f * i / Math.Max(SoundPlayer.SoundCount, 1), 40.0f);

                yield return(CoroutineStatus.Running);
            }

            TitleScreen.LoadState = 40.0f;
            yield return(CoroutineStatus.Running);

            LightManager = new Lights.LightManager(base.GraphicsDevice, Content);

            TitleScreen.LoadState = 41.0f;
            yield return(CoroutineStatus.Running);

            GUI.LoadContent();
            TitleScreen.LoadState = 42.0f;

            yield return(CoroutineStatus.Running);

            TaskPool.Add("InitRelayNetworkAccess", SteamManager.InitRelayNetworkAccess(), (t) => { });

            FactionPrefab.LoadFactions();
            NPCSet.LoadSets();
            CharacterPrefab.LoadAll();
            MissionPrefab.Init();
            TraitorMissionPrefab.Init();
            MapEntityPrefab.Init();
            Tutorials.Tutorial.Init();
            MapGenerationParams.Init();
            LevelGenerationParams.LoadPresets();
            CaveGenerationParams.LoadPresets();
            OutpostGenerationParams.LoadPresets();
            WreckAIConfig.LoadAll();
            EventSet.LoadPrefabs();
            ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item));
            AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions));
            SkillSettings.Load(GetFilesOfType(ContentType.SkillSettings));
            Order.Init();
            EventManagerSettings.Init();
            BallastFloraPrefab.LoadAll(GetFilesOfType(ContentType.MapCreature));
            HintManager.Init();
            TitleScreen.LoadState = 50.0f;
            yield return(CoroutineStatus.Running);

            StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure));
            TitleScreen.LoadState = 55.0f;
            yield return(CoroutineStatus.Running);

            UpgradePrefab.LoadAll(GetFilesOfType(ContentType.UpgradeModules));
            TitleScreen.LoadState = 56.0f;
            yield return(CoroutineStatus.Running);

            JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs));
            CorpsePrefab.LoadAll(GetFilesOfType(ContentType.Corpses));

            NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations));

            ItemAssemblyPrefab.LoadAll();
            TitleScreen.LoadState = 60.0f;
            yield return(CoroutineStatus.Running);

            GameModePreset.Init();

            SaveUtil.DeleteDownloadedSubs();
            SubmarineInfo.RefreshSavedSubs();

            TitleScreen.LoadState = 65.0f;
            yield return(CoroutineStatus.Running);

            GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content);

            TitleScreen.LoadState = 68.0f;
            yield return(CoroutineStatus.Running);

            MainMenuScreen   = new MainMenuScreen(this);
            ServerListScreen = new ServerListScreen();

            TitleScreen.LoadState = 70.0f;
            yield return(CoroutineStatus.Running);

#if USE_STEAM
            SteamWorkshopScreen = new SteamWorkshopScreen();
            if (SteamManager.IsInitialized)
            {
                Steamworks.SteamFriends.OnGameRichPresenceJoinRequested += OnInvitedToGame;
                Steamworks.SteamFriends.OnGameLobbyJoinRequested        += OnLobbyJoinRequested;
            }
#endif

            SubEditorScreen = new SubEditorScreen();

            TitleScreen.LoadState = 75.0f;
            yield return(CoroutineStatus.Running);

            ParticleEditorScreen = new ParticleEditorScreen();

            TitleScreen.LoadState = 80.0f;
            yield return(CoroutineStatus.Running);

            LevelEditorScreen     = new LevelEditorScreen();
            SpriteEditorScreen    = new SpriteEditorScreen();
            EventEditorScreen     = new EventEditorScreen();
            CharacterEditorScreen = new CharacterEditor.CharacterEditorScreen();
            CampaignEndScreen     = new CampaignEndScreen();

            yield return(CoroutineStatus.Running);

            TitleScreen.LoadState = 85.0f;
            ParticleManager       = new ParticleManager(GameScreen.Cam);
            ParticleManager.LoadPrefabs();
            TitleScreen.LoadState = 88.0f;
            LevelObjectPrefab.LoadAll();

            TitleScreen.LoadState = 90.0f;
            yield return(CoroutineStatus.Running);

            DecalManager = new DecalManager();
            LocationType.Init();
            MainMenuScreen.Select();

            foreach (string steamError in SteamManager.InitializationErrors)
            {
                new GUIMessageBox(TextManager.Get("Error"), TextManager.Get(steamError));
            }

            TitleScreen.LoadState = 100.0f;
            hasLoaded             = true;
            if (GameSettings.VerboseLogging)
            {
                DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime);
            }
            yield return(CoroutineStatus.Success);
        }
Esempio n. 30
0
        private IEnumerable <object> Load(bool isSeparateThread)
        {
            if (GameSettings.VerboseLogging)
            {
                DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime);
            }

            while (TitleScreen.WaitForLanguageSelection)
            {
                yield return(CoroutineStatus.Running);
            }

            SoundManager = new Sounds.SoundManager();
            SoundManager.SetCategoryGainMultiplier("default", Config.SoundVolume, 0);
            SoundManager.SetCategoryGainMultiplier("ui", Config.SoundVolume, 0);
            SoundManager.SetCategoryGainMultiplier("waterambience", Config.SoundVolume, 0);
            SoundManager.SetCategoryGainMultiplier("music", Config.MusicVolume, 0);
            SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume * 20.0f, 0);

            if (ConsoleArguments.Contains("-skipintro"))
            {
                Config.EnableSplashScreen = false;
            }

            if (Config.EnableSplashScreen)
            {
                var pendingSplashScreens = TitleScreen.PendingSplashScreens;
                pendingSplashScreens?.Enqueue(new Pair <string, Point>("Content/Splash_UTG.mp4", new Point(1280, 720)));
                pendingSplashScreens?.Enqueue(new Pair <string, Point>("Content/Splash_FF.mp4", new Point(1280, 720)));
                pendingSplashScreens?.Enqueue(new Pair <string, Point>("Content/Splash_Daedalic.mp4", new Point(1920, 1080)));
            }

            //if not loading in a separate thread, wait for the splash screens to finish before continuing the loading
            //otherwise the videos will look extremely choppy
            if (!isSeparateThread)
            {
                while (TitleScreen.PlayingSplashScreen || TitleScreen.PendingSplashScreens.Count > 0)
                {
                    yield return(CoroutineStatus.Running);
                }
            }

            GUI.Init(Window, Config.SelectedContentPackages, GraphicsDevice);
            DebugConsole.Init();

            if (Config.AutoUpdateWorkshopItems)
            {
                if (SteamManager.AutoUpdateWorkshopItems())
                {
                    ContentPackage.LoadAll();
                    Config.ReloadContentPackages();
                }
            }

            if (SelectedPackages.Count == 0)
            {
                DebugConsole.Log("No content packages selected");
            }
            else
            {
                DebugConsole.Log("Selected content packages: " + string.Join(", ", SelectedPackages.Select(cp => cp.Name)));
            }

#if DEBUG
            GameSettings.ShowUserStatisticsPrompt = false;
            GameSettings.SendUserStatistics       = false;
#endif

            InitUserStats();

            yield return(CoroutineStatus.Running);

            Debug.WriteLine("sounds");

            int i = 0;
            foreach (object crObj in SoundPlayer.Init())
            {
                CoroutineStatus status = (CoroutineStatus)crObj;
                if (status == CoroutineStatus.Success)
                {
                    break;
                }

                i++;
                TitleScreen.LoadState = SoundPlayer.SoundCount == 0 ?
                                        1.0f :
                                        Math.Min(40.0f * i / Math.Max(SoundPlayer.SoundCount, 1), 40.0f);

                yield return(CoroutineStatus.Running);
            }

            TitleScreen.LoadState = 40.0f;
            yield return(CoroutineStatus.Running);

            LightManager = new Lights.LightManager(base.GraphicsDevice, Content);

            TitleScreen.LoadState = 41.0f;
            yield return(CoroutineStatus.Running);

            GUI.LoadContent();
            TitleScreen.LoadState = 42.0f;

            yield return(CoroutineStatus.Running);

            MissionPrefab.Init();
            MapEntityPrefab.Init();
            Tutorials.Tutorial.Init();
            MapGenerationParams.Init();
            LevelGenerationParams.LoadPresets();
            ScriptedEventSet.LoadPrefabs();
            AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions));
            TitleScreen.LoadState = 50.0f;
            yield return(CoroutineStatus.Running);

            StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure));
            TitleScreen.LoadState = 53.0f;
            yield return(CoroutineStatus.Running);

            ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item));
            TitleScreen.LoadState = 55.0f;
            yield return(CoroutineStatus.Running);

            JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs));
            // Add any missing jobs from the prefab into Config.JobNamePreferences.
            foreach (JobPrefab job in JobPrefab.List)
            {
                if (!Config.JobPreferences.Contains(job.Identifier))
                {
                    Config.JobPreferences.Add(job.Identifier);
                }
            }

            NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations));

            ItemAssemblyPrefab.LoadAll();
            TitleScreen.LoadState = 60.0f;
            yield return(CoroutineStatus.Running);

            GameModePreset.Init();

            Submarine.RefreshSavedSubs();

            TitleScreen.LoadState = 65.0f;
            yield return(CoroutineStatus.Running);

            GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content);

            TitleScreen.LoadState = 68.0f;
            yield return(CoroutineStatus.Running);

            MainMenuScreen   = new MainMenuScreen(this);
            LobbyScreen      = new LobbyScreen();
            ServerListScreen = new ServerListScreen();

            TitleScreen.LoadState = 70.0f;
            yield return(CoroutineStatus.Running);

            if (SteamManager.USE_STEAM)
            {
                SteamWorkshopScreen = new SteamWorkshopScreen();
                if (SteamManager.IsInitialized)
                {
                    SteamManager.Instance.Friends.OnInvitedToGame    += OnInvitedToGame;
                    SteamManager.Instance.Lobby.OnLobbyJoinRequested += OnLobbyJoinRequested;
                }
            }
            SubEditorScreen = new SubEditorScreen();

            TitleScreen.LoadState = 75.0f;
            yield return(CoroutineStatus.Running);

            ParticleEditorScreen = new ParticleEditorScreen();

            TitleScreen.LoadState = 80.0f;
            yield return(CoroutineStatus.Running);

            LevelEditorScreen     = new LevelEditorScreen();
            SpriteEditorScreen    = new SpriteEditorScreen();
            CharacterEditorScreen = new CharacterEditorScreen();

            yield return(CoroutineStatus.Running);

            TitleScreen.LoadState = 85.0f;
            ParticleManager       = new ParticleManager(GameScreen.Cam);
            ParticleManager.LoadPrefabs();
            TitleScreen.LoadState = 88.0f;
            LevelObjectPrefab.LoadAll();

            TitleScreen.LoadState = 90.0f;
            yield return(CoroutineStatus.Running);

            DecalManager = new DecalManager();
            LocationType.Init();
            MainMenuScreen.Select();

            CheckContentPackage();

            foreach (string steamError in SteamManager.InitializationErrors)
            {
                new GUIMessageBox(TextManager.Get("Error"), TextManager.Get(steamError));
            }

            TitleScreen.LoadState = 100.0f;
            hasLoaded             = true;
            if (GameSettings.VerboseLogging)
            {
                DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime);
            }
            yield return(CoroutineStatus.Success);
        }