Esempio n. 1
0
 public void ReleaseAnimation()
 {
     if (CandyAnimator != null)
     {
         CandyBAPool.Enqueue(CandyAnimator.gameObject);
         CandyAnimator = null;
     }
     if (CandySpriteRenderer != null)
     {
         Destroy(CandySpriteRenderer.gameObject);
         CandySpriteRenderer = null;
     }
 }
Esempio n. 2
0
        public void Refresh()
        {
            //调整大小
            var stdSize = Mathf.Max(7, Grid.MaxSide);

// ReSharper disable PossibleLossOfFraction
            transform.localScale = new Vector3(100 * 8 / stdSize, 100 * 8 / stdSize, 1);
// ReSharper restore PossibleLossOfFraction

            if (_curShownGenre != Genre)
            {
                if (ArtContent != null)
                {
                    if (CandyAnimator)
                    {
                        CandyBAPool.Enqueue(CandyAnimator.gameObject);
                    }
                    else
                    {
                        Destroy(ArtContent);
                    }
                    ArtContent = null;
                }

                _curShownGenre = Genre;
            }

            if (ArtContent == null)
            {
                var go = CandyBAPool.Dequeue(Info);
                go.transform.parent = transform;
                go.transform.ResetTransform();
                ArtContent          = go;
                CandyAnimator       = go.GetComponent <Animator>();
                CandySpriteRenderer = go.GetComponent <SpriteRenderer>();
            }

            if (CandyAnimator != null)
            {
                Reset();

                if (Genre >= 0)
                {
                    if (Info.Type == Candy.CandyType.H)
                    {
                        CandyAnimator.SetTrigger("BecomeH");
                    }
                    else if (Info.Type == Candy.CandyType.V)
                    {
                        CandyAnimator.SetTrigger("BecomeV");
                    }
                    else if (Info.Type == Candy.CandyType.Bomb)
                    {
                        if (Candy.Fired)
                        {
                            CandyAnimator.SetTrigger("BecomeFiredBomb");
                        }
                        else
                        {
                            CandyAnimator.SetTrigger("BecomeBomb");
                        }
                    }
                }
            }

            if (CandySpriteRenderer)//如果是Item,则要更换Sprite
            {
                CandySpriteRenderer.sprite = CandyBAPool.GetSpriteForCandy(Info);
            }

            SetNextBlinkTime();
        }