コード例 #1
0
        public ScreenManager(Game game)
            : base(game)
        {
            base.Initialize();
            isInitialized = true;

            // Sets up a input system
            inputSystem = new InputManager();
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: Bigtalljosh/Devoxelation
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            // Initialises the Resolution class, allowing the game to auto-scale all assets based on the resolution.
            Resolution.Init(ref graphics);
            Content.RootDirectory = "Content";

            IsFixedTimeStep = false;

            // Sets up the path to the content folder based on the .exe local location
            _index = Assembly.GetExecutingAssembly().Location.LastIndexOf("\\");
            _path = Assembly.GetExecutingAssembly().Location.Substring(0, _index);

            // Loads the Application Settings XML file
            System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
            System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
            appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");

            // Sets the application settings based on the values of the XML file.
            // Some of the values have to be converted to a different type as when they are read
            // they are all read in as Strings. Of course this then doesn't match the intended type.
            Window.Title = appConfigXML.SelectSingleNode("//ScreenTitle").InnerText;
            int selectedResolutionWidth = Convert.ToInt16(appConfigXML.SelectSingleNode("//ScreenWidth").InnerText);
            int selectedResolutionHeight = Convert.ToInt16(appConfigXML.SelectSingleNode("//ScreenHeight").InnerText);
            bool selectedFullScreen = Convert.ToBoolean(appConfigXML.SelectSingleNode("//FullScreen").InnerText);
            //bool selectedFullScreen = false;

            // Change Virtual Resolution
            Resolution.SetVirtualResolution(1280, 720); // This is the default resolution.. do not change this or you'll break everything!
            Resolution.SetResolution(selectedResolutionWidth, selectedResolutionHeight, selectedFullScreen);

            screenManager = new ScreenManager(this);
            inputManager = new InputManager();
            Components.Add(screenManager);
        }