Beispiel #1
0
        /// <summary>
        /// 允许游戏在开始运行之前执行其所需的任何初始化。
        /// 游戏能够在此时查询任何所需服务并加载任何非图形
        /// 相关的内容。调用 base.Initialize 将枚举所有组件
        /// 并对其进行初始化。 
        /// </summary>
        protected override void Initialize()
        {
            // TODO: 在此处添加初始化逻辑
            currentState = GameState.main_menu;
            preState = GameState.main_menu;

            Components.Clear();
            Menu menu = new Menu(this);
            menu.Initialize();
            Components.Add(menu);

            base.Initialize();
        }
Beispiel #2
0
        /// <summary>
        /// 允许游戏在开始运行之前执行其所需的任何初始化。
        /// 游戏能够在此时查询任何所需服务并加载任何非图形
        /// 相关的内容。调用 base.Initialize 将枚举所有组件
        /// 并对其进行初始化。 
        /// </summary>
        protected override void Initialize()
        {
            // TODO: 在此处添加初始化逻辑
            TouchPanel.EnabledGestures = GestureType.VerticalDrag | GestureType.HorizontalDrag | GestureType.Tap;

            currentState = GameState.main_menu;
            preState = GameState.main_menu;
            sceneChangeLag = 0;

            Components.Clear();
            Menu menu = new Menu(this);
            menu.Initialize();
            Components.Add(menu);

            base.Initialize();
        }
Beispiel #3
0
        /// <summary>
        /// 允许游戏运行逻辑,例如更新全部内容、
        /// 检查冲突、收集输入信息以及播放音频。
        /// </summary>
        /// <param name="gameTime">提供计时值的快照。</param>
        protected override void Update(GameTime gameTime)
        {
            // 允许游戏退出
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: 在此处添加更新逻辑
            if (currentState != preState)
            {
                sceneChangeLag -= gameTime.ElapsedGameTime.Milliseconds;
                if (sceneChangeLag <= 0)
                {
                    preState = currentState;
                    switch (currentState)
                    {
                        case GameState.main_menu:
                            Components.Clear();
                            Menu menu = new Menu(this);
                            menu.Initialize();
                            Components.Add(menu);
                            break;
                        case GameState.playing:
                            Components.Clear();
                            Scene scene = new Scene(this);
                            scene.Initialize();
                            Components.Add(scene);
                            break;
                        case GameState.lose:
                            Components.Clear();
                            Lose lose = new Lose(this);
                            lose.Initialize();
                            Components.Add(lose);
                            break;
                        case GameState.win:
                            Components.Clear();
                            Win win = new Win(this);
                            win.Initialize();
                            Components.Add(win);
                            break;
                        default:
                            break;
                    }
                }
            }

            base.Update(gameTime);
        }
Beispiel #4
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;
        }
Beispiel #5
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;
        }
Beispiel #6
0
        private void EndGame()
        {
            //ClearScreen();
            Print(23, 15, "GAME", Color.Black, Color.DarkSeaGreen);
            Print(23, 17, "OVER", Color.Black, Color.DarkSeaGreen);

            Print(21, 20, "Press * to", Color.Black, Color.DarkSeaGreen);
            Print(23, 21, "Exit", Color.Black, Color.DarkSeaGreen);

            gameState = GameState.GameOver;
        }
Beispiel #7
0
 private void CreateMenu()
 {
     ClearScreen();
     CreateStartMessage();
     gameState = GameState.MenuScreen;
 }
 public entry(string text, Vector2 position, GameState leading)
 {
     this.text = text;
     this.position = position;
     this.leading = leading;
 }
Beispiel #9
0
        protected override void Update(GameTime gameTime)
        {
            // Update Counter to keep snake from moving too fast.
            if (updatecounter == 6)
            {
                // Game State Manager
                // Actions performed depend on game state
                switch (currentGameState)
                {
                    case GameState.Start:
                        if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                        {
                            currentGameState = GameState.InGame;
                            // Turn on Game Components related to the InGame state
                            spriteManager.Enabled = true;
                            spriteManager.Visible = true;
                            myGameSpace.Enabled = true;
                            myGameSpace.Visible = true;
                        }
                        break;
                    case GameState.InGame:
                        if (backgroundInstance.State == SoundState.Stopped)
                        {
                            backgroundInstance.Play();
                        }
                        break;
                    case GameState.GameOver:
                        // If they are on, turn off Game Components related to the InGame state
                        if (spriteManager.Enabled)
                        {
                            spriteManager.Enabled = false;
                            spriteManager.Visible = false;
                            myGameSpace.Enabled = false;
                            myGameSpace.Visible = false;
                            gameOver.Play();
                        }
                        // Press Escape to Exit Program
                        if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                            this.Exit();
                        if (backgroundInstance.State == SoundState.Playing)
                        {
                            backgroundInstance.Stop();
                        }
                        break;
                }

                // Allows the game to exit with a gamepad
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    this.Exit();
                updatecounter = 0;
                base.Update(gameTime);
            }
            updatecounter++;
        }