Ejemplo n.º 1
0
        // Called to show the shell that the player should be looking at
        public IEnumerator ShowLuckyShell()
        {
            while (luckyShell.AnimateOpenChest() == false)
            {
                yield return(null);
            }
            yield return(null);

            while (luckyShell.AnimateCloseChest() == false)
            {
                yield return(null);
            }
            yield return(new WaitForSeconds(1f));

            // If the game state is at SHOW, we start the game up
            // Otherwise, we simply leave the method
            if (currentState == GameState.SHOW)
            {
                StartCoroutine(PerformGame());
            }
        }
Ejemplo n.º 2
0
        // This is called when the player has selected a shell to see if they are right
        public IEnumerator ConcludeGame(InteractShell selectedShell)
        {
            if (currentState == GameState.SELECTING)
            {
                // The reason we wait 3 seconds here is because we want to make sure the ShowLuckyShell method
                // completes running its course, since we called it in parallel to this method.
                if (selectedShell.IsWinner == true)
                {
                    currentState = GameState.WIN;
                    gameScore   += 1;
                    StartCoroutine(soundPlayer.WinSound());

                    while (selectedShell.AnimateOpenChest() == false)
                    {
                        yield return(null);
                    }
                    while (selectedShell.AnimateCloseChest() == false)
                    {
                        yield return(null);
                    }
                }
                else
                {
                    currentState = GameState.LOSE;
                    StartCoroutine(soundPlayer.LoseSound());

                    while (luckyShell.AnimateOpenChest() == false)
                    {
                        yield return(null);
                    }
                    while (luckyShell.AnimateCloseChest() == false)
                    {
                        yield return(null);
                    }

                    // If we lose once, we restart from the start
                    gameScore        = 0;
                    numberOfSwitches = origNumberOfSwitches;
                    soundPlayer.RestartSong();
                }
                yield return(new WaitForSeconds(1f));

                // We then reset the shells back
                foreach (InteractShell currShell in InteractShell.shellList)
                {
                    currShell.ResetShell();
                }

                // And depending if we won/lost, we proceed accordingly
                if (currentState == GameState.LOSE)
                {
                    currentState = GameState.BEGINNING;
                }
                else if (currentState == GameState.WIN)
                {
                    currentState = GameState.LOADING;
                    yield return(null);

                    StartGame();
                }
            }
        }