}         // RenderBottomLinkButton(buttonType)

        #endregion

        #region Render background
        /// <summary>
        /// Render mouse cursor
        /// </summary>
        public void RenderMouseCursor()
        {
#if !XBOX360
            // We got 4 animation steps, rotate them by the current time
            int mouseAnimationStep = (int)(BaseGame.TotalTimeMs / 100) % 4;

            // And render mouse on screen.
            mouseCursorTexture.RenderOnScreen(
                new Rectangle(Input.MousePos.X, Input.MousePos.Y, 60, 60),
                new Rectangle(64 * mouseAnimationStep, 0, 60, 60));

            // Draw all sprites (just the mouse cursor)
            SpriteHelper.DrawSprites(width, height);
#endif
        }         // RenderMouseCursor()
예제 #2
0
        protected override void Draw(GameTime gameTime)
        {
            SpriteHelper.DrawSprites(width, height);
            font.WriteAll();

            spriteBatch.Begin();
            spriteBatch.DrawString(CopyrightFont, "© 2011 by GodLesZ for Krönchen <3", new Vector2(10, Window.ClientBounds.Height - 18), Color.LightGray);
            if (Paused)
            {
                spriteBatch.DrawString(CopyrightFont, "Pause", new Vector2(Window.ClientBounds.Width / 2 - 65, Window.ClientBounds.Height / 2 - 20), Color.White, 0, Vector2.Zero, 4f, SpriteEffects.None, 0);
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #3
0
        }                                           // ShowAllItems(useShader)

        #endregion

        #region Render
        /// <summary>
        /// Render, most performance critical method of the game.
        /// Renders all asteroids and handles all physics, updating, etc.
        /// We use instancing to speed up asteroid rendering!
        /// </summary>
        public void Render(Texture inGameTexture, Texture lightEffectTexture)
        {
            #region Initialize
            // Use alpha blending for blending out asteroids
            BaseGame.EnableAlphaBlending();

            // Get camera position, no need to call the property 1 mio times.
            Vector3 cameraPos = BaseGame.CameraPos;

            // Empty display distance list
            remToDisplayDistance.Clear();
            #endregion

            #region Show target behind asteroids
            // Show target icon behind all asteroids and items (only in game)
            if (inGameTexture != null)
            {
                // First find out where the target is.
                Point screenPos = BaseGame.Convert3DPointTo2D(TargetPosition);
                bool  isVisible = BaseGame.IsInFrontOfCamera(TargetPosition);

                if (isVisible &&
                    screenPos.X >= 0 && screenPos.X < BaseGame.Width &&
                    screenPos.Y >= 0 && screenPos.Y < BaseGame.Height)
                {
                    // From Mission.cs:70.
                    Rectangle TargetIconRect = new Rectangle(106, 49, 61, 61);

                    // Render target icon centered at screenPos
                    // Note: This will be blurred because we render it before
                    // the glow/bloom/motion blur shader is applied, but if we
                    // render after that we can't render behind the asteroids.
                    // See Mission.RenderTarget!
                    inGameTexture.RenderOnScreen(new Rectangle(
                                                     screenPos.X - TargetIconRect.Width / 2,
                                                     screenPos.Y - TargetIconRect.Height / 2,
                                                     TargetIconRect.Width, TargetIconRect.Height),
                                                 TargetIconRect, Color.White, SpriteBlendMode.Additive);
                }         // if (isVisible)
            }             // if (inGameTexture)
            #endregion

            #region Show glow behind items
            // Show glow behind all items
            for (int num = 0; num < Level.NumOfItemTypes; num++)
            {
                // Go through all items of this type
                foreach (Vector3 pos in items[num])
                {
                    // Get distance to viewer
                    float distance = (pos - cameraPos).Length();

                    // Skip if out of visible range * 6
                    if (distance > MaxViewDepth * 6 ||
                        BaseGame.IsInFrontOfCamera(pos) == false)
                    {
                        continue;
                    }

                    // Convert to screen coordinates
                    Point screenPos = BaseGame.Convert3DPointTo2D(pos);
                    int   glowSize  = 36 * BaseGame.Width / 1024;

                    // If not visible, skip!
                    if (screenPos.X < -glowSize ||
                        screenPos.Y < -glowSize ||
                        screenPos.X > BaseGame.Width + glowSize ||
                        screenPos.Y > BaseGame.Height + glowSize)
                    {
                        continue;
                    }

                    // Calculate alpha
                    float alpha = 1.0f;
                    if (distance > MaxViewDepth * 4)
                    {
                        alpha = 1.0f -
                                ((distance - MaxViewDepth * 4) / (MaxViewDepth * (6 - 4)));
                    }

                    // Show glow with help of light effect
                    if (lightEffectTexture != null)
                    {
                        lightEffectTexture.RenderOnScreen(
                            new Rectangle(screenPos.X - glowSize, screenPos.Y - glowSize,
                                          glowSize * 2, glowSize * 2),
                            lightEffectTexture.GfxRectangle,
                            ColorHelper.ApplyAlphaToColor(ItemColors[num], alpha * 0.5f),
                            SpriteBlendMode.Additive);
                    }

                    // And display distance to item below it (not here, see below).
                    float textAlpha = alpha * 1.5f *
                                      (1.0f - (distance / (MaxViewDepth * 6)));
                    AddDistanceToBeDisplayed(screenPos, distance,
                                             textAlpha < 1.0f ? textAlpha : 1.0f);
                }         // foreach (pos)
            }             // for (num)

            // Flush all glow sprites on the screen (before rendering asteroids!)
            SpriteHelper.DrawSprites();
            #endregion

            #region Render 3d models, especially the asteroids
            // Draw goal at target position
            goalModel.Render(Matrix.CreateScale(100) *
                             Matrix.CreateRotationX(-(float)Math.PI / 2.0f) *
                             Matrix.CreateTranslation(TargetPosition));

            // Call base render method, target and item glow is behind of the
            // asteroids.
            base.RenderAsteroids();
            #endregion
        }         // Render()