Пример #1
0
        public SnakeConsole()
            : base(50, 60)
        {
            gameSpeed = new TimeSpan(0, 0, 0, 0, gameSpeedMs);
            lastUpdate = DateTime.Now;

            random = new Random();
            this.IsVisible = false;
            gameState = GameState.MenuScreen;

            // Draw outline of phone
            SetGlyph(11, 55, 200, Color.White);
            SetGlyph(39, 55, 188, Color.White);
            for(int i = 12; i < 39; i++)
            {
                SetGlyph(i, 55, 205, Color.White);
            }
            for (int i = 30; i < 55; i++)
            {
                SetGlyph(11, i, 186, Color.White);
                SetGlyph(39, i, 186, Color.White);
            }
            SetGlyph(11, 29, 187, Color.White);
            SetGlyph(39, 29, 201, Color.White);
            SetGlyph(10, 29, 200, Color.White);
            SetGlyph(40, 29, 188, Color.White);
            for (int i = 5; i < 29; i++)
            {
                SetGlyph(10, i, 186, Color.White);
                SetGlyph(40, i, 186, Color.White);
            }
            SetGlyph(10, 4, 201, Color.White);
            SetGlyph(40, 4, 187, Color.White);
            for (int i = 11; i < 40; i++)
            {
                SetGlyph(i, 4, 205, Color.White);
            }

            // Draw Phone Buttons
            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow1, "1");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow1, "2");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow1, "3");

            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow2, "4");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow2, "5");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow2, "6");

            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow3, "7");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow3, "8");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow3, "9");

            DrawPhoneButton(phoneButtonColumn1, phoneButtonRow4, "*");
            DrawPhoneButton(phoneButtonColumn2, phoneButtonRow4, "0");
            DrawPhoneButton(phoneButtonColumn3, phoneButtonRow4, "#");

            // Create Animations  AstrickKeyAnimationCb
            astrickKeyAnimation = new InstructionSet();
            CodeInstruction astrickCallback = new CodeInstruction();
            astrickCallback.CodeCallback = AstrickKeyAnimationCb;
            astrickKeyAnimation.Instructions.AddLast(astrickCallback);

            upKeyAnimation = new InstructionSet();
            CodeInstruction upCallback = new CodeInstruction();
            upCallback.CodeCallback = UpKeyAnimationCb;
            upKeyAnimation.Instructions.AddLast(upCallback);

            downKeyAnimation = new InstructionSet();
            CodeInstruction downCallback = new CodeInstruction();
            downCallback.CodeCallback = DownKeyAnimationCb;
            downKeyAnimation.Instructions.AddLast(downCallback);

            leftKeyAnimation = new InstructionSet();
            CodeInstruction leftCallback = new CodeInstruction();
            leftCallback.CodeCallback = LeftKeyAnimationCb;
            leftKeyAnimation.Instructions.AddLast(leftCallback);

            rightKeyAnimation = new InstructionSet();
            CodeInstruction rightCallback = new CodeInstruction();
            rightCallback.CodeCallback = RightKeyAnimationCb;
            rightKeyAnimation.Instructions.AddLast(rightCallback);

            // Draw Microphone
            for (int i = 24; i < 27; i++)
            {
                SetGlyph(i, 53, 240, Color.DarkGray);
            }

            // Draw Plate
            for (int x = 12; x < 39; x++)
            {
                for (int y = 6; y < 28; y++)
                {
                    SetGlyph(x, y, 178, Color.Silver);
                }
            }
            for (int x = 13; x < 38; x++)
            {
                for (int y = 28; y < 30; y++)
                {
                    SetGlyph(x, y, 178, Color.Silver);
                }
            }

            // Draw End and CAll Button
            for (int x = phoneButtonColumn1; x < phoneButtonColumn1 + 7; x++)
            {
                for (int y = 26; y < 29; y++)
                {
                    SetGlyph(x, y, 219, Color.Gray);
                }
            }
            Print(phoneButtonColumn1 + 2, 27, "End", Color.Red, Color.Gray);

            for (int x = phoneButtonColumn3 - 2; x < phoneButtonColumn3 - 2 + 7; x++)
            {
                for (int y = 26; y < 29; y++)
                {
                    SetGlyph(x, y, 219, Color.Gray);
                }
            }
            Print(phoneButtonColumn3 - 1, 27, "Call", Color.Green, Color.Gray);

            // Draw Speaker
            for (int i = 22; i < 29; i++)
            {
                SetGlyph(i, 7, 240, Color.Black, Color.Silver);
            }

            // Draw Brand
            Print(23, 10, "NOKIA", Color.White, Color.Silver);

            // Draw Screen
            ClearScreen();

            // Draw Game Name
            CreateStartMessage();

            player = null;
        }
Пример #2
0
        private void ResetGame()
        {
            ClearScreen();
            currentScore = 0;
            DrawScore(currentScore);
            DrawGameBorder();
            player = new Player();
            player.Position = new Microsoft.Xna.Framework.Point(18, 18);
            player.SetStartingPosition(player.Position);
            SetGlyph(player.Position.X, player.Position.Y, 1, Color.Black, Color.DarkSeaGreen);

            CreateRandomWaferLocation();
            SetGlyph(wafer.X, wafer.Y, 249, Color.Black, Color.DarkSeaGreen);

            gameState = GameState.Running;
        }