示例#1
0
        /// <summary>
        /// Отображение сообщения об уровне
        /// </summary>
        private void ShowLevelMessage()
        {
            string S1 = string.Format("УРОВЕНЬ {0,2:D}", levelNumber + 1),
                   S2 = "Нажмите Пробел,",
                   S3 = "чтобы начать";

            Vector2 V1 = new Vector2((BackBufferWidth - midFont.MeasureString(S1).X) / 2,
                                     (BackBufferHeight - 180) / 2) + level.CameraPosition,
                    V2 = new Vector2((BackBufferWidth - defFont.MeasureString(S2).X) / 2,
                                     (BackBufferHeight + 60) / 2) + level.CameraPosition,
                    V3 = new Vector2((BackBufferWidth - defFont.MeasureString(S3).X) / 2,
                                     (BackBufferHeight + 110) / 2) + level.CameraPosition;

            spriteBatch.Draw(messageBack, GameAuxFunctions.CenterOf(messageBackLeftTop, level.CameraPosition),
                             TurtleGameColors.LBlue_B);
            spriteBatch.DrawString(midFont, S1, V1, TurtleGameColors.LBlue);
            spriteBatch.DrawString(defFont, S2, V2, TurtleGameColors.Orange);
            spriteBatch.DrawString(defFont, S3, V3, TurtleGameColors.Orange);
        }
示例#2
0
        /// <summary>
        /// Отображение запроса на подтверждение выхода
        /// </summary>
        private void ShowExitMessage()
        {
            string S1 = "Вы действительно хотите",
                   S2 = "завершить игру?",
                   S3 = "Нажмите Y, чтобы выйти из игры,",
                   S4 = "или N, чтобы вернуться";

            Vector2 V1 = new Vector2((BackBufferWidth - midFont.MeasureString(S1).X) / 2,
                                     (BackBufferHeight - 180) / 2) + level.CameraPosition,
                    V2 = new Vector2((BackBufferWidth - midFont.MeasureString(S2).X) / 2,
                                     (BackBufferHeight - 110) / 2) + level.CameraPosition,
                    V3 = new Vector2((BackBufferWidth - defFont.MeasureString(S3).X) / 2,
                                     (BackBufferHeight + 70) / 2) + level.CameraPosition,
                    V4 = new Vector2((BackBufferWidth - defFont.MeasureString(S4).X) / 2,
                                     (BackBufferHeight + 110) / 2) + level.CameraPosition;

            spriteBatch.Draw(messageBack, GameAuxFunctions.CenterOf(messageBackLeftTop, level.CameraPosition),
                             TurtleGameColors.Yellow_B);
            spriteBatch.DrawString(midFont, S1, V1, TurtleGameColors.Yellow);
            spriteBatch.DrawString(midFont, S2, V2, TurtleGameColors.Yellow);
            spriteBatch.DrawString(defFont, S3, V3, TurtleGameColors.Orange);
            spriteBatch.DrawString(defFont, S4, V4, TurtleGameColors.Orange);
        }
示例#3
0
        /// <summary>
        /// Отображение сообщения о проигрыше
        /// </summary>
        private void ShowLoseMessage()
        {
            string S1 = "УРОВЕНЬ",
                   S2 = "НЕ ПРОЙДЕН!",
                   S3 = "Нажмите Пробел,",
                   S4 = "чтобы попробовать снова";

            Vector2 V1 = new Vector2((BackBufferWidth - midFont.MeasureString(S1).X) / 2,
                                     (BackBufferHeight - 180) / 2) + level.CameraPosition,
                    V2 = new Vector2((BackBufferWidth - midFont.MeasureString(S2).X) / 2,
                                     (BackBufferHeight - 110) / 2) + level.CameraPosition,
                    V3 = new Vector2((BackBufferWidth - defFont.MeasureString(S3).X) / 2,
                                     (BackBufferHeight + 60) / 2) + level.CameraPosition,
                    V4 = new Vector2((BackBufferWidth - defFont.MeasureString(S4).X) / 2,
                                     (BackBufferHeight + 110) / 2) + level.CameraPosition;

            spriteBatch.Draw(messageBack, GameAuxFunctions.CenterOf(messageBackLeftTop, level.CameraPosition),
                             TurtleGameColors.Red_B);
            spriteBatch.DrawString(midFont, S1, V1, TurtleGameColors.Red);
            spriteBatch.DrawString(midFont, S2, V2, TurtleGameColors.Red);
            spriteBatch.DrawString(defFont, S3, V3, TurtleGameColors.Orange);
            spriteBatch.DrawString(defFont, S4, V4, TurtleGameColors.Orange);
        }
