Exemple #1
0
    public void CreateTextReward()
    {
        Vector2    pos           = GetRandomPosition();
        GameObject newTextReward = Instantiate(muffinTextReward, myRectTransform);

        newTextReward.transform.localPosition = pos;

        MuffinRewardAnimationInfo animInfo = new MuffinRewardAnimationInfo();

        animInfo.transform = newTextReward.GetComponent <RectTransform>();
        animInfo.textField = newTextReward.GetComponent <TMP_Text>();

        animInfo.textField.text = muffinsPerClick.ToString();

        allRewardsInfo.Add(animInfo);
    }
Exemple #2
0
    public bool AnimateRewardInfo(MuffinRewardAnimationInfo info)
    {
        info.elapsedTime += Time.deltaTime;

        info.transform.anchoredPosition += Vector2.up * textAnimationSpeed * Time.deltaTime;

        Color currentColor = info.textField.color;

        currentColor.a       = Mathf.Lerp(1, 0, info.elapsedTime / textRewardDuration);
        info.textField.color = currentColor;

        if (info.elapsedTime <= textRewardDuration)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }