public ComponentManager(ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicsDeviceManager)
        {
            _contentManager     = contentManager;
            _resourceRepository = new ResourceRepository(new BasicResourceRepositoryConfiguration(), _contentManager);

            Font = _resourceRepository.GetFont();
            _spaceShipTexture = _resourceRepository.GetTextureByType(typeof(SpaceShip));

            var graphicsDevice = graphicsDeviceManager.GraphicsDevice;

            Configuration = new BasicGameConfiguration(
                _spaceShipTexture.Height,
                Font
                );

            graphicsDeviceManager.PreferredBackBufferWidth  = Configuration.ScreenSize.Width;
            graphicsDeviceManager.PreferredBackBufferHeight = Configuration.ScreenSize.Height;
            graphicsDeviceManager.ApplyChanges();

            SpaceShip      = new SpaceShip(Configuration, new Size(_spaceShipTexture.Width, _spaceShipTexture.Height));
            _ballTexture   = _resourceRepository.GetTextureByType(typeof(BasicBall));
            BallRepository = new BallRepository(Configuration, new Size(_ballTexture.Width, _ballTexture.Height));

            Balls = new List <IBall>();

            _drawer = new ComponentDrawer(graphicsDevice, Font);

            Prizes = new List <IPrize>();
            Shoots = new List <IShoot>();

            MediaPlayer.Volume = .03f;
        }
Beispiel #2
0
        public TestGame()
        {
            var graphics = new GraphicsDeviceManager(this) {
                GraphicsProfile = GraphicsProfile.HiDef,
                PreferredBackBufferWidth = 1440,
                PreferredBackBufferHeight = 900,
                SynchronizeWithVerticalRetrace = true,
                IsFullScreen = false
            };
            graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings;

            Content.RootDirectory = "Content";

            IsMouseVisible = true;
            IsFixedTimeStep = false;
            //TargetElapsedTime = TimeSpan.FromSeconds(1f / 30f);
            DisplayUI = true;

            Kernel = NinjectKernel.Instance;
            NinjectKernel.BindGame(this);
            Kernel.Settings.AllowNullInjection = true;

            _previousKeyboard = Keyboard.GetState();

            _framerate = new StreamWriter(File.OpenWrite("framerate.csv"));
            Exiting += TestGame_Exiting;
        }
Beispiel #3
0
 internal static void SetupCamera(Camera cameraToSetUp, Microsoft.Xna.Framework.GraphicsDeviceManager graphicsDeviceManager)
 {
     CameraSetup.graphicsDeviceManager = graphicsDeviceManager;
     ResetWindow();
     ResetCamera(cameraToSetUp);
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SizeOrOrientationChanged += HandleResolutionChange;
 }
Beispiel #4
0
 /// <summary>
 /// Toggles whether or not the game window renders in fullscreen or windowed mode
 /// </summary>
 /// <param name="shouldApplyChanges">Whether or not to apply the graphics changes immediately.</param>
 public void ToggleFullscreen(bool shouldApplyChanges = true)
 {
     GraphicsDeviceManager.ToggleFullScreen();
     if (shouldApplyChanges)
     {
         GraphicsDeviceManager.ApplyChanges();
     }
 }
Beispiel #5
0
 public void InitGraphicsDevice(
     Microsoft.Xna.Framework.GraphicsDeviceManager manager,
     Microsoft.Xna.Framework.Graphics.GraphicsDevice device)
 {
     manager.PreferredBackBufferWidth  = _windowWidth;
     manager.PreferredBackBufferHeight = _windowHeight;
     manager.IsFullScreen             = _fullScreen;
     manager.PreferMultiSampling      = _preferMultiSampling;
     manager.PreparingDeviceSettings += OnPreparingDeviceSettings;
     manager.ApplyChanges();
 }
Beispiel #6
0
 internal static void SetupCamera(Camera cameraToSetUp, Microsoft.Xna.Framework.GraphicsDeviceManager graphicsDeviceManager, int width = 480, int height = 270)
 {
                         #if WINDOWS || DESKTOP_GL
     FlatRedBall.FlatRedBallServices.Game.Window.AllowUserResizing = true;
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SetResolution((int)(width * Scale), (int)(height * Scale));
                         #elif IOS || ANDROID
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SetFullScreen(FlatRedBall.FlatRedBallServices.GraphicsOptions.ResolutionWidth, FlatRedBall.FlatRedBallServices.GraphicsOptions.ResolutionHeight);
                         #elif UWP
                         #endif
     ResetCamera(cameraToSetUp);
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SizeOrOrientationChanged += HandleResolutionChange;
 }
