示例#1
0
        public override void OnUpdate(GameTime gameTime)
        {
            if (AnimationComplete)
            {
                return;
            }

            if (fadeIn)
            {
                currentAlpha += FadeVelocity;
                if (currentAlpha >= 255)
                {
                    currentAlpha = 255;
                    AnimationComplete = true;
                }
            }
            else
            {
                currentAlpha -= FadeVelocity;
                if (currentAlpha <= 0)
                {
                    currentAlpha = 0;
                    AnimationComplete = true;
                }
            }
        }
示例#2
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     p1Bounds = new Rectangle(new Vector2(0, 0), spriteBatch.MeasureString(scoreBoardPlayer1, Font));
     p2Bounds = new Rectangle(new Vector2(GraphicsDevice.BackBuffer.Width - spriteBatch.MeasureString(scoreBoardPlayer2, Font).X, 0), spriteBatch.MeasureString(scoreBoardPlayer2, Font));
     spriteBatch.DrawString(scoreBoardPlayer1, Font, p1Bounds, Color);
     spriteBatch.DrawString(scoreBoardPlayer2, Font, p2Bounds, Color);
 }
示例#3
0
        /// <summary>
        /// Zeichnen der Elemente
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="gameTime"></param>
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            switch (SceneMode)
            {
                case SceneMode.FirstStart:
                    text = "Bereit?";
                    gameScene.Draw(spriteBatch, gameTime);
                    break;

                case SceneMode.Paused:
                    text = "Pausiert";
                    break;

                case SceneMode.WonLost:
                    break;

                case SceneMode.Scored:
                    text = "Bereit?";
                    gameScene.Draw(spriteBatch, gameTime);
                    break;

                default:
                    break;
            }
            font = new Font("Arial", 50, TypefaceStyle.Bold);
            position = new Vector2()
            {
                X = (graphicsDevice.BackBuffer.Width - spriteBatch.MeasureString(text, font).X) / 2,
                Y = 100
            };
            color = Color.White;
            spriteBatch.DrawString(text, font, position, color);
        }
示例#4
0
 /// <summary>
 /// Zeichnen der Elemente
 /// </summary>
 /// <param name="spriteBatch"></param>
 /// <param name="gameTime"></param>
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {            
     scoreBoard.Draw(spriteBatch, gameTime);
     ball.Draw(spriteBatch, gameTime);
     sL.Draw(spriteBatch, gameTime);
     sR.Draw(spriteBatch, gameTime);
 }
示例#5
0
        public void Update(GameTime gameTime)
        {
            if (!IsEnabled)
            {
                return;
            }

            if (fadeIn)
            {
                currentAlpha += FadeVelocity;
                if (currentAlpha >= 255)
                {
                    currentAlpha = 255;
                    AnimationComplete = true;
                }
            }
            else
            {
                currentAlpha -= FadeVelocity;
                if (currentAlpha <= 0)
                {
                    currentAlpha = 0;
                    AnimationComplete = true;
                }
            }
        }
示例#6
0
        public void Update(GameTime gameTime)
        {
            if (AnimationComplete)
            {
                return;
            }

            if (!flag)
            {
                currentAlpha += FadeInVelocity;
                if (currentAlpha >= 255)
                {
                    currentAlpha = 255;
                    flag = true;
                }
            }
            else
            {
                currentAlpha -= FadeOutVelocity;
                if (currentAlpha <= 0)
                {
                    currentAlpha = 0;
                    AnimationComplete = true;
                }
            }
        }
示例#7
0
        /// <summary>
        /// Updaten der GameLogik
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            int offSetX = speed * directionX;
            int offsetY = speed * directionY;

            MoveOnX(offSetX);
            MoveOnY(offsetY);
        }
示例#8
0
        public override void Render(RenderDevice renderer, GameTime gameTime)
        {
            renderer.GraphicsDevice.ClearColor = Color.Black;
            
            tiles.ForEach(x => x.Render(renderer, gameTime));

            //renderer.DrawTexture(grassTexture2D, new Vector2(20, 20), Color.White);
        }
