示例#1
0
    private void CheckWinOrLose()
    {
        if (m_inputManager.IsFirstRelease() || m_timeUntilNextSwipe < -ONE_POINT_TIME)
        {
            bool win = false;
            if (m_timeUntilNextSwipe < -ONE_POINT_TIME || m_timeUntilNextSwipe > ONE_POINT_TIME && m_currentSwipe < m_currentLevel.Swipes.Count)
            {
                win = false;
            }
            else if (m_currentLevel.GetSwipe(m_currentSwipe) == Swipes.Up)
            {
                if (m_swipeManager.GetCurrentSwipePosition().y > REQUIRED_SWIPE_DISTANCE)
                {
                    win = true;
                }
            }
            else if (m_currentLevel.GetSwipe(m_currentSwipe) == Swipes.Down)
            {
                if (m_swipeManager.GetCurrentSwipePosition().y < -REQUIRED_SWIPE_DISTANCE)
                {
                    win = true;
                }
            }
            else if (m_currentLevel.GetSwipe(m_currentSwipe) == Swipes.Left)
            {
                if (m_swipeManager.GetCurrentSwipePosition().x < -REQUIRED_SWIPE_DISTANCE)
                {
                    win = true;
                }
            }
            else if (m_currentLevel.GetSwipe(m_currentSwipe) == Swipes.Right)
            {
                if (m_swipeManager.GetCurrentSwipePosition().x > REQUIRED_SWIPE_DISTANCE)
                {
                    win = true;
                }
            }

            bool showResults = false;

            if (win)
            {
                m_audioManager.PlayWinSound();
                float percent = m_swipeManager.GetPercentage();
                if (percent >= 0.85f && percent <= 1.15f)
                {
                    m_points += 3;
                    m_threePointText.gameObject.SetActive(true);
                    m_threePointTimer = 0.0f;
                }
                else if (percent > 0.5f && percent < 1.5f)
                {
                    m_points += 2;
                    m_twoPointText.gameObject.SetActive(true);
                    m_twoPointTimer = 0.0f;
                }
                else
                {
                    m_points += 1;
                    m_onePointText.gameObject.SetActive(true);
                    m_onePointTimer = 0.0f;
                }
            }
            else
            {
                m_missText.gameObject.SetActive(true);
                m_losses++;
                m_audioManager.PlayLoseSound();
            }

            m_currentSwipe++;

            UpdateAccuracy();
            if (m_accuracy < GameManager.C_ACCURACY && m_losses >= GameManager.ALLOWED_LOSSES)
            {
                showResults = true;
            }

            if (m_currentSwipe >= m_currentLevel.Swipes.Count - 1)
            {
                if (m_accuracy > m_previousAccuracy && m_accuracy >= GameManager.C_ACCURACY)
                {
                    SaveLevelStats();
                }
                if (m_accuracy >= GameManager.C_ACCURACY)
                {
                    m_win = true;
                }
                showResults        = true;
                m_previousAccuracy = -1;
            }
            if (showResults)
            {
                ShowResults();
                return;
            }
            UpdateTimeUntilNextSwipe();
            m_audioManager.ResetSongTimer();
            m_swipeManager.SetCurrentSwipeType(m_currentLevel.GetSwipe(m_currentSwipe), m_timeUntilNextSwipe);
            m_swipeManager.SetNextSwipeType(m_currentLevel.GetSwipe(m_currentSwipe + 1));
            m_backgroundManager.SetNextBackground(m_currentLevel.GetBackgroundIndex(m_currentSwipe + 1));
        }
    }