Пример #1
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)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();

            switch (GameElements.currentState)
            {
                case GameElements._state.Run:
                    //Draws the level design
                    anka.Draw(spriteBatch, camera, GraphicsDevice, gameTime, 0);
                    levelLayout.Draw(spriteBatch, camera, GraphicsDevice, gameTime, 0);
                    testStudent.Draw(spriteBatch, camera, GraphicsDevice, gameTime, 0);


                    #region jonatans Debug Stuff, safe to remove
                    if (debug)
                    {
                        // Drawing the colission angle for debug pusposes, may be used for other things later
                        spriteBatch.DrawString(font, "Collision angle: " + anka.tempPlayerAngle, new Vector2(50, 50), Color.White);
                        spriteBatch.DrawString(font, "HP " + anka.Health, new Vector2(50, 70), Color.White);

                        // Drawing ANKA hitbox
                        spriteBatch.Draw(tmpTexture, anka.Hitbox, Color.Blue);
                        spriteBatch.DrawString(font, "Anka hitbox", new Vector2(anka.Hitbox.X, anka.Hitbox.Y - 20), Color.Black);


                        //Drawing student hitbox
                        spriteBatch.Draw(tmpTexture, testStudent.Hitbox, Color.Blue);
                        spriteBatch.DrawString(font, "student hitbox", new Vector2(testStudent.Hitbox.X, testStudent.Hitbox.Y - 20), Color.Black);

                        //Drawing bullet hitbox
                        foreach (Projectile proj in testStudent.projectiles)
                        {
                            spriteBatch.Draw(tmpTexture, proj.Hitbox, Color.Purple);
                            spriteBatch.DrawString(font, "Bullet", new Vector2(proj.Hitbox.X, proj.Hitbox.Y), Color.Black);
                        }
                        // Scroll of nope hitbox
                        spriteBatch.Draw(tmpTexture, levelLayout.theScroll.Hitbox, Color.Blue);
                        spriteBatch.DrawString(font, "The scroll of NOPE", new Vector2(levelLayout.theScroll.Hitbox.X, levelLayout.theScroll.Hitbox.Y - 10), Color.Black);

                    }

                    #endregion

                    #region jonatans winconditions
                    //Check if ANKA is dead and if so the player won
                    if (anka.Health <= 0)
                    {
                        

                        Random rng = new Random();
                        float r = rng.Next(0, 100) / 100f;
                        float g = rng.Next(0, 100) / 100f;
                        float b = rng.Next(0, 100) / 100f;
                       


                        Color randomColor = new Color(r, g, b, 1);


                        spriteBatch.DrawString(winFont, "Congratulations you get to end the lession earlier!1!1111!!1", new Vector2(0, 250), randomColor);


                       
                    }

                    #endregion

                    break;
                case GameElements._state.Menu:
                    //Draws the menu sprite
                    GameElements.MenuDraw(spriteBatch);
                    break;
                case GameElements._state.Lobby:
                    GameElements.LobbyDraw(spriteBatch);
                    break;
                case GameElements._state.Quit:
                    Exit();
                    break;
                case GameElements._state.End:
                    GameElements.EndDraw(spriteBatch,font);
                    break;
            }

            spriteBatch.End();
            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }