Example #1
0
        //protected override void Initialize()
        //{
        //    base.Initialize();

        //    _graphicsDeviceManager.IsFullScreen = true;
        //    _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
        //    _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
        //    _graphicsDeviceManager.ApplyChanges();
        //}

        protected override void LoadContent()
        {
            _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
            _font            = Content.Load <BitmapFont>("Fonts/montserrat-32");

            _camera = new OrthographicCamera(_viewportAdapter);
            //_explosionAnimations = Content.Load<SpriteSheetAnimationFactory>("explosion-animations");

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _backgroundTexture = Content.Load <Texture2D>("black");

            var bulletTexture = Content.Load <Texture2D>("laserBlue03");
            var bulletRegion  = new TextureRegion2D(bulletTexture);

            _bulletFactory = new BulletFactory(_entityManager, bulletRegion);

            SpawnPlayer(_bulletFactory);

            _meteorFactory = new MeteorFactory(_entityManager, Content);

            for (var i = 0; i < 13; i++)
            {
                _meteorFactory.SpawnNewMeteor(_player.Position);
            }
        }
Example #2
0
        private void SpawnPlayer(BulletFactory bulletFactory)
        {
            var spaceshipTexture = Content.Load <Texture2D>("playerShip1_blue");
            var spaceshipRegion  = new TextureRegion2D(spaceshipTexture);

            _player = _entityManager.AddEntity(new Spaceship(spaceshipRegion, bulletFactory));
        }
Example #3
0
        protected override void LoadContent()
        {
            _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
            _camera          = new Camera2D(_viewportAdapter);

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var workingFolder = Directory.GetCurrentDirectory();

            _backgroundTexture = Content.Load <Texture2D>("black");

            var bulletTexture = Content.Load <Texture2D>("laserBlue03");
            var bulletRegion  = new TextureRegion2D(bulletTexture);
            var bulletFactory = new BulletFactory(_entityManager, bulletRegion);

            var spaceshipTexture = Content.Load <Texture2D>("playerShip1_blue");
            var spaceshipRegion  = new TextureRegion2D(spaceshipTexture);

            _player = _entityManager.AddEntity(new Spaceship(spaceshipRegion, bulletFactory));

            var meteorTexture = Content.Load <Texture2D>("meteorBrown_big1");
            var meteorRegion  = new TextureRegion2D(meteorTexture);

            for (var i = 0; i < 5; i++)
            {
                var x        = _random.Next(2) == 0 ? 1 : -1;
                var y        = _random.Next(2) == 0 ? 1 : -1;
                var velocity = new Vector2(x, y) * 10f;
                var meteor   = new Meteor(meteorRegion, velocity)
                {
                    Position = new Vector2(100, 100)
                };

                _entityManager.AddEntity(meteor);
            }
        }
Example #4
0
        //protected override void Initialize()
        //{
        //    base.Initialize();

        //    _graphicsDeviceManager.IsFullScreen = true;
        //    _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
        //    _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
        //    _graphicsDeviceManager.ApplyChanges();
        //}

        protected override void LoadContent()
        {
            _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
            _guiManager = new GuiManager(_viewportAdapter, GraphicsDevice);
            _font = Content.Load<BitmapFont>("Fonts/courier-new-32");

            var normal = new GuiTextureRegionDrawable(new TextureRegion2D(Content.Load<Texture2D>("Gui/button-normal")));
            var pressed = new GuiTextureRegionDrawable(new TextureRegion2D(Content.Load<Texture2D>("Gui/button-clicked")));
            var hover = new GuiTextureRegionDrawable(new TextureRegion2D(Content.Load<Texture2D>("Gui/button-hover")));
            var buttonStyle = new GuiButtonStyle(normal, pressed, hover);
            var button = new GuiButton(buttonStyle)
            {
                Position = new Vector2(400, 240)
            };
            button.Clicked += (sender, args) =>
            {
                if (_player != null)
                {
                    Explode(_player.Position, 3);
                    _player.Destroy();
                    _player = null;
                }
            };
            _guiManager.Controls.Add(button);

            var labelStyle = new GuiLabelStyle(_font);
            var label = new GuiLabel(labelStyle, "Hello")
            {
                Position = new Vector2(100, 100)
            };
            label.MouseUp += (sender, args) => label.Text = args.Position.ToString();
            _guiManager.Controls.Add(label);
            
            _camera = new Camera2D(_viewportAdapter);
            _explosionAnimations = Content.Load<SpriteSheetAnimationGroup>("explosion-animations");

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _backgroundTexture = Content.Load<Texture2D>("black");

            var bulletTexture = Content.Load<Texture2D>("laserBlue03");
            var bulletRegion = new TextureRegion2D(bulletTexture);
            _bulletFactory = new BulletFactory(_entityManager, bulletRegion);

            SpawnPlayer(_bulletFactory);

            _meteorFactory = new MeteorFactory(_entityManager, Content);

            for (var i = 0; i < 13; i++)
                _meteorFactory.SpawnNewMeteor(_player.Position);
        }
Example #5
0
 private void SpawnPlayer(BulletFactory bulletFactory)
 {
     var spaceshipTexture = Content.Load<Texture2D>("playerShip1_blue");
     var spaceshipRegion = new TextureRegion2D(spaceshipTexture);
     _player = _entityManager.AddEntity(new Spaceship(spaceshipRegion, bulletFactory));
 }
Example #6
0
        //protected override void Initialize()
        //{
        //    base.Initialize();

        //    _graphicsDeviceManager.IsFullScreen = true;
        //    _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
        //    _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
        //    _graphicsDeviceManager.ApplyChanges();
        //}

        protected override void LoadContent()
        {
            _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);
            _guiManager = new GuiManager(_viewportAdapter, GraphicsDevice);
            _font = Content.Load<BitmapFont>("Fonts/courier-new-32");

            //var textureRegion = new TextureRegion2D(Content.Load<Texture2D>("Gui/9patch-2"));
            //var dialogPatch = new GuiPatchDrawable(textureRegion, 100, 100, 122, 111, Color.White);
            //var dialogStyle = new GuiButtonStyle(dialogPatch);
            //var dialog = new GuiButton(dialogStyle)
            //{
            //    HorizontalAlignment = GuiHorizontalAlignment.Stretch,
            //    VerticalAlignment = GuiVerticalAlignment.Stretch
            //};
            //_guiManager.Layout.Children.Add(dialog);

            var checkedOn = Content.Load<Texture2D>("Gui/button-clicked").ToGuiDrawable();
            var checkedOff = Content.Load<Texture2D>("Gui/button-normal").ToGuiDrawable();
            var checkBoxStyle = new GuiCheckBoxStyle(checkedOn, checkedOff);
            var checkBox = new GuiCheckBox(checkBoxStyle) {HorizontalAlignment = GuiHorizontalAlignment.Left};
            _guiManager.Layout.Children.Add(checkBox);

            var normal = Content.Load<Texture2D>("Gui/button-normal").ToGuiDrawable();
            var pressed = Content.Load<Texture2D>("Gui/button-clicked").ToGuiDrawable();
            var hover = Content.Load<Texture2D>("Gui/button-hover").ToGuiDrawable();
            var buttonStyle = new GuiButtonStyle(normal, pressed, hover);
            var button = new GuiButton(buttonStyle) {VerticalAlignment = GuiVerticalAlignment.Bottom};
            button.Clicked += (sender, args) =>
            {
                if (_player != null)
                {
                    Explode(_player.Position, 3);
                    _player.Destroy();
                    _player = null;
                }
            };
            _guiManager.Layout.Children.Add(button);

            var labelStyle = new GuiLabelStyle(_font);
            _scoreLabel = new GuiLabel(labelStyle, "Hello")
            {
                HorizontalAlignment = GuiHorizontalAlignment.Right,
                VerticalAlignment = GuiVerticalAlignment.Top
            };
            _guiManager.Layout.Children.Add(_scoreLabel);




            _guiManager.PerformLayout();

            _camera = new Camera2D(_viewportAdapter);
            _explosionAnimations = Content.Load<SpriteSheetAnimationGroup>("explosion-animations");

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _backgroundTexture = Content.Load<Texture2D>("black");

            var bulletTexture = Content.Load<Texture2D>("laserBlue03");
            var bulletRegion = new TextureRegion2D(bulletTexture);
            _bulletFactory = new BulletFactory(_entityManager, bulletRegion);

            SpawnPlayer(_bulletFactory);

            _meteorFactory = new MeteorFactory(_entityManager, Content);

            for (var i = 0; i < 13; i++)
                _meteorFactory.SpawnNewMeteor(_player.Position);
        }