コード例 #1
0
ファイル: PlayerController.cs プロジェクト: Avatarchik/EPoker
        public override void ShowCardsToPile(PlayerViewModel viewModel)
        {
            base.ShowCardsToPile(viewModel);

            List <CardInfo> cardInfoList = JsonConvert.DeserializeObject <List <CardInfo> > (
                Convert.ToString(Network.Client.CurrentRoom.CustomProperties ["current_cards"])
                );

            // 清除牌堆原有的牌
            CoreGameRoot.Pile.Cards.Clear();

            foreach (CardInfo ci in cardInfoList)
            {
                // 1.查找手牌的这一张
                CardViewModel card = viewModel.HandCards.Where(cardVM => CardInfo.ValueEqual(cardVM.Info, ci)).FirstOrDefault();
                if (card != null)
                {
                    // 1.1.还原一些属性
                    card.ExecuteDeselectCard();
                    card.OwnerActorId = -1;
                    card.Face         = CardFace.FaceUp;

                    // 2.牌堆中加入相同的这一张牌
                    CoreGameRoot.Pile.Cards.Add(card);

                    // 3.删除手牌这一张
                    viewModel.HandCards.Remove(card);
                }
            }

            viewModel.ExecuteReorder();
            CoreGameRoot.Pile.ExecutePileCardsReorder();
        }
コード例 #2
0
ファイル: PlayerController.cs プロジェクト: Avatarchik/EPoker
        public override void AddCards(PlayerViewModel viewModel, AddCardsCommand arg)
        {
            base.AddCards(viewModel, arg);

            foreach (CardInfo ci in arg.CardInfos)
            {
                CardViewModel card = MVVMKernelExtensions.CreateViewModel <CardViewModel> ();
                card.Info = ci;

                if (viewModel.IsSelf)
                {
                    card.Face = CardFace.FaceUp;
                }
                else
                {
                    card.Face = CardFace.FaceDown;
                }

                card.Place        = CardPlace.Floor;
                card.OwnerActorId = viewModel.ActorId;
                viewModel.HandCards.Add(card);
            }

            viewModel.ExecuteReorder();
        }
コード例 #3
0
ファイル: PlayerController.cs プロジェクト: Avatarchik/EPoker
        public override void RemoveCards(PlayerViewModel viewModel, RemoveCardsCommand arg)
        {
            base.RemoveCards(viewModel, arg);
            foreach (CardInfo ci in arg.CardInfos)
            {
                CardViewModel card = viewModel.HandCards.FirstOrDefault(cardVM => CardInfo.ValueEqual(cardVM.Info, ci));
                viewModel.HandCards.Remove(card);
            }

            viewModel.ExecuteReorder();
        }