示例#9
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     if (AnimationComplete)
     {
         return;
     }
     spriteBatch.DrawString(Text, Font, Position, Color.FromArgb((int)currentAlpha, 255, 255, 255));
 }
示例#10
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     if (!IsEnabled)
     {
         return;
     }
     spriteBatch.FillRectangle(Color.FromArgb((int)currentAlpha, 0, 0, 0), display);
 }
示例#11
0
 /// <summary>
 /// Initializes a new GameLoop class.
 /// </summary>
 public GameLoop()
 {
     TargetTime = 16.666f;
     _loopThread = new Thread(Loop) {Priority = ThreadPriority.Highest};
     _gameTimer = new Stopwatch();
     _drawables = new List<IDrawable>();
     _updateables = new List<IUpdateable>();
     _gameTime = new GameTime();
     Precision = Precision.High;
     DrawMode = DrawMode.Limited;
     _logger = LogManager.GetClassLogger();
 }
示例#12
0
        /// <summary>
        /// Updates the Player.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            if (!_isVisible) return;

            Sprite.Update(gameTime);
            RemainingLifeTime -= gameTime.ElapsedGameTime;
            if (RemainingLifeTime < 0)
            {
                RemainingLifeTime = 0;
                _isVisible = false;
            }
        }
示例#13
0
 /// <summary>
 /// Draws the scene.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch.</param>
 /// <param name="gameTime">The GameTime.</param>
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     _skyBox.Draw(spriteBatch, gameTime);
     _entityComposer.Draw(spriteBatch, gameTime);
     if (!_debugDisplay.Visible)
     {
         _scoreBoard.Draw(spriteBatch, gameTime);
     }
     _minimap.Draw(spriteBatch, gameTime);
     _debugDisplay.Draw(spriteBatch, gameTime);
     _blackBlend.Draw(spriteBatch, gameTime);
     UIManager.Draw(spriteBatch, gameTime);
 }
示例#14
0
        /// <summary>
        /// Draws the Skybox.
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch.</param>
        /// <param name="gameTime">The GameTime.</param>
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.DrawTexture(_background, _backgroundPosition);

            spriteBatch.DrawTexture(_layer1, _layer1Position1);
            spriteBatch.DrawTexture(_layer2, _layer2Position1);

            spriteBatch.DrawTexture(_layer1, _layer1Position2);
            spriteBatch.DrawTexture(_layer2, _layer2Position2);

            //spriteBatch.DrawTexture(_layer1, _layer1Position3);
            spriteBatch.DrawTexture(_layer2, _layer2Position3);
        }
示例#15
0
        /// <summary>
        /// Updaten der Gamelogik
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            var state = inputManager.Keyboard.GetState();

            if (state.IsKeyDown(Keys.Space))
            {
                sceneManager.ActiveScene = sceneManager.Get<GameScene>();
            }
            if (state.IsKeyDown(Keys.Back))
            {
                sceneManager.ActiveScene = sceneManager.Get<MenuScene>();
            }
        }
示例#16
0
        /// <summary>
        /// Updaten der GameLogik
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            var state = inputManager.Keyboard.GetState();

            if (state.IsKeyDown(KeyMoveUp) && state.IsKeyUp(KeyMoveDown))
            {
                MoveOnY(-5);
            }
            if (state.IsKeyDown(KeyMoveDown) && state.IsKeyUp(KeyMoveUp))
            {
                MoveOnY(+5);
            }
        }
示例#17
0
        /// <summary>
        /// Updates the scene.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            _blackBlend.Update(gameTime);
            UIManager.Update(gameTime);

            if (_menuButton1.IsMouseDown(MouseButtons.Left))
            {
                SGL.QueryComponents<SceneManager>().ActiveScene = SGL.QueryComponents<SceneManager>().Get<GameScene>();
            }

            if (_menuButton3.IsMouseDown(MouseButtons.Left))
            {
                Application.Exit();
            }
        }
