Ejemplo n.º 1
0
 public static void PlaySimonSound(SimonColors scolor)
 {
     try
     {
         simonSounds[(int)scolor].Play();
     }
     catch
     {
         Debug.Write("PlayExplosion Failed");
     }
 }
Ejemplo n.º 2
0
        public static void SolveSimonSays(BombManager bombData, ref SimonSaysModule moduleData)
        {
            int len = moduleData.FlashSequence.Length;

            SimonColors[] returnSequence = new SimonColors[len];
            for (int i = 0; i < len; i++)
            {
                returnSequence[i] = GetSimonColor(moduleData.FlashSequence[i], bombData.Strikes, bombData.SerialContainsVowel());
            }
            moduleData.SetSolution(returnSequence);
            moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber);
            moduleData.RaiseDependencyFlag(DependencyFlag.Strikes);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here
            turntime += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (turn == Turn.COMPUTER)
            {
                Lit = SimonColors.NONE;

                if (turntime > 1000)
                {
                     moves.Add((SimonColors)rand.Next(0, 4));
                     turn = Turn.PLAYBACK;
                     PlayBackIndex = 0;
                    turntime = 0;
                }
            }
            else if (turn == Turn.PLAYBACK)
            {
                if (turntime > 750)
                {

                    if (PlayBackIndex == moves.Count)
                    {
                        turn = Turn.PLAYER;
                        Lit = SimonColors.NONE;
                        PlayBackIndex = 0;
                    }
                    else
                    {
                        Lit = moves[PlayBackIndex];
                        PlayBackIndex++;
                    }

                    turntime = 0;
                }
            }
            else if (turn == Turn.PLAYER)
            {
                MouseState ms = Mouse.GetState();

                if (ms.LeftButton == ButtonState.Pressed && released)
                {
                    released = false;
                    Lit = getPressed();

                    if (Lit != SimonColors.NONE)
                    {
                        SoundManager.PlaySimonSound(Lit);

                        if (Lit == moves[PlayerTurnIndex])
                        {
                            PlayerTurnIndex++;

                            if (PlayerTurnIndex == moves.Count)
                            {
                                PlayerTurnIndex = 0;
                                turn = Turn.COMPUTER;
                            }
                        }
                        else
                        {
                            turn = Turn.GAMEOVER;
                            SoundManager.PlayGameOver();
                            PlayerTurnIndex = 0;
                        }
                    }
                }
                else if (ms.LeftButton == ButtonState.Released)
                    released = true;

            }
            else if (turn == Turn.GAMEOVER)
            {
                SoundManager.PlayGameOver();

                moves.Clear();
                turn = Turn.COMPUTER;
                Lit = SimonColors.NONE;
            }

            base.Update(gameTime);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here

            if (turn == Turn.COMPUTER)
            {
                // TODO: After 1 second add a random move

                // moves.Add((SimonColors)rand.Next(0, 4));
                // turn = Turn.PLAYBACK;
                // PlayBackIndex = 0;
            }
            else if (turn == Turn.PLAYBACK)
            {
                // TODO: Play one move every 750ms..
                // DO NOT PLAY BACK ALL MOVES AT ONCE

                // If PlayBackIndex == moves.Count then turn = Turn.PLAYER (and set PlayerTurnIndex to 0)
            }
            else if (turn == Turn.PLAYER)
            {
                MouseState ms = Mouse.GetState();

                if (ms.LeftButton == ButtonState.Pressed)
                {
                    // Check to see if green button is hit.. add code to make sure the mouse button is depressed so you
                    // don't respond to this buttonpress twice in a row
                    Lit = getPressed();

                    if (Lit != SimonColors.NONE)
                    {
                        // do something here!  Maybe see if Lit was the correct button to press?

                        SoundManager.PlaySimonSound(Lit);
                    }
                }
            }
            else if (turn == Turn.GAMEOVER)
            {
                SoundManager.PlayGameOver();

                moves.Clear();
                turn = Turn.COMPUTER;
                Lit = SimonColors.NONE;
            }

            base.Update(gameTime);
        }
Ejemplo n.º 5
0
        public static SimonColors GetSimonColor(SimonColors flash, int strikes, bool vowel)
        {
            switch (flash)
            {
            case SimonColors.Red:
            {
                switch (strikes)
                {
                case 0:
                    return(SimonColors.Blue);

                case 1:
                    return(vowel ? SimonColors.Yellow : SimonColors.Red);

                default:
                    return(vowel ? SimonColors.Green : SimonColors.Yellow);
                }
            }

            case SimonColors.Blue:
            {
                switch (strikes)
                {
                case 0:
                    return(vowel ? SimonColors.Red : SimonColors.Yellow);

                case 1:
                    return(vowel ? SimonColors.Green : SimonColors.Blue);

                default:
                    return(vowel ? SimonColors.Red : SimonColors.Green);
                }
            }

            case SimonColors.Green:
            {
                switch (strikes)
                {
                case 0:
                    return(vowel ? SimonColors.Yellow : SimonColors.Green);

                case 1:
                    return(vowel ? SimonColors.Blue : SimonColors.Yellow);

                default:
                    return(vowel ? SimonColors.Yellow : SimonColors.Blue);
                }
            }

            default:
            {
                switch (strikes)
                {
                case 0:
                    return(vowel ? SimonColors.Green : SimonColors.Red);

                case 1:
                    return(vowel ? SimonColors.Red : SimonColors.Green);

                default:
                    return(vowel ? SimonColors.Blue : SimonColors.Red);
                }
            }
            }
        }