コード例 #1
0
ファイル: Game1.cs プロジェクト: cragmire/MVA
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _drawState = new DrawState(GraphicsDevice);

            _menuScreen = new MenuScreen(Content, _drawState.ScreenBounds);
            _menuScreen.OnStart += OnGameStart;
        }
コード例 #2
0
ファイル: Button.cs プロジェクト: cragmire/MVA
 public void Draw(DrawState state)
 {
     if (_pressTex != null)
         state.SpriteBatch.Draw(_pressTex, _location, _pressed ? Color.DarkGray : Color.White);
     else
         state.SpriteBatch.DrawString(_font, _text, new Vector2(_location.X, _location.Y),  _pressed ? Color.DarkGray : Color.White);
 }
コード例 #3
0
ファイル: MenuScreen.cs プロジェクト: cragmire/MVA
        public void Draw(GameTime gameTime, DrawState state)
        {
            state.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, state.ScreenXform);

            var center = state.ScreenBounds.Center.ToVector2();

            // Draw the background and title.
            state.SpriteBatch.Draw(_backgroundTex, center - _backgroundTex.GetHalfSize(), Color.White);
            state.SpriteBatch.Draw(_titleTex, center - _titleTex.GetHalfSize(), Color.White);

            // Draw the start button blinking.
            if ((gameTime.TotalGameTime.TotalSeconds % 0.9f) > 0.45f)
                _startButton.Draw(state);

            state.SpriteBatch.End();
        }
コード例 #4
0
ファイル: GameScreen.cs プロジェクト: cragmire/MVA
        private void DrawRoom(DrawState state)
        {
            var screen = state.ScreenBounds;
            var center = screen.Center.ToVector2();
            var room = _map.PlayerRoom;

            if (_scrollOutRoom != -1)
            {
                room = _map[_scrollOutRoom];
                var offset = Vector2.Lerp(Vector2.Zero, _scrollOutEnd, Helpers.EaseInOut(_scrollPos));
                center += offset;
            }
            else if (_scrollInRoom != -1)
            {
                room = _map[_scrollInRoom];
                var offset = Vector2.Lerp(_scrollInStart, Vector2.Zero, Helpers.EaseInOut(_scrollPos));
                center += offset;
            }

            state.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, state.ScreenXform);

            // Draw the ground.
            state.SpriteBatch.Draw(_groundTex, center - _groundTex.GetHalfSize(), Color.White);

            var roomHalfWidth = _wallNorthSolid.Width / 2.0f;
            var wallDepth = _wallNorthSolid.Height;
            var roomHalfHeight = _wallEastSolid.Height / 2.0f;

            // Do we draw the alien goop?
            if (_goopPos.HasValue)
                state.SpriteBatch.Draw(_goopTex, center + new Vector2(_goopPos.Value.X, _goopPos.Value.Y), null, null, _goopTex.GetHalfSize(), _goopPos.Value.Z);

            // Do we draw the alien.
            if (_map.AlienRoom == room.Index)
                state.SpriteBatch.Draw(_alienTex, center - _alienTex.GetHalfSize(), Color.White);

            if (room.HasTrap)
            {
                var frameN = MathHelper.Clamp((int)Math.Floor((_roomTimer.TotalSeconds / 1.2f) * 8), 0, 7);
                var frameWidth = _trapTex.Width / 8;
                var frame = new Rectangle(frameN * frameWidth, 0, frameWidth, _trapTex.Height);
                state.SpriteBatch.Draw(_trapTex, center - new Vector2(frameWidth / 2.0f, _trapTex.Height / 2.0f), frame, Color.White);
            }

            if (_map.WeaponRoom == room.Index)
                state.SpriteBatch.Draw(_flamethrowerTex, center - _flamethrowerTex.GetHalfSize(), Color.White);

            if (_attackTimer > TimeSpan.FromSeconds(1.25f))
            {
                var frameN = (int)Math.Floor((_attackTimer.TotalSeconds * 6.0f) % 4.0f);
                var frame = new Rectangle(0, frameN * (_flamesTex.Height / 4), _flamesTex.Width, _flamesTex.Height / 4);
                var offset = new Vector2(frame.Right, frame.Height / 2.0f);
                state.SpriteBatch.Draw(_flamesTex, state.ScreenBounds.Center.ToVector2(),
                    frame, Color.White, _attackRot, offset, 1, SpriteEffects.None, 0.0f);
            }

            // Draw the room walls.
            state.SpriteBatch.Draw(room.NorthRoom != -1 ? _wallNorthOpen : _wallNorthSolid, new Vector2(center.X - roomHalfWidth, center.Y - roomHalfHeight));
            state.SpriteBatch.Draw(room.EastRoom != -1 ? _wallEastOpen : _wallEastSolid, new Vector2(center.X + roomHalfWidth - wallDepth, center.Y - roomHalfHeight));
            state.SpriteBatch.Draw(room.WestRoom != -1 ? _wallWestOpen : _wallWestSolid, new Vector2(center.X - roomHalfWidth, center.Y - roomHalfHeight));
            state.SpriteBatch.Draw(room.SouthRoom != -1 ? _wallSouthOpen : _wallSouthSolid, new Vector2(center.X - roomHalfWidth, center.Y + roomHalfHeight - wallDepth));
            state.SpriteBatch.End();
        }
