Inheritance: CardViewModel, ICommand
コード例 #1
0
ファイル: PlayerViewBase.cs プロジェクト: kradchen/sgs
        internal virtual void UpdateCards()
        {
            if (PlayerModel == null)
            {
                return;
            }
            PlayerModel.HandCards.Clear();
            PlayerModel.HandCardCount         = 0;
            PlayerModel.WeaponCommand         = null;
            PlayerModel.ArmorCommand          = null;
            PlayerModel.DefensiveHorseCommand = null;
            PlayerModel.OffensiveHorseCommand = null;
            PlayerModel.PrivateDecks.Clear();

            var player = PlayerModel.Player;

            if (player == null)
            {
                return;
            }

            // HandCards
            foreach (var card in player.HandCards())
            {
                PlayerModel.HandCards.Add(new CardViewModel()
                {
                    Card = card
                });
            }
            PlayerModel.HandCardCount = player.HandCards().Count;

            // Equipment
            foreach (var card in player.Equipments())
            {
                Equipment equip = card.Type as Equipment;

                if (equip != null)
                {
                    EquipCommand command = new EquipCommand()
                    {
                        Card = card
                    };
                    switch (equip.Category)
                    {
                    case CardCategory.Weapon:
                        PlayerModel.WeaponCommand = command;
                        break;

                    case CardCategory.Armor:
                        PlayerModel.ArmorCommand = command;
                        break;

                    case CardCategory.DefensiveHorse:
                        PlayerModel.DefensiveHorseCommand = command;
                        break;

                    case CardCategory.OffensiveHorse:
                        PlayerModel.OffensiveHorseCommand = command;
                        break;
                    }
                }
            }

            // Private Decks
            var decks = Game.CurrentGame.Decks.GetPlayerPrivateDecks(player);

            foreach (var deck in decks)
            {
                var deckModel = new SpecialDeckViewModel()
                {
                    DeckPlace = new DeckPlace(player, deck)
                };

                PlayerModel.PrivateDecks.Add(deckModel);
                var cards = Game.CurrentGame.Decks[player, deck];
                foreach (var card in cards)
                {
                    deckModel.Cards.Add(new CardViewModel()
                    {
                        Card = card
                    });
                }
            }
        }
コード例 #2
0
ファイル: PlayerViewBase.cs プロジェクト: pxoylngx/sgs
        public void AddCards(DeckType deck, IList<CardView> cards, bool isFaked)
        {
            foreach (CardView card in cards)
            {
                card.CardModel.IsEnabled = false;
            }
            if (deck == DeckType.Hand)
            {
                AddHandCards(cards, isFaked);
                foreach (var card in cards)
                {
                    PlayerModel.HandCards.Add(card.CardModel);
                }
                PlayerModel.HandCardCount += cards.Count;
            }
            else if (deck == DeckType.Equipment)
            {
                foreach (var card in cards)
                {
                    Equipment equip = card.Card.Type as Equipment;

                    if (equip != null)
                    {
                        EquipCommand command = new EquipCommand(){ Card = card.Card };
                        switch(equip.Category)
                        {
                            case CardCategory.Weapon:
                                PlayerModel.WeaponCommand = command;
                                break;
                            case CardCategory.Armor:
                                PlayerModel.ArmorCommand = command;
                                break;
                            case CardCategory.DefensiveHorse:
                                PlayerModel.DefensiveHorseCommand = command;
                                break;
                            case CardCategory.OffensiveHorse:
                                PlayerModel.OffensiveHorseCommand = command;
                                break;
                        }
                    }
                    AddEquipment(card, isFaked);
                }
            }
            else if (deck == DeckType.DelayedTools)
            {
                foreach (var card in cards)
                {
                    AddDelayedTool(card, isFaked);
                }
            }
            else if (deck == RoleGame.RoleDeckType)
            {
                foreach (var card in cards)
                {
                    AddRoleCard(card, isFaked);
                }
            }
            else if (deck is PrivateDeckType)
            {
                var deckModel = PlayerModel.PrivateDecks.FirstOrDefault(d => d.Name == deck.Name);
                if (deckModel == null)
                {
                    deckModel = new PrivateDeckViewModel();
                    deckModel.Name = deck.Name;
                    PlayerModel.PrivateDecks.Add(deckModel);
                }
                foreach (var card in cards)
                {
                    deckModel.Cards.Add(card.CardModel);
                }
                AddPrivateCards(cards, isFaked);
            }
        }
コード例 #3
0
ファイル: PlayerViewBase.cs プロジェクト: kradchen/sgs
        public void AddCards(DeckType deck, IList <CardView> cards, bool isFaked)
        {
            foreach (CardView card in cards)
            {
                card.CardModel.IsEnabled = false;
            }
            if (deck == DeckType.Hand)
            {
                foreach (var card in cards)
                {
                    PlayerModel.HandCards.Add(card.CardModel);
                }
                PlayerModel.HandCardCount += cards.Count;
                AddHandCards(cards, isFaked);
            }
            else if (deck == DeckType.Equipment)
            {
                foreach (var card in cards)
                {
                    Equipment equip = card.Card.Type as Equipment;

                    if (equip != null)
                    {
                        EquipCommand command = new EquipCommand()
                        {
                            Card = card.Card
                        };
                        switch (equip.Category)
                        {
                        case CardCategory.Weapon:
                            PlayerModel.WeaponCommand = command;
                            break;

                        case CardCategory.Armor:
                            PlayerModel.ArmorCommand = command;
                            break;

                        case CardCategory.DefensiveHorse:
                            PlayerModel.DefensiveHorseCommand = command;
                            break;

                        case CardCategory.OffensiveHorse:
                            PlayerModel.OffensiveHorseCommand = command;
                            break;
                        }
                    }
                    AddEquipment(card, isFaked);
                }
            }
            else if (deck == DeckType.DelayedTools)
            {
                foreach (var card in cards)
                {
                    AddDelayedTool(card, isFaked);
                }
            }
            else if (deck == RoleGame.RoleDeckType)
            {
                foreach (var card in cards)
                {
                    AddRoleCard(card, isFaked);
                }
            }
            else if (deck is PrivateDeckType)
            {
                var deckModel = PlayerModel.PrivateDecks.FirstOrDefault(d => d.DeckPlace.DeckType == deck);
                if (deckModel == null)
                {
                    deckModel           = new SpecialDeckViewModel();
                    deckModel.DeckPlace = new DeckPlace(PlayerModel.Player, deck);
                    PlayerModel.PrivateDecks.Add(deckModel);
                }
                foreach (var card in cards)
                {
                    deckModel.Cards.Add(card.CardModel);
                }

                AddPrivateCards(cards, isFaked);
            }
            else
            {
                foreach (var card in cards)
                {
                    card.Disappear(isFaked ? 0d : 0.5d);
                }
            }
        }
コード例 #4
0
        internal virtual void UpdateCards()
        {
            if (PlayerModel == null) return;
            PlayerModel.HandCards.Clear();
            PlayerModel.HandCardCount = 0;
            PlayerModel.WeaponCommand = null;
            PlayerModel.ArmorCommand = null;
            PlayerModel.DefensiveHorseCommand = null;
            PlayerModel.OffensiveHorseCommand = null;
            PlayerModel.PrivateDecks.Clear();

            var player = PlayerModel.Player;
            if (player == null) return;

            // HandCards
            foreach (var card in player.HandCards())
            {
                PlayerModel.HandCards.Add(new CardViewModel() { Card = card });
            }
            PlayerModel.HandCardCount = player.HandCards().Count;

            // Equipment
            foreach (var card in player.Equipments())
            {
                Equipment equip = card.Type as Equipment;

                if (equip != null)
                {
                    EquipCommand command = new EquipCommand() { Card = card };
                    switch (equip.Category)
                    {
                        case CardCategory.Weapon:
                            PlayerModel.WeaponCommand = command;
                            break;
                        case CardCategory.Armor:
                            PlayerModel.ArmorCommand = command;
                            break;
                        case CardCategory.DefensiveHorse:
                            PlayerModel.DefensiveHorseCommand = command;
                            break;
                        case CardCategory.OffensiveHorse:
                            PlayerModel.OffensiveHorseCommand = command;
                            break;
                    }
                }
            }

            // Private Decks
            var decks = Game.CurrentGame.Decks.GetPlayerPrivateDecks(player);
            foreach (var deck in decks)
            {
                var deckModel = new SpecialDeckViewModel()
                {
                    DeckPlace = new DeckPlace(player, deck)
                };

                PlayerModel.PrivateDecks.Add(deckModel);
                var cards = Game.CurrentGame.Decks[player, deck];
                foreach (var card in cards)
                {
                    deckModel.Cards.Add(new CardViewModel() { Card = card });
                }
            }
        }