Пример #1
0
    IEnumerator CutSceneWrapper(IEnumerator cutScene)
    {
        SpinStateEnum savedGameState = SpinState;

        SetGameState(SpinStateEnum.ShowCutscene);

        // Disable main game

        // Execute cutscene
        yield return(cutScene);

        // Enable main game
        SetGameState(savedGameState);
    }
Пример #2
0
    IEnumerator WaitForState(SpinStateEnum state, float timeout = -1)
    {
        float endTime = Time.time + timeout;

        while (SpinState != state)
        {
            if (timeout != -1 && Time.time >= endTime)
            {
                break;
            }

            yield return(null);
        }
    }
Пример #3
0
 void SetGameState(SpinStateEnum newState)
 {
     AppLog.StaticLogInfo("Setting new game state: {0}", newState);
     SpinState = newState;
 }
Пример #4
0
    IEnumerator GameLoop()
    {
        SpinState = SpinStateEnum.None;

        yield return(InitGame());

        // Outer game loop
        while (true)
        {
NewRound:
            ShowButtons(fullSpinRequired: true);

            SetGameState(SpinStateEnum.FullSpinRequired);

            holdFlags_[0] = false;
            holdFlags_[1] = false;
            holdFlags_[2] = false;
            UpdateHoldButtons();

            var spinLabel      = ButtonSpin.GetComponentInChildren <TextMeshProUGUI>();
            var spinLabelTween = spinLabel.transform.DOPunchScale(new Vector2(0.3f, 0.3f), 1.0f, 2, 1).SetLoops(-1);

            // Wait for user doing a full spin
            yield return(WaitForState(SpinStateEnum.Spinning));

            spinLabelTween.Kill();
            spinLabel.transform.DOScale(1.0f, 0.1f);

            SetWinLine(new int[] { 3, 4, 5 }); // Default middle

            int  winIdx;
            bool playerInterfered = false;
            while (!playerInterfered)
            {
                ShowButtons(fullSpinRequired: false);

                // Wait for spin to be done
                while (wheel_.IsSpinning)
                {
                    yield return(null);
                }

                if (CheckWin(out winIdx))
                {
                    // The player won something on initial spin, celebrate a bit, then back to full spin
                    SetGameState(SpinStateEnum.ShowCutscene);
                    yield return(ShowWin(winIdx));

                    goto NewRound;
                }

                // Player did not auto-win on initial spin
                SetGameState(SpinStateEnum.AwaitingUserDecisions);
                bool canWin = CheckForWinHint() > 0;
                if (!canWin && autoSpin_)
                {
                    // Nothing to win and auto-spin is enabled. Start all over.
                    yield return(new WaitForSeconds(0.5f));

                    ExecuteSpin(fullSpin: true);
                    continue;
                }

                yield return(WaitForState(SpinStateEnum.Spinning));

                CheckForWinHint(hide: true);

                bool playerUsedHold = holdFlags_[0] != false || holdFlags_[1] != false || holdFlags_[2] != false;
                // Keep looping full spins until player holds or nudges
                playerInterfered = playerUsedHold || !lastSpinWasFull_;

                // Reset win line to default if player didn't interfere, since it doesn't matter where it is
                if (!playerInterfered)
                {
                    SetWinLine(new int[] { 3, 4, 5 }); // Default middle
                }
            }

            // Player used hold and/or nudge. Wait for spin to be done
            while (wheel_.IsSpinning)
            {
                yield return(null);
            }

            if (CheckWin(out winIdx))
            {
                // The player won something on secondary spin, celebrate a bit, then back to full spin
                SetGameState(SpinStateEnum.ShowCutscene);
                yield return(ShowWin(winIdx));

                continue;
            }

            // The player didn't win anything this round. Back to square one.
        }
    }