コード例 #5
0
ファイル: GameScreen.cs プロジェクト: cragmire/MVA
        private void DrawHud(GameTime gameTime, DrawState state)
        {
            state.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, state.ScreenXform);

            var room = _map.PlayerRoom;

            if (ShowHud())
            {
                if (room.NorthRoom != -1)
                    (_attackMode ? _attackButtonNorth : _buttonNorth).Draw(state);
                if (room.EastRoom != -1)
                    (_attackMode ? _attackButtonEast : _buttonEast).Draw(state);
                if (room.SouthRoom != -1)
                    (_attackMode ? _attackButtonSouth : _buttonSouth).Draw(state);
                if (room.WestRoom != -1)
                    (_attackMode ? _attackButtonWest : _buttonWest).Draw(state);

                if (_player.HasWeapon)
                    _flameThrowerButton.Draw(state);

                if (_map.IsTrapNear(room.Index))
                {
                    if (_roomTimer.TotalSeconds % 2.0f < 1.0f)
                        state.SpriteBatch.Draw(_trapWarnTex, new Vector2(state.ScreenBounds.Left, state.ScreenBounds.Bottom - _trapWarnTex.Height), Color.White);
                }
            }

            // Draw the health.
            if (_player.Health > 0)
                state.SpriteBatch.Draw(_healthTex, new Vector2(20, 10), Color.White);
            if (_player.Health > 1)
                state.SpriteBatch.Draw(_healthTex, new Vector2(20 + _healthTex.Width, 10), Color.White);
            if (_player.Health > 2)
                state.SpriteBatch.Draw(_healthTex, new Vector2(20 + (_healthTex.Width * 2), 10), Color.White);

            // Draw the room identifier.
            var roomDesc = string.Format("ROOM: {0}", room.Index + 1);
            state.SpriteBatch.DrawString(_hudFont, roomDesc, new Vector2(20, 74), Color.White);

            state.SpriteBatch.End();
        }
コード例 #6
0
ファイル: GameScreen.cs プロジェクト: cragmire/MVA
 private void DrawGameWin(DrawState state)
 {
     state.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, state.ScreenXform);
     state.SpriteBatch.Draw(_gameWinTex, state.ScreenBounds.Center.ToVector2() - _gameWinTex.GetHalfSize(), Color.Red);
     state.SpriteBatch.End();
 }
コード例 #7
0
ファイル: GameScreen.cs プロジェクト: cragmire/MVA
        public void Draw(GameTime gameTime, DrawState state)
        {
            DrawRoom(state);

            if (_player.IsDead && _roomTimer > TimeSpan.FromSeconds(2.0f))
                DrawGameOver(state);
            if (_map.AlienRoom == -1)
                DrawGameWin(state);
            else
                DrawHud(gameTime, state);
        }