Esempio n. 1
0
        /// <summary>
        /// 发一张牌,有过程
        /// </summary>
        /// <param name="from">起始位置</param>
        /// <param name="to">目标位置</param>
        /// <param name="index"></param>
        /// <param name="depth">牌层级</param>
        /// <param name="cardId"></param>
        /// <param name="onFinish">动画结束时的执行方法</param>
        /// <returns></returns>
        public GameObject DoDealOnePokerWithAnim(Transform from, Transform to, int index, int depth, int cardId, Action onFinish = null)
        {
            GameObject gob   = Instantiate(PokerPrefab);
            PokerCard  pCard = gob.GetComponent <PokerCard>();

            pCard.SetCardDepth(100 + depth * 2);
            pCard.Index              = index;
            gob.transform.parent     = to;
            gob.transform.position   = from.position;
            gob.transform.localScale = Vector3.one;

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

            sp.target     = to.position;
            sp.enabled    = true;
            sp.onFinished = (() =>
            {
                UIGrid grid = to.GetComponentInParent <UIGrid>();

                if (grid != null)
                {
                    grid.Reposition();
                }

                if (onFinish != null)
                {
                    onFinish();
                }

                //当传入牌值为0时,是牌的背面,所以不翻牌
                if (cardId != 0)
                {
                    pCard.SetCardId(cardId);
                    pCard.TurnCard();
                }
            });


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

            ta.from     = 0.5f;
            ta.to       = 1;
            ta.duration = _runTime;
            ta.ResetToBeginning();
            ta.PlayForward();


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

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

            return(gob);
        }
Esempio n. 2
0
        public void ShowBankerCard0(int cardId)
        {
            PokerCard poker = CardPos0.GetComponentInChildren <PokerCard>();

            CardsId[0] = cardId;

            if (poker != null)
            {
                poker.SetCardId(cardId);
                poker.TurnCard();
            }
        }