示例#1
0
        public override void Update(GameTime gameTime)
        {
            time += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (cheatTextCurrentColor != Color.Transparent)
            {
                cheatTextCurrentColor = Color.Lerp(Color.Gold, Color.Transparent, ((float)gameTime.TotalGameTime.TotalSeconds - cheatInputTime) / 4f);
            }

            if (fadephase < 2 && (KeyboardManager.KeyPressedUp(Keys.Space) || KeyboardManager.KeyPressedUp(Keys.Enter) || KeyboardManager.KeyPressedUp(Keys.Escape) || GamepadManager.ProceedButtonPressedUp()))
            {
                backgroundCurrentColor = Color.White;
                text1CurrentColor      = Color.White;
                text2CurrentColor      = Color.White;
                startTextColor         = Color.White;
                startTextNextChange    = time + .8f;
                fadephase = 2;
            }
            else if (fadephase == 2)
            // Process input on the main screen...
            {
                if (KeyboardManager.KeyDown(Keys.LeftShift) || GamepadManager.AnyShoulderButtonDown())
                {
                    // Get the input to add to the cheat string.
                    if (KeyboardManager.KeyPressedUp(Keys.Up) || GamepadManager.UpButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "U");
                    }
                    if (KeyboardManager.KeyPressedUp(Keys.Down) || GamepadManager.DownButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "D");
                    }
                    if (KeyboardManager.KeyPressedUp(Keys.Left) || GamepadManager.LeftButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "L");
                    }
                    if (KeyboardManager.KeyPressedUp(Keys.Right) || GamepadManager.RightButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "R");
                    }

                    CheckCheats(gameTime);
                }
                else
                {
                    cheatInputText = "";
                }


                if ((KeyboardManager.KeyPressedDown(Keys.Enter) || GamepadManager.ProceedButtonPressedUp()) && !HelpShown && !CreditsShown)
                {
                    // Begin the game...
                    fadephase = 3;
                    music.Stop();
                    time                = 0f;
                    startTextColor      = Color.White;
                    startTextNextChange = 0.05f;
                    GameStartSound.Play();
                }
                else
                {
                    if (KeyboardManager.KeyDown(Keys.C))
                    {
                        CreditsShown = true;
                    }
                    else
                    {
                        CreditsShown = false;
                    }

                    if (KeyboardManager.KeyDown(Keys.H))
                    {
                        HelpShown = true;
                    }
                    else
                    {
                        HelpShown = false;
                    }
                }
            }

            switch (fadephase)
            {
            case (0):
                backgroundCurrentColor = Color.Lerp(Color.Black, Color.White, time / 3f);
                if (backgroundCurrentColor == Color.White)
                {
                    fadephase = 1;
                }
                break;

            case (1):
                if (time > 3.5f)
                {
                    text1CurrentColor = Color.Lerp(Color.Transparent, Color.White, (time - 3.5f) / 1.8f);
                    text2CurrentColor = Color.Lerp(Color.Transparent, Color.White, (time - 5f) / 3f);
                }
                if (time > 8f)
                {
                    startTextColor      = Color.White;
                    startTextNextChange = 8.8f;
                    fadephase           = 2;
                }
                break;

            case (2):
            {
                if (time > startTextNextChange)
                {
                    if (startTextColor == Color.White)
                    {
                        startTextColor = Color.Transparent;
                    }
                    else
                    {
                        startTextColor = Color.White;
                    }

                    startTextNextChange += .8f;
                }
            }
            break;

            case (3):
                if (time > startTextNextChange)
                {
                    if (startTextColor == Color.White)
                    {
                        startTextColor = Color.Yellow;
                    }
                    else
                    {
                        startTextColor = Color.White;
                    }

                    startTextNextChange += .05f;
                }
                if (time > 1.5f)
                {
                    startTextColor = Color.Transparent;
                    fadephase      = 4;
                    time           = 0;
                }
                break;

            case (4):
                backgroundCurrentColor = Color.Lerp(Color.White, Color.Black, time / 1.5f);
                text1CurrentColor      = Color.Lerp(Color.White, Color.Black, time / 1.5f);
                text2CurrentColor      = Color.Lerp(Color.White, Color.Black, time / 1.5f);
                //startTextColor = Color.Lerp(Color.White, Color.Black, time / 1.5f);

                if (time > 1.8f)
                {
                    Game.ChangeScene(new GameScene(Game));
                }
                break;

            default:
                break;
            }
        }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            currentGameTime = (float)gameTime.TotalGameTime.TotalSeconds;

            Vector2 movement = new Vector2();
            // Update controls
            float moveSpeed;

            if (KeyboardManager.KeyDown(Keys.LeftShift) || GamepadManager.AButtonDown() || GamepadManager.AnyShoulderButtonDown())
            {
                moveSpeed = speed / 2.5f;
            }
            else
            {
                moveSpeed = speed;
            }


            if (KeyboardManager.KeyDown(Keys.Left) || GamepadManager.LeftButtonDown())
            {
                movement.X = -1 * (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (KeyboardManager.KeyDown(Keys.Right) || GamepadManager.RightButtonDown())
            {
                movement.X = (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (KeyboardManager.KeyDown(Keys.Up) || GamepadManager.UpButtonDown())
            {
                movement.Y = -1 * (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (KeyboardManager.KeyDown(Keys.Down) || GamepadManager.DownButtonDown())
            {
                movement.Y = (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            if ((KeyboardManager.KeyDown(Keys.Space) || GamepadManager.XButtonDown()) && gameTime.TotalGameTime.TotalSeconds > nextFireTime && CanFire)
            {
                // Fire!
                AudioManager.PlaySoundEffect(GameScene.Shot3Sound, .2f);
                Bullet newBullet = mainEmitter.FireBullet(((float)Math.PI / 2) * 3, 500f, Color.GreenYellow, BulletType.Diamond, true);
                newBullet.SetCollisionLayer(2);
                newBullet.DrawLayer = .1f;

                nextFireTime = (float)gameTime.TotalGameTime.TotalSeconds + .1f;
            }

            // Calculate the movement from the sticks if they exist
            movement.X += (moveSpeed * GamepadManager.LeftStickX() * (float)gameTime.ElapsedGameTime.TotalSeconds);
            movement.Y -= (moveSpeed * GamepadManager.LeftStickY() * (float)gameTime.ElapsedGameTime.TotalSeconds);

            Position += movement;

            // Now clamp the position...

            if (Center.X - Origin.X < thisScene.ScreenArea.X)
            {
                Center = new Vector2(thisScene.ScreenArea.X + Origin.X, Center.Y);
            }
            else if (Center.X + Origin.X > thisScene.ScreenArea.X + thisScene.ScreenArea.Width)
            {
                Center = new Vector2(thisScene.ScreenArea.X + thisScene.ScreenArea.Width - Origin.X, Center.Y);
            }

            if (Center.Y - Origin.Y < thisScene.ScreenArea.Y)
            {
                Center = new Vector2(Center.X, thisScene.ScreenArea.Y + Origin.Y);
            }
            else if (Center.Y + Origin.Y > thisScene.ScreenArea.Y + thisScene.ScreenArea.Height)
            {
                Center = new Vector2(Center.X, thisScene.ScreenArea.Y + thisScene.ScreenArea.Height - Origin.Y);
            }

            //Test a hoolio
            base.Update(gameTime);
        }