示例#18
0
        /// <summary>
        /// Updaten der Gamelogik
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            button1.Update(gameTime);
            button2.Update(gameTime);

            if (button1.IsMouseDown(Sharpex2D.Input.MouseButtons.Left))
            {
                SceneManager.Get<PauseScene>().SceneMode = SceneMode.FirstStart;
                SceneManager.ActiveScene = SceneManager.Get<PauseScene>();
            }
            if (button2.IsMouseDown(Sharpex2D.Input.MouseButtons.Left))
            {
                System.Windows.Forms.Application.Exit();
            }
        }
示例#19
0
        /// <summary>
        ///     Updates the object.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public void Update(GameTime gameTime)
        {
            _position1 = new Vector2(_position1.X - 0.5f, _position1.Y);
            _position2 = new Vector2(_position2.X - 0.5f, _position2.Y);

            if (_position1.X <= -640)
            {
                _position1.X = 638;
            }

            if (_position2.X <= -640)
            {
                _position2.X = 638;
            }
        }
示例#20
0
 /// <summary>
 /// Zeichnen der Elemente
 /// </summary>
 /// <param name="spriteBatch"></param>
 /// <param name="gameTime"></param>
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     text1.Draw(spriteBatch, gameTime);
     if (text1.AnimationComplete)
     {
         text2.Draw(spriteBatch, gameTime);
         if (text2.AnimationComplete)
         {
             text3.Draw(spriteBatch, gameTime);
             if (text3.AnimationComplete)
             {
                 
             }
         }
     }
 }
示例#21
0
 /// <summary>
 /// Updaten der Gamelogik
 /// </summary>
 /// <param name="gameTime"></param>
 public override void Update(GameTime gameTime)
 {
     text1.Update(gameTime);
     if (text1.AnimationComplete)
     {
         text2.Update(gameTime);
         if (text2.AnimationComplete)
         {
             text3.Update(gameTime);
             if (text3.AnimationComplete)
             {
                 SceneManager.ActiveScene = SceneManager.Get<Scenes.MenuScene>();
             }
         }
     }
    
 }
示例#22
0
 /// <summary>
 /// Draws the Scene.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch.</param>
 /// <param name="gameTime">The GameTime.</param>
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     spriteBatch.DrawTexture(_background, _backgroundPosition);
     Vector2 dim =
         spriteBatch.MeasureString(
             string.Format("score: {0}", _finalScore), _font);
     Vector2 dim2 = spriteBatch.MeasureString("Press {Enter} to continue", _font2);
     Vector2 dim3 = spriteBatch.MeasureString(
         string.Format("(Achievement multiplier {0}x)", _achievmentMultiplier), _font3);
     spriteBatch.DrawString(
         string.Format("score: {0}", _finalScore), _font,
         new Vector2(400 - dim.X/2, 300), Color.White);
     spriteBatch.DrawString(string.Format("(Achievement multiplier {0}x)", _achievmentMultiplier), _font3,
         new Vector2(400 - dim3.X/2, 350), Color.White);
     spriteBatch.DrawString("Press {Enter} to continue", _font2, new Vector2(400 - dim2.X/2, 420), Color.White);
     _blackBlend.Draw(spriteBatch, gameTime);
 }
示例#23
0
 /// <summary>
 /// Draws the Scene.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch.</param>
 /// <param name="gameTime">The GameTime.</param>
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     _skyBox.Draw(spriteBatch, gameTime);
     _fadeableText1.Draw(spriteBatch, gameTime);
     if (_fadeableText1.AnimationComplete)
     {
         _fadeableText2.Draw(spriteBatch, gameTime);
         if (_fadeableText2.AnimationComplete)
         {
             _fadeableText3.Draw(spriteBatch, gameTime);
             if (_fadeableText3.AnimationComplete)
             {
                 _blackBlend.Draw(spriteBatch, gameTime);
             }
         }
     }
 }
示例#24
0
        /// <summary>
        /// Draws the Minimap.
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch.</param>
        /// <param name="gameTime">The GameTime.</param>
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!Visible) return;

            spriteBatch.DrawTexture(_minimap, new Vector2(X, Y), 0.4f);

            foreach (Vector2 enemy in _enemyPositions)
            {
                spriteBatch.FillRectangle(Color.Red, new Rectangle(enemy.X, enemy.Y, 5, 5));
            }

            foreach (Vector2 projectile in _projectilePositions)
            {
                spriteBatch.FillRectangle(Color.Blue, new Rectangle(projectile.X, projectile.Y, 2, 2));
            }

            spriteBatch.FillRectangle(Color.Green, new Rectangle(_playerPosition.X, _playerPosition.Y, 5, 5));
        }
示例#25
0
        /// <summary>
        /// Draws the DebugDisplay.
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch.</param>
        /// <param name="gameTime">The GameTime.</param>
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!Visible) return;

            foreach (Enemy enemy in _currentEntityComposer.Enemies)
            {
                spriteBatch.DrawRectangle(_pen, enemy.Bounds);
            }

            foreach (Projectile projectile in _currentEntityComposer.Projectiles)
            {
                spriteBatch.DrawRectangle(_pen2, projectile.Bounds);
            }

            spriteBatch.DrawRectangle(_pen3, _currentEntityComposer.Player.Bounds);

            spriteBatch.DrawString(_debugMessage, _font, _display, Color.White);
        }
示例#26
0
        /// <summary>
        /// Updaten der Gamelogik
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            var kbState = inputManager.Keyboard.GetState();

            if (kbState.IsKeyDown(Keys.Escape))
            {
                sceneManager.Get<PauseScene>().SceneMode = SceneMode.Paused;
                sceneManager.ActiveScene = sceneManager.Get<PauseScene>();
            }
            if (kbState.IsKeyDown(Keys.Back))
            {
                sceneManager.ActiveScene = sceneManager.Get<MenuScene>();
            }
            ball.Update(gameTime);
            sL.Update(gameTime);
            sR.Update(gameTime);
            scoreBoard.Update(gameTime);

            CheckOnCollision();          
        }
示例#27
0
        /// <summary>
        /// Updates the Player.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            if (!_isVisible) return;

            Sprite.Update(gameTime);
            Bounds = new Rectangle(Position, new Vector2(47, 61));
            _healthBarRed = new Rectangle(Position.X, Position.Y - 10, 38, 2);
            _healthBarGreen = new Rectangle(Position.X, Position.Y - 10, 38f*Health/MaximumHealth, 2);
        }
示例#28
0
        /// <summary>
        /// Draws the Player.
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch.</param>
        /// <param name="gameTime">The GameTime.</param>
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!_isVisible) return;

            spriteBatch.DrawTexture(Sprite, Position);

            //healthbar
            if (!EnableHPBar) return;

            spriteBatch.FillRectangle(Color.Red, _healthBarRed);
            spriteBatch.FillRectangle(Color.Green, _healthBarGreen);
        }
示例#29
0
 /// <summary>
 /// Zeichnen der Elemente
 /// </summary>
 /// <param name="spriteBatch"></param>
 /// <param name="gameTime"></param>
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     spriteBatch.DrawTexture(Texture, Position);
 }
示例#30
0
        /// <summary>
        /// Updates the BlackBlend.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public void Update(GameTime gameTime)
        {
            if (!IsEnabled) return;

            if (FadeIn)
            {
                if (_alpha < 253)
                {
                    _alpha += 2;
                }
                else
                {
                    IsCompleted = true;
                }
            }
            else
            {
                if (_alpha > 2)
                {
                    _alpha -= 2;
                }
                else
                {
                    IsCompleted = true;
                }
            }
        }