예제 #1
0
        public override void Draw(GraphicsDevice graphicsDevice_)
        {
            // Render objects to the screen
            // ================

            // Clear the screen
            graphicsDevice_.Clear(Color.Beige);

            // Start rendering graphics
            GraphicsHandler.StartDrawing();

            // Render background
            GraphicsHandler.DrawSprite(m_grassbackground);
            GraphicsHandler.DrawSprite(m_background);

            // Render animated sprites
            foreach (AnimatedSprite anim_ in m_animatedSprites)
            {
                if (anim_.IsVisible())
                {
                    GraphicsHandler.DrawAnimatedSprite(anim_);
                }
            }

            // Render particles             TEMP
            foreach (Particle part_ in m_particles)
            {
                if (part_.GetLife() > 0)
                {
                    GraphicsHandler.DrawParticle(part_.GetPosition(), part_.GetColour(), part_.GetLife());
                }
            }

            h_trackHandler.Draw();

            // Render player vehicles
            foreach (Player p in m_players)
            {
                GraphicsHandler.DrawSprite(p.GetVehicle().m_vehicleBody.GetSprite());
                //GraphicsHandler.DrawSprite(p.GetCow());
                GraphicsHandler.DrawSprite(p.m_controlScheme.m_controlInterfaceSprite);
                GraphicsHandler.DrawSprite(p.m_controlScheme.m_steeringIndicatorSprite);

                if (!PlayersReady)
                {
                    GraphicsHandler.DrawSprite(p.m_ReadyButton.m_sprite);
                }
            }

            for (int i = 0; i < Settings.m_numberOfPlayers; i++)
            {
                //GraphicsHandler.DrawSprite(m_rankingSprites[i]);
            }

            // RENDER UI

            // Render ranking text
            if (m_rankings.Count != 0)
            {
                GraphicsHandler.DrawText("1st - Player " + m_rankings[0].ToString(), new Vector2(Settings.m_screenWidth / 2 - 450, Settings.m_screenHeight / 2 - 80), Color.Red, 0);

                if (m_rankings.Count > 1)
                {
                    GraphicsHandler.DrawText("2nd - Player " + m_rankings[1].ToString(), new Vector2(Settings.m_screenWidth / 2 - 350, Settings.m_screenHeight / 2 - 80), Color.Red, 0);
                    if (m_rankings.Count > 2)
                    {
                        GraphicsHandler.DrawText("3rd - Player " + m_rankings[2].ToString(), new Vector2(Settings.m_screenWidth / 2 - 250, Settings.m_screenHeight / 2 - 80), Color.Red, 0);
                        if (m_rankings.Count > 3)
                        {
                            GraphicsHandler.DrawText("4th - Player " + m_rankings[3].ToString(), new Vector2(Settings.m_screenWidth / 2 - 150, Settings.m_screenHeight / 2 - 80), Color.Red, 0);
                        }
                    }
                }
            }

            for (int i = 0; i < m_rankingSprites.Count; i++)
            {
                GraphicsHandler.DrawSprite(m_rankingSprites[i]);
            }



            /*if (m_rankings.Count != 0) {
             *  GraphicsHandler.DrawText(new DebugText("1st - Player " + m_players[0].GetRaceTime(), new Vector2(1000f, 440f)));
             *  if (m_rankings.Count > 1) {
             *      GraphicsHandler.DrawText(new DebugText("2nd - Player " + m_players[1].GetRaceTime(), new Vector2(1000f, 460f)));
             *      if (m_rankings.Count > 2) {
             *          GraphicsHandler.DrawText(new DebugText("3rd - Player " + m_players[2].GetRaceTime(), new Vector2(1000f, 480f)));
             *          if (m_rankings.Count > 3) {
             *              GraphicsHandler.DrawText(new DebugText("4th - Player " + m_players[3].GetRaceTime(), new Vector2(1000f, 500f)));
             *          }
             *      }
             *  }
             * }*/

            foreach (Player p in m_players)
            {
                Debug.AddSprite(p.GetVehicle().m_vehicleBody.GetSprite());
                foreach (Tyre t in p.GetVehicle().m_vehicleTyres)
                {
                    Debug.AddSprite(t.GetSprite());
                }
            }

            foreach (Player p in m_players)
            {
                Debug.AddSprite(p.GetVehicle().m_vehicleTyres[0].GetSprite());
                Debug.AddSprite(p.GetVehicle().m_vehicleTyres[1].GetSprite());
                Debug.AddSprite(p.GetVehicle().m_vehicleTyres[2].GetSprite());
                Debug.AddSprite(p.GetVehicle().m_vehicleTyres[3].GetSprite());
            }
            //GraphicsHandler.DrawSprite(bsv.m_vehicleBody.GetSprite());*/



            if (!startTimer.timerFinished)
            {
                GraphicsHandler.DrawText(((int)(startTimer.timeRemaining / 1000) + 1).ToString(), new Vector2(1000, 50), Color.Red, 3);
            }
            if (finished)
            {
                GraphicsHandler.DrawText("Player " + m_winner.ToString() + " is the winner", new Vector2(500, 500), Color.Red);
            }

            // Stop rendering graphics
            GraphicsHandler.StopDrawing();
        }