Beispiel #7
0
 internal static void SetupCamera(Camera cameraToSetUp, Microsoft.Xna.Framework.GraphicsDeviceManager graphicsDeviceManager, int width = 800, int height = 600)
 {
         #if WINDOWS || DESKTOP_GL
     FlatRedBall.FlatRedBallServices.Game.Window.AllowUserResizing = false;
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SetResolution(width, height);
         #elif IOS || ANDROID
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SetFullScreen(FlatRedBall.FlatRedBallServices.GraphicsOptions.ResolutionWidth, FlatRedBall.FlatRedBallServices.GraphicsOptions.ResolutionHeight);
         #elif UWP
     FlatRedBall.FlatRedBallServices.GraphicsOptions.SetResolution(width, height);
         #endif
     ResetCamera(cameraToSetUp);
 }
Beispiel #8
0
        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            _graphics.GraphicsProfile           = GraphicsProfile.Reach;
            _graphics.PreferMultiSampling       = true;
            _graphics.PreferredBackBufferWidth  = 1024;
            _graphics.PreferredBackBufferHeight = 768;

            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            IsFixedTimeStep = true;
            _graphics.SynchronizeWithVerticalRetrace = true;
        }
        // Initialize all graphics properties.
        public void Initialize(XnaGraphicsDeviceManager xnaGraphics)
        {
            if (null != this.graphics)
              {
            return;
              }

              this.graphics = xnaGraphics;
              this.graphics.PreferredBackBufferWidth = 640;
              this.graphics.PreferredBackBufferHeight = 480;
              this.graphics.IsFullScreen = false;
              this.graphics.ApplyChanges();

              this.spriteBatch = new SpriteBatch(this.graphics.GraphicsDevice);
        }
Beispiel #10
0
        // Initialize all graphics properties.
        public void Initialize(XnaGraphicsDeviceManager xnaGraphics)
        {
            if (null != _graphics)
            {
                return;
            }

            _graphics = xnaGraphics;
            _graphics.PreferredBackBufferWidth  = 800;
            _graphics.PreferredBackBufferHeight = 600;
            _graphics.IsFullScreen = false;
            _graphics.ApplyChanges();

            GraphicsDevice = _graphics.GraphicsDevice;
            SpriteBatch    = new SpriteBatch(GraphicsDevice);
        }
Beispiel #11
0
        // Initialize all graphics properties.
        public void Initialize(XnaGraphicsDeviceManager xnaGraphics)
        {
            if (null != _graphics)
            {
                return;
            }

            _graphics = xnaGraphics;
            _graphics.PreferredBackBufferWidth = 800;
            _graphics.PreferredBackBufferHeight = 600;
            _graphics.IsFullScreen = false;
            _graphics.ApplyChanges();

            GraphicsDevice = _graphics.GraphicsDevice;
            SpriteBatch = new SpriteBatch(GraphicsDevice);
        }
        public VisionView(GraphicsEngine _graphicEngine, SpriteBatch sb, GraphicsDeviceManager _gman, Vector2 _cameraOffset, Point _origin, float rotation, List<Line> _visionBlockingLines)
        {
            graphicEngine = _graphicEngine;
            gman = _gman;
            origin = _origin;
            visionBlockingLines = _visionBlockingLines;
            cameraOffset = _cameraOffset;

            //List<Point> lightPolygon
            //lightPolygon = new Vision().GetLightPolygons();
            vision = new Vision(origin, rotation, _visionBlockingLines);

            //Console.WriteLine(origin);

            displayLight(sb, cameraOffset, vision.lightTriangles);
        }
Beispiel #13
0
        /// <summary>
        /// Setup the game properties
        /// </summary>
        /// <param name="contentManager">the XNA content manager to be used</param>
        /// <param name="graphicDeviceManager">the XNA graphic manager to be used</param>
        public GameProperties(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window)
        {
            // load game properties
            System.Xml.XmlDocument config = new System.Xml.XmlDocument();
            config.Load(@"Content/config.xml");

            // try resolution
            try
            {
                graphicDeviceManager.PreferredBackBufferWidth = Convert.ToInt32(config.GetElementsByTagName("resolutionX")[0].InnerText);
                graphicDeviceManager.PreferredBackBufferHeight = Convert.ToInt32(config.GetElementsByTagName("resolutionY")[0].InnerText);
                Screen screen = Screen.PrimaryScreen;
                window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.Width / 2 - graphicDeviceManager.PreferredBackBufferWidth / 2, screen.Bounds.Height / 2 - graphicDeviceManager.PreferredBackBufferHeight / 2);
            }
            catch (Exception)
            {
                graphicDeviceManager.PreferredBackBufferWidth = 1280;
                graphicDeviceManager.PreferredBackBufferHeight = 720;
            }

            // try fullscreen
            try
            {
                int fullscreen = Convert.ToInt32(config.GetElementsByTagName("fullscreen")[0].InnerText);
                if (fullscreen == 1)
                {
                    Screen screen = Screen.PrimaryScreen;
                    window.IsBorderless = true;
                    window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.X, screen.Bounds.Y);
                    graphicDeviceManager.PreferredBackBufferWidth = screen.Bounds.Width;
                    graphicDeviceManager.PreferredBackBufferHeight = screen.Bounds.Height;
                    this.isFullscreen = true;
                }
                else
                {
                    this.isFullscreen = false;
                }
            }
            catch (Exception) { }

            graphicDeviceManager.ApplyChanges();

            // try language settings
            try
            {
                this.SelectedLanguage = config.GetElementsByTagName("language")[0].InnerText;
            }
            catch(Exception){ }

            this.currentGameState = GameState.LoadMenu;
            this.input = new InputHandler();

            this.contentManager = new Helper.ContentManager(contentManager);
            this.spriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(graphicDeviceManager.GraphicsDevice);
            this.graphicDeviceManager = graphicDeviceManager;
            this.gameWindow = window;

            System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(@"Content\Shader\main_shader.mgfxo", System.IO.FileMode.Open));
            this.baseShader = new Microsoft.Xna.Framework.Graphics.Effect(this.graphicDeviceManager.GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length));
        }
 public XnaGame(Action update, Action render)
 {
     this.update = update;
     this.render = render;
     this.graphics = new Microsoft.Xna.Framework.GraphicsDeviceManager(this);
     this.Content.RootDirectory = "Content";
     this.IsFixedTimeStep = false;
     this.InactiveSleepTime = TimeSpan.FromSeconds(1);
     this.IsMouseVisible = true;
     this.Window.AllowUserResizing = true;
 }
Beispiel #15
0
        /// <summary>
        /// Setup the game properties
        /// </summary>
        /// <param name="contentManager">the XNA content manager to be used</param>
        /// <param name="graphicDeviceManager">the XNA graphic manager to be used</param>
        public GameProperties(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window)
        {
            // load game properties
            System.Xml.XmlDocument config = new System.Xml.XmlDocument();
            config.Load(@"Content/config.xml");

            // try resolution
            try
            {
                graphicDeviceManager.PreferredBackBufferWidth  = Convert.ToInt32(config.GetElementsByTagName("resolutionX")[0].InnerText);
                graphicDeviceManager.PreferredBackBufferHeight = Convert.ToInt32(config.GetElementsByTagName("resolutionY")[0].InnerText);
                Screen screen = Screen.PrimaryScreen;
                window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.Width / 2 - graphicDeviceManager.PreferredBackBufferWidth / 2, screen.Bounds.Height / 2 - graphicDeviceManager.PreferredBackBufferHeight / 2);
            }
            catch (Exception)
            {
                graphicDeviceManager.PreferredBackBufferWidth  = 1280;
                graphicDeviceManager.PreferredBackBufferHeight = 720;
            }


            // try fullscreen
            try
            {
                int fullscreen = Convert.ToInt32(config.GetElementsByTagName("fullscreen")[0].InnerText);
                if (fullscreen == 1)
                {
                    Screen screen = Screen.PrimaryScreen;
                    window.IsBorderless = true;
                    window.Position     = new Microsoft.Xna.Framework.Point(screen.Bounds.X, screen.Bounds.Y);
                    graphicDeviceManager.PreferredBackBufferWidth  = screen.Bounds.Width;
                    graphicDeviceManager.PreferredBackBufferHeight = screen.Bounds.Height;
                    this.isFullscreen = true;
                }
                else
                {
                    this.isFullscreen = false;
                }
            }
            catch (Exception) { }

            graphicDeviceManager.ApplyChanges();

            // try language settings
            try
            {
                this.SelectedLanguage = config.GetElementsByTagName("language")[0].InnerText;
            }
            catch (Exception) { }


            this.currentGameState = GameState.LoadMenu;
            this.input            = new InputHandler();

            this.contentManager       = new Helper.ContentManager(contentManager);
            this.spriteBatch          = new Microsoft.Xna.Framework.Graphics.SpriteBatch(graphicDeviceManager.GraphicsDevice);
            this.graphicDeviceManager = graphicDeviceManager;
            this.gameWindow           = window;

            System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(@"Content\Shader\main_shader.mgfxo", System.IO.FileMode.Open));
            this.baseShader = new Microsoft.Xna.Framework.Graphics.Effect(this.graphicDeviceManager.GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length));
        }
 //readonly Color visionViewColor = Color.White;
 //readonly Color visionViewColor = Color.SlateGray;
 public static Vision Draw(GraphicsEngine _graphicEngine, SpriteBatch sb, GraphicsDeviceManager _gman, Vector2 cameraOffset, Point origin, float rotation, List<Line> visionBlockingLines)
 {
     VisionView vv = new VisionView(_graphicEngine, sb, _gman, cameraOffset, origin, rotation, visionBlockingLines);
     //return vv.lightPolygon;
     return vv.vision;
 }
Beispiel #17
0
        private void InternalSetupVideoSettings(int windowWidth, int windowHeight, bool?fullscreen = null, bool?vsync = null, float?pixelScale = null)
        {
            bool hasPresentingSettingsChanged = false,
                 hasViewSettingsChanged       = false;

            Microsoft.Xna.Framework.GraphicsDeviceManager graphics = XNAGameWrapper.GraphicsDeviceManager;

            if (fullscreen.HasValue && graphics.IsFullScreen != fullscreen.Value)
            {
                BeforeSwitchingFullscreen(fullscreen.Value);
                graphics.IsFullScreen        = fullscreen.Value;
                hasPresentingSettingsChanged = true;
            }

            windowWidth  = (int)Math.Max(windowWidth, WindowMinimumSize.Width);
            windowHeight = (int)Math.Max(windowHeight, WindowMinimumSize.Height);

            if (graphics.PreferredBackBufferWidth != windowWidth)
            {
                graphics.PreferredBackBufferWidth = windowWidth;
                hasPresentingSettingsChanged      = true;
            }

            if (graphics.PreferredBackBufferHeight != windowHeight)
            {
                graphics.PreferredBackBufferHeight = windowHeight;
                hasPresentingSettingsChanged       = true;
            }

            if (vsync.HasValue && graphics.SynchronizeWithVerticalRetrace != vsync.Value)
            {
                graphics.SynchronizeWithVerticalRetrace = vsync.Value;
                hasPresentingSettingsChanged            = true;
            }

            if (pixelScale.HasValue)
            {
                float scale = pixelScale.Value <= Math.Epsilon ? Math.Epsilon : pixelScale.Value;

                if (_pixelScale != scale)
                {
                    _pixelScale            = scale;
                    hasViewSettingsChanged = true;
                }
            }

            if (NextResizeMode == ResizeMode.KeepProportions && (_nextInternalWidth != Width || _nextInternalHeight != Height))
            {
                hasViewSettingsChanged = true;
            }

            if (!hasPresentingSettingsChanged)
            {
                if (hasViewSettingsChanged || NextResizeMode != ResizeMode)
                {
                    RefreshViewMode(NextResizeMode, PixelScale);
                }

                return;
            }

            graphics.ApplyChanges();
        }
Beispiel #18
0
        /// <summary>
        /// initialize verything
        /// required to run this
        /// </summary>
        /// <param name="contentManager">the XNA content Manager</param>
        /// <param name="graphicDeviceManager">the XNA graphic manager</param>
        /// /// <param name="displayModes">possible display modes</param>
        public void Run(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window, Microsoft.Xna.Framework.Game game)
        {
            this.Properties = new GameProperties(contentManager, graphicDeviceManager, window);

            // load bare media to initialize loadingscreen
            // Cursor textures
            FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorRegular, "Texture/Cursor/Default");
            FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorCamera, "Texture/Cursor/Camera");

            this.game = game;

            this.renderer = new Renderer();

            this.cursor = new Cursor();

            this.menuLoader = new LoadingScreen.LoadMenu();
            this.gameLoader = new LoadingScreen.LoadGame();
        }
Beispiel #19
0
 /// <summary>
 /// Applies pending changes to the <see cref="Microsoft.Xna.Framework.GraphicsDeviceManager"/>.
 /// </summary>
 public void ApplyChanges()
 {
     GraphicsDeviceManager.ApplyChanges();
 }
Beispiel #20
0
 /// <param name="game">Reference to current <see cref="Komodo.Core.Game"/> instance.</param>
 public GraphicsManager(Game game)
 {
     Game = game;
     GraphicsDeviceManager = new GraphicsDeviceManager(_monoGame);
 }