Пример #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
            if (this.stages == GameStages.Game_Stage && this.testLevel.Character.CurrentHealth <= 0)
            {
                stages = GameStages.Death_Stage;
            }
            //if(stages == GameStages.Start_Stage)
            //{
            //    this.staRtScreen.Update(gameTime);
            //}

            if (stages == GameStages.Game_Stage)
            {
                timeSinceLastUpdate += gameTime.ElapsedGameTime.Milliseconds;
                if (timeSinceLastUpdate >= oneSec)
                {
                    timeSinceLastUpdate = 0;
                    this.testLevel.Character.CooldownTimer += 1;
                }
                this.testPlayer.Move();
                GfxHandler.GetSprite(this.testPlayer).Update(gameTime, this.testPlayer);

                foreach (Character enemy in this.testLevel.Enemies.ToList())
                {
                    enemy.Move();
                    GfxHandler.GetSprite(enemy).Update(gameTime, enemy);
                }

                foreach (Projectile projectile in this.testLevel.Projectiles.ToList())
                {
                    projectile.Move();
                    GfxHandler.GetSprite(projectile).Update(gameTime);
                }
            }
            else
            {
            }

            base.Update(gameTime);
        }
Пример #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            this.GraphicsDevice.Clear(Color.Black);

            // Vector2 origin = new Vector2(GfxHandler.GetWidth(this.testPlayer) / 2, GfxHandler.GetHeight(this.testPlayer) / 2);
            // TODO: Add your drawing code here
            if (stages == GameStages.Game_Stage)
            {
                this.spriteBatch.Begin();


                this.testLevel.Assets.ForEach(t => this.spriteBatch.Draw(GfxHandler.GetTexture(t), t.Position));



                this.spriteBatch.End();
                this.statScreen.DrawHealth(this.testLevel.Character, this.Content, this.spriteBatch);
                GfxHandler.GetSprite(this.sampleEnemy).Draw(this.spriteBatch, this.sampleEnemy.Position);
                GfxHandler.GetSprite(this.testPlayer).Draw(this.spriteBatch, this.testPlayer.Position, this.testPlayer.FacingAngle, this.testPlayer.MovementAngle);

                foreach (var projectile in this.testLevel.Projectiles.ToList())
                {
                    GfxHandler.GetSprite(projectile).Draw(this.spriteBatch, projectile.Position, projectile.Angle);

                    if (projectile.Lifetime > projectile.Range)
                    {
                        this.testLevel.Projectiles.Remove(projectile);
                    }
                }
            }
            else if (this.stages == GameStages.Death_Stage)
            {
                this.statScreen.EndScreen(this.Content, this.spriteBatch);
            }
            else
            {
                this.staRtScreen.DrawStartScreen(this.spriteBatch, this.Content);
            }


            base.Draw(gameTime);
        }