Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deskId"></param>
        /// <param name="cards"></param>
        /// <param name="action">是否执行发牌动画</param>
        void PutCard(int deskId, string cards, bool action = false)
        {
            Data.Player player = null;
            foreach (var p in Data.Game.Players.Values)
            {
                if (p.DeskId == deskId)
                {
                    player = p;
                }
            }
            if (player == null)
            {
                return;
            }

            List <GImage> cardImgs = new List <GImage>();
            var           cp       = cardPlaces[player.Index];
            var           cpos     = cp.position;
            var           tpos     = cpos; // 记录牌动画的目的点

            foreach (var v in cards.Split('|'))
            {
                if (v == "-")
                {
                    cpos.x += player.DeskId == Data.Game.DeskId ? 40 : 15;
                    continue;
                }

                var    n        = int.Parse(v);
                string cardName = getName(n);
                GImage card     = UIPackage.CreateObject("qipai", cardName).asImage;

                card.position = cpos;
                tpos          = cpos;
                var scale = 1.0f;
                if (player.DeskId == Data.Game.DeskId)
                {
                    cpos.x += 50;
                }
                else
                {
                    cpos.x += 23;
                    scale   = 0.6f;
                }

                if (action)
                {
                    card.position = cardCenterPlace.position;
                    card.TweenMove(new Vector2(tpos.x, tpos.y), 0.3f);
                    card.TweenScale(new Vector2(scale, scale), 0.3f);
                }
                else
                {
                    card.SetScale(scale, scale);
                }


                card.AddRelation(cp, RelationType.Middle_Middle);
                card.AddRelation(cp, RelationType.Center_Center);
                ui.AddChild(card);
                cardImgs.Add(card);
            }

            if (cardsUi.ContainsKey(deskId))
            {
                foreach (var img in cardsUi[deskId])
                {
                    ui.RemoveChild(img);
                }
                cardsUi.Remove(deskId);
            }

            cardsUi.Add(deskId, cardImgs);
        }