Beispiel #1
0
        public static GameProfile NewProfile()
        {
            GameProfile profile = new GameProfile();

            profile.ResetAll();
            return(profile);
        }
Beispiel #2
0
        public static void Save(GameProfile profile)
        {
            String path = GetSavePath();

            Directory.CreateDirectory(Path.GetDirectoryName(path));

            FileStream    f             = File.Create(path);
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(GameProfile));

            xmlSerializer.Serialize(f, profile);
            f.Close();
        }
Beispiel #3
0
        public override void Startup()
        {
            //Registering assemblies needed for scripts
            ScriptAssembly.Assemblies.Add(Assembly.GetExecutingAssembly());
            ScriptAssembly.Assemblies.Add(typeof(Microsoft.Xna.Framework.Vector2).Assembly);
            ScriptAssembly.Assemblies.Add(typeof(FarseerPhysics.Dynamics.Body).Assembly);
            ScriptAssembly.Assemblies.Add(typeof(LBE.Gameplay.GameObject).Assembly);

            //Loading configuration
            m_configParameters = Engine.AssetManager.GetAsset <ConfigParameters>("Game/Config.lua::Config");
            Engine.Renderer.SetResolution(
                m_configParameters.Content.ResolutionX,
                m_configParameters.Content.ResolutionY);

            //Loading starting infos
            m_startInfo = Engine.AssetManager.Get <GameStartInfo>("Game/GameStart.lua::GameStart");
            if (m_startInfo.Release)
            {
                m_startInfo = new GameStartInfo()
                {
                    Release = true
                }
            }
            ;

            Engine.Debug.Flags.EnableAI       = m_startInfo.EnableAI;
            Engine.Debug.Flags.RenderDebug    = m_startInfo.RenderDebug;
            Engine.Debug.Flags.EnableCommands = !m_startInfo.Release;

            //Loading player profil
            m_gameProfil = GameProfile.Load();
            if (m_gameProfil == null)
            {
                m_gameProfil = GameProfile.NewProfile();
            }
            GameProfile.Save(m_gameProfil);

            //Create game session
            m_gameSession = new Ball.GameSession();

            //Creating managers
            m_statManager = new StatManager();
            m_gameManager = new GameManager();
            m_optionMgr   = new OptionManager();
            m_menuManager = new MenuManager();
            m_gameMusic   = new GameMusic();

            //Reset control
            m_resetCtrl = new KeyControl(Keys.Home);

            //Start the game!!!
            StartGame();
        }
Beispiel #4
0
        public static GameProfile Load()
        {
            String path = GetSavePath();

            if (File.Exists(path))
            {
                FileStream    f             = File.Open(path, FileMode.Open);
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(GameProfile));
                GameProfile   profile       = (GameProfile)xmlSerializer.Deserialize(f);
                f.Close();

                return(profile);
            }
            else
            {
                return(null);
            }
        }