public static void Render(RenderEngine renderEngine, int cameraOffset)
 {
     foreach (Particle particle in ParticleList)
     {
         renderEngine.Render(particle, cameraOffset);
     }
 }
예제 #2
0
 public override void Draw(RenderEngine renderEngine)
 {
     renderEngine.Draw(btnTexture, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height, _mouseIsOver ? ButtonColor * 1.5f : ButtonColor);
     if (!string.IsNullOrWhiteSpace(Text))
     {
         renderEngine.DrawString(Text, Bounds.Center.X, Bounds.Center.Y, TextColor, true);
     }
 }
        /** Draw the current GameState and all components */
        public void DrawAll(RenderEngine renderEngine)
        {
            //Draw the GameState itself
            Draw(renderEngine);

            //Draw components last
            foreach (GUIComponent guiComponent in components) guiComponent.Draw(renderEngine);
        }
 protected override void Update(GameTime delta, KeyboardState keyboard, MouseState mouse, RenderEngine renderEngine)
 {
     if (keyboard.GetPressedKeys().Length != 0)
     {
         if (keyboard.IsKeyDown(Keys.Escape)) NextGameState = null;
         else Fade();
     }
     if (opacity.A != 255) Fade();
 }
        /// <summary>
        /// Updates all components in this GameState and figures out what should be the next GameState
        /// </summary>
        /// <returns>Returns what should be the current GameState. If null is returned then it will go back to the previous state</returns>
        public virtual GameState UpdateAll(GameTime delta, KeyboardState keyboard, MouseState mouse, RenderEngine renderEngine)
        {
            //Update GUI components
            foreach (GUIComponent guiComponent in components)
            {
                guiComponent.Update(keyboard, mouse, delta);
            }

            Update(delta, keyboard, mouse, renderEngine);

            return NextGameState;
        }
 protected override void Draw(RenderEngine renderEngine)
 {
     //Draw player Tank
     if (_unitType != null)
         renderEngine.Draw(_unitType.Texture, 450, 250, _unitType.Texture.Width, _unitType.Texture.Height);
 }
        public override GameState UpdateAll(GameTime delta, KeyboardState keyboard, MouseState mouse, RenderEngine renderEngine)
        {
            if (_getInputKey == null)
            {
                return base.UpdateAll(delta, keyboard, mouse, renderEngine);
            }

            foreach (var key in keyboard.GetPressedKeys())
            {
                _playerInput[key] = _getControlKey;
                _getInputKey.setText(key.ToString());
                _getInputKey = null;
                break;
            }

            return this;
        }
 public override void Draw(RenderEngine renderEngine)
 {
     renderEngine.DrawFilledRectangle(Bounds, Color.Coral);
     renderEngine.DrawString(Text + (isTyping ? token : ' '), Bounds.X, Bounds.Y, Color.White);
 }
예제 #9
0
 public override void Draw(RenderEngine renderEngine)
 {
     renderEngine.DrawString(Text, Bounds.X, Bounds.Y, Color.White);
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _renderEngine = new RenderEngine(_spriteBatch);

            ResourceManager.LoadDebugFont(Content);
            Components.Add(new FPSCounter(this, _spriteBatch));
        }
 protected override void Draw(RenderEngine renderEngine)
 {
 }
 protected override void Draw(RenderEngine renderEngine)
 {
     renderEngine.Draw(ResourceManager.GetTexture("splash.jpg"), 0, 0, renderEngine.GetScreenWidth(), renderEngine.GetScreenHeight());
 }
예제 #13
0
 protected virtual void Update(GameTime delta, KeyboardState keyboard, MouseState mouse, RenderEngine renderEngine)
 {
     //Default no implementation
 }
예제 #14
0
 /** Draw the current GameState */
 protected abstract void Draw(RenderEngine renderEngine);
        protected override void Update(GameTime delta, KeyboardState keyboard, MouseState mouse, RenderEngine renderEngine)
        {
            //TODO: this should open a small ingame menu?
            if (keyboard.IsKeyDown(Keys.Escape))
            {
                NextGameState = null; //Go back to main menu
                return;
            }

            //15 seconds until first wave spawns
            if ((int)_enemySpawnRate == 0)
            {
                _enemySpawnRate = delta.TotalGameTime.TotalSeconds + 15;
            }

            //Update highscore
            _player1Score.Text = "SCORE: " + _playerList[0].Score;
            if(_playerList.Count > 1) _player2Score.Text = "SCORE: " + _playerList[1].Score;

            //Update Camera shake
            if (Camera.shake > 0) Camera.shake -= delta.ElapsedGameTime.Milliseconds;

            //Update particle effects
            ParticleEngine.Update(delta, _entities, _tileMap);

            //Update all entities (TODO: this could be done in parallel?)
            Queue<Entity> destroyedEntities = new Queue<Entity>();
            foreach (Entity entity in _entities)
            {
                //Update the entity itself (run AI, check input, etc.)
                entity.Update(delta, keyboard, mouse);

                //Collision with map edges
                if (entity.Position.X < 0)                                          entity.X = 0;
                if (entity.Position.Y < 0)                                          entity.Y = 0;
                if (entity.Position.X + entity.Width / 2.0f > _tileMap.RealWidth)   entity.X = _tileMap.RealWidth - entity.Width / 2.0f;
                if (entity.Position.Y + entity.Height / 2.0f > _tileMap.RealHeight) entity.Y = _tileMap.RealHeight - entity.Height / 2.0f;

                //Collision with world
                if(entity.IsCollidable) _tileMap.WorldCollision(entity);

                if (entity.IsDestroyed)
                {
                    destroyedEntities.Enqueue(entity);
                }
            }

            foreach (var destroyedEntity in destroyedEntities) {
                _entities.Remove(destroyedEntity);
            }

            //Entity to entity collision detection
            for (int i = 0; i < _entities.Count; ++i)
            {
                if (!_entities[i].IsCollidable) continue;

                for (int j = i + 1; j < _entities.Count; ++j){
                    if (!_entities[j].IsCollidable) continue;
                    _entities[i].HandleCollision(_entities[j]);
                }
            }

            //Spawn new waves of enemies!
            if(!_versusMode) SpawnEnemies(delta);
        }
        protected override void Draw(RenderEngine renderEngine)
        {
            int cameraOffset = 0;

            //Splitscreen camera?
            if (_playerList.Count == 2 && (_playerList[0].Position - _playerList[1].Position).LengthSquared() >= 800*480 / 2)
            {
                foreach (Player player in _playerList)
                {
                    Camera.ViewPortWidth = 800 / _playerList.Count;
                    Camera.ViewPortHeight = 480;

                    Camera.Position = player.Position - new Vector2(Camera.ViewPortWidth, Camera.ViewPortHeight) / 2;

                    //Draw the level
                    renderEngine.Render(_tileMap, cameraOffset);

                    //Draw each entity visible on the screen
                    foreach (Entity entity in _entities.Where(entity => Camera.ObjectIsVisible(entity.Bounds)))
                    {
                        renderEngine.Render(entity, cameraOffset);
                    }

                    //Draw particle effects
                    ParticleEngine.Render(renderEngine, cameraOffset);

                    cameraOffset += Camera.ViewPortWidth + 32;
                }

                //Draw splitscreen bar
                if (_playerList.Count > 1)
                {
                    renderEngine.Draw(ResourceManager.GetTexture("split.png"), Camera.ViewPortWidth - 32, 0, 64, Camera.ViewPortHeight, Color.White);
                }
            }

            //Normal Camera
            else
            {
                Camera.ViewPortWidth = 800;
                Camera.ViewPortHeight = 480;

                if (_playerList.Count == 1)
                    Camera.Position = _playerList[0].Position - new Vector2(Camera.ViewPortWidth, Camera.ViewPortHeight) / 2;
                else
                {
                    Camera.Position = (_playerList[0].Position + _playerList[1].Position)/2 - new Vector2(Camera.ViewPortWidth, Camera.ViewPortHeight) / 2;
                }

                //Draw the level
                renderEngine.Render(_tileMap, cameraOffset);

                //Draw each entity visible on the screen
                foreach (Entity entity in _entities.Where(entity => Camera.ObjectIsVisible(entity.Bounds)))
                {
                    renderEngine.Render(entity, cameraOffset);
                }

                //Draw particle effects
                ParticleEngine.Render(renderEngine, cameraOffset);
            }
        }
 public abstract void Draw(RenderEngine renderEngine);