示例#4
0
        /// <summary>
        /// Метод отрисовывает уровень игры
        /// </summary>
        /// <param name="VGameTime">Время игры</param>
        protected override void Draw(GameTime VGameTime)
        {
            // Создание чистого окна и запуск рисования
            graphics.GraphicsDevice.Clear(SnakeGameColors.DGreen);
            spriteBatch.Begin();

            // В ЗАВИСИМОСТИ ОТ СОСТОЯНИЯ ИГРЫ
            switch (gameStatus)
            {
            //////////////////////////////////////////////////////////////////
            case GameStatus.Start:
                ShowStartMessage();

                break;

            //////////////////////////////////////////////////////////////////
            case GameStatus.Help:
                ShowHelpMessage();

                break;

            //////////////////////////////////////////////////////////////////
            case GameStatus.Playing:
                // ОТОБРАЖЕНИЕ УРОВНЯ
                level.Draw(VGameTime, spriteBatch, playerPosition[0]);

                // ОТОБРАЖЕНИЕ АНИМИРОВАННЫХ ИХОБРАЖЕНИЙ
                // Яблоко
                appleAnimator.Draw(VGameTime, spriteBatch, applePosition, SpriteEffects.None, SnakeGameColors.White, 0.0);

                // Тело змейки
                for (int n = 1; n < playerPosition.Count; n++)
                {
                    bodyAnimator.Draw(VGameTime, spriteBatch, playerPosition[n], SpriteEffects.None, SnakeGameColors.White, 0.0);
                }

                // Голова змейки
                headAnimator.Draw(VGameTime, spriteBatch, playerPosition[0], SpriteEffects.None, SnakeGameColors.White,
                                  // Изменение угла поворота текстуры
                                  Math.Acos(Math.Sign(playerTo.X)) * GameAuxFunctions.NNSign(playerTo.Y, true));


                // ОТОБРАЖЕНИЕ ИНФОРМАЦИИ
                DrawInfo();

                // Отображение сообщений
                Vector2 backBufferSize = new Vector2(SnakeGame.BackBufferWidth, SnakeGame.BackBufferHeight);
                if (showLevelMsg)
                {
                    messageBackAnimator.Draw(VGameTime, spriteBatch, GameAuxFunctions.CenterOf(backBufferSize,
                                                                                               level.CameraPosition), SpriteEffects.None, SnakeGameColors.LBlue_B, 0.0);
                    ShowLevelMessage();
                }

                if (showWinMsg)
                {
                    messageBackAnimator.Draw(VGameTime, spriteBatch, GameAuxFunctions.CenterOf(backBufferSize,
                                                                                               level.CameraPosition), SpriteEffects.None, SnakeGameColors.Green_B, 0.0);
                    ShowWinMessage();
                }

                if (showLoseMsg)
                {
                    messageBackAnimator.Draw(VGameTime, spriteBatch, GameAuxFunctions.CenterOf(backBufferSize,
                                                                                               level.CameraPosition), SpriteEffects.None, SnakeGameColors.Red_B, 0.0);
                    ShowLoseMessage();
                }

                if (showExitMsg)
                {
                    messageBackAnimator.Draw(VGameTime, spriteBatch, GameAuxFunctions.CenterOf(backBufferSize,
                                                                                               level.CameraPosition), SpriteEffects.None, SnakeGameColors.Yellow_B, 0.0);
                    ShowExitMessage();
                }

                break;

            //////////////////////////////////////////////////////////////////

            case GameStatus.Finish:
                ShowFinishMessage();

                break;
            }

            // Отключение устройства рисования
            spriteBatch.End();

            // Перерисовка
            base.Draw(VGameTime);
        }