示例#1
0
    public void NudgeTiles()
    {
        if (!isNudgeDisabled)
        {
            // First nudge of the game
            if (nudgeCounter == 0)
            {
                nudgeCounter++;
                firstNudgeTime = Time.time;
                StartCoroutine(ShakeCenter(0.5f, 0.2f));
            }
            else if (nudgeCounter == 1)
            {
                // If previous nudge happened more than 3 seconds ago, replace the first nudge with second nudge
                if ((Time.time - firstNudgeTime) >= 3f)
                {
                    firstNudgeTime = Time.time;
                }
                // Else, add the second nudge and warn the player
                else
                {
                    secondNudgeTime = Time.time;
                    nudgeCounter++;
                    Vector3 rewardPos = new Vector3(0.0f, -3.5f, 0.0f);
                    RewardNotificationsController rewardNotifier = Instantiate(rewardNotificationObj, rewardPos, Quaternion.identity).GetComponentInChildren <RewardNotificationsController>();
                    rewardNotifier.TriggerRewardNotification("Careful!");
                }

                StartCoroutine(ShakeCenter(0.5f, 0.2f));
            }
            else if (nudgeCounter == 2)
            {
                if ((Time.time - firstNudgeTime) < 3f)
                {
                    isNudgeDisabled  = true;
                    nudgeDisableTime = Time.time;
                    nudgeCounter     = 0;
                    firstNudgeTime   = 0f;
                    secondNudgeTime  = 0f;

                    cooldownPanel.SetActive(true);
                }
                else if ((Time.time - firstNudgeTime) >= 3f && (Time.time - secondNudgeTime) < 3f)
                {
                    firstNudgeTime  = secondNudgeTime;
                    secondNudgeTime = 0f;
                    nudgeCounter    = 1;
                }
                else
                {
                    firstNudgeTime  = Time.time;
                    secondNudgeTime = 0f;
                    nudgeCounter    = 1;
                }
                StartCoroutine(ShakeCenter(0.5f, 0.2f));
            }
        }
    }
示例#2
0
    IEnumerator PlayScoreIncrementNotification(int increment)
    {
        textToDisplay.text = ("+" + increment.ToString());
        animator.Play("ScalingIn");
        yield return(new WaitForSeconds(0.5f));

        // Trigger reward notifications
        if (increment > 100)
        {
            string rewardText = "";
            if (increment > 450)
            {
                rewardText = "GODLIKE!";
            }
            else if (increment > 300)
            {
                rewardText = "PERFECT!";
            }
            else if (increment > 150)
            {
                rewardText = "NICE!";
            }
            else if (increment > 100)
            {
                rewardText = "GOOD!";
            }

            Vector3 rewardPos = new Vector3(0.0f, -3.5f, 0.0f);
            RewardNotificationsController rewardNotifier = Instantiate(rewardNotificationObj, rewardPos, Quaternion.identity).GetComponentInChildren <RewardNotificationsController>();
            rewardNotifier.TriggerRewardNotification(rewardText);
        }



        animator.Play("ScalingOut");
        yield return(new WaitForSeconds(0.275f));

        Destroy(transform.parent.parent.gameObject);
    }