Beispiel #1
0
    public IEnumerator CoAnimateFruit(bool newFruit)
    {
        yield return(new WaitForEndOfFrame());

        // Match size of target cell
        rect.sizeDelta = curCellReference.GetAnchoredSize() * 2;

        if (this != null && curCellReference != null)
        {
            // Check how to animate
            if (newFruit)
            {
                // Set attributes
                UpdateSprite();
                UpdatePosition(curCellReference.GetAnchoredPosition());

                // Animate new fruit in
                iTween.ValueTo(gameObject, iTween.Hash(
                                   "from", Vector3.zero,
                                   "to", targetScale,
                                   "time", 0.1f,
                                   "ease", iTween.EaseType.easeOutBounce,
                                   "onupdate", "UpdateScale"
                                   ));
            }
            else
            {
                // Animate existing fruit to position
                iTween.ValueTo(gameObject, iTween.Hash(
                                   "from", rect.anchoredPosition,
                                   "to", curCellReference.GetAnchoredPosition(),
                                   "time", 0.1f,
                                   "ease", iTween.EaseType.easeOutCirc,
                                   "onupdate", "UpdatePosition",
                                   "oncomplete", "AnimateUpgrade"
                                   ));
            }
        }
    }