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();
            }
        }
Esempio n. 3
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. 4
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();
        }