Esempio n. 1
0
        /// <summary>
        /// 隐藏牌,有过程
        /// </summary>
        /// <param name="poker">要隐藏的牌</param>
        /// <param name="to">目标位置</param>
        /// <param name="onFinish">结束时回掉方法</param>
        public void HidePokerWithAnim(GameObject poker, Transform to = null, Action onFinish = null)
        {
            if (poker == null)
            {
                return;
            }

            PokerCard pCard = poker.GetComponent <PokerCard>();

            pCard.SetCardId(0);
            pCard.SetCardFront();

            if (to == null)
            {
                to = HideTran;
            }

            poker.transform.parent = to.transform;

            SpringPosition sp = poker.GetComponent <SpringPosition>();

            sp.target  = Vector3.zero;
            sp.enabled = true;



            TweenAlpha ta = poker.GetComponent <TweenAlpha>();

            ta.from     = 1;
            ta.to       = 0;
            ta.duration = _runTime;
            ta.ResetToBeginning();
            ta.PlayForward();
            ta.AddOnFinished(onFinish != null
                ? new EventDelegate(() => { onFinish(); })
                : new EventDelegate(() => { Destroy(poker); }));


            TweenRotation tr = poker.GetComponent <TweenRotation>();

            tr.from     = new Vector3(0, 0, -4);
            tr.to       = Vector3.zero;
            tr.duration = _runTime;
            tr.ResetToBeginning();
            tr.PlayForward();

            TweenScale ts = poker.GetComponent <TweenScale>();

            ts.from = poker.transform.localScale;
            ts.to   = Vector3.one * 0.3f;
            ts.ResetToBeginning();
            ts.PlayForward();
        }
Esempio n. 2
0
        /// <summary>
        /// 发一张牌,无过程
        /// </summary>
        /// <param name="to">目标位置</param>
        /// <param name="card">牌的数值</param>
        /// <param name="depth">牌的层级</param>
        void DealOnePokerNoAnim(Transform to, int card, int depth)
        {
            GameObject gob = Instantiate(PokerPrefab);

            _pokerList.Add(gob);

            gob.transform.parent        = to.transform;
            gob.transform.localScale    = Vector3.one;
            gob.transform.localPosition = Vector3.zero;

            PokerCard pCard = gob.GetComponent <PokerCard>();

            pCard.SetCardId(card);
            pCard.SetCardFront();
            pCard.SetCardDepth(100 + depth);

            to.gameObject.GetComponentInParent <UIGrid>().Reposition();
        }