Esempio n. 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/courier-new-32");

            _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);
            }
        }
Esempio n. 2
0
        public Zombie(SpriteSheetAnimationGroup animationGroup)
        {
            _animator = new SpriteSheetAnimator(animationGroup);
            _sprite = _animator.Sprite;

            State = ZombieState.Appearing;
            IsOnGround = false;
        }
Esempio n. 3
0
 public Explosion(SpriteSheetAnimationGroup animations, Vector2 position, float radius)
 {
     _animator = new SpriteSheetAnimator(animations)
     {
         Sprite = { Position = position, Scale = Vector2.One * radius * 0.2f },
         IsLooping = false
     };
     _animator.PlayAnimation("explode", Destroy);
 }
        public SpriteSheetAnimator(SpriteSheetAnimationGroup animationGroup, Sprite sprite)
        {
            _animationGroup = animationGroup;
            _frameIndex = 0;

            Sprite = sprite;
            IsPlaying = true;
            IsLooping = true;

            if (Sprite != null && _animationGroup.Frames.Any())
                Sprite.TextureRegion = _animationGroup.Frames.First();
        }
        public SpriteSheetAnimator(SpriteSheetAnimationGroup animationGroup, Sprite sprite)
        {
            _animationGroup = animationGroup;
            //_frames = new List<TextureRegion2D>(regions);
            //_animations = new Dictionary<string, SpriteSheetAnimation>();
            _frameIndex = 0;

            Sprite = sprite;
            IsPlaying = true;
            IsLooping = true;

            if (Sprite != null && _animationGroup.Frames.Any())
                Sprite.TextureRegion = _animationGroup.Frames.First();
        }
        public SpriteSheetAnimator(SpriteSheetAnimationGroup animationGroup, Sprite sprite)
        {
            _animationGroup = animationGroup;
            _frameIndex     = 0;

            Sprite    = sprite;
            IsPlaying = true;
            IsLooping = true;

            if (Sprite != null && _animationGroup.Frames.Any())
            {
                Sprite.TextureRegion = _animationGroup.Frames.First();
            }
        }
        public SpriteSheetAnimator(SpriteSheetAnimationGroup animationGroup, Sprite sprite)
        {
            _animationGroup = animationGroup;
            //_frames = new List<TextureRegion2D>(regions);
            //_animations = new Dictionary<string, SpriteSheetAnimation>();
            _frameIndex = 0;

            Sprite    = sprite;
            IsPlaying = true;
            IsLooping = true;

            if (Sprite != null && _animationGroup.Frames.Any())
            {
                Sprite.TextureRegion = _animationGroup.Frames.First();
            }
        }
 public static SpriteSheetAnimator CreateAnimator(this Sprite sprite, SpriteSheetAnimationGroup animationGroup)
 {
     return new SpriteSheetAnimator(animationGroup, sprite);
 }
Esempio n. 9
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);
        }
        //public SpriteSheetAnimator(Sprite sprite, TextureAtlas textureAtlas)
        //    : this(sprite, textureAtlas.Select(t => t))
        //{
        //}

        //public SpriteSheetAnimator(TextureAtlas textureAtlas)
        //    : this(null, textureAtlas)
        //{
        //}

        //public SpriteSheetAnimator(IEnumerable<TextureRegion2D> regions)
        //    : this(null, regions)
        //{
        //}

        public SpriteSheetAnimator(SpriteSheetAnimationGroup animationGroup)
            : this(animationGroup, new Sprite(animationGroup.Frames.First()))
        {
        }
        //public SpriteSheetAnimator(Sprite sprite, TextureAtlas textureAtlas)
        //    : this(sprite, textureAtlas.Select(t => t))
        //{
        //}

        //public SpriteSheetAnimator(TextureAtlas textureAtlas)
        //    : this(null, textureAtlas)
        //{
        //}

        //public SpriteSheetAnimator(IEnumerable<TextureRegion2D> regions)
        //    : this(null, regions)
        //{
        //}

        public SpriteSheetAnimator(SpriteSheetAnimationGroup animationGroup)
            : this(animationGroup, new Sprite(animationGroup.Frames.First()))
        {
        }
Esempio n. 12
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);
        }