コード例 #1
0
ファイル: DealPokerMgr.cs プロジェクト: da1fanshu/yizhe
        /// <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);
        }
コード例 #2
0
ファイル: DealPokerMgr.cs プロジェクト: da1fanshu/yizhe
        /// <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();
        }