/// <summary>
        /// Create our two controls for showing the cards in our deck and that are available to be added
        /// </summary>
        public override void Initialise()
        {
            base.Initialise();

            DeckCardListControl = new CardGridControl(Deck.Cards, deckColumns, new Vector2(Size.X * ratio, Size.Y), new Vector2(Size.X * (0.5f - 0.5f * ratio), 0));
            // Add all the cards in our deck that are of our type
            DeckCardListControl.IncludePredicate = new Predicate <CardData>(x => x.Type == CardType);
            DeckCardListControl.OnRightClicked  += RemoveFromDeck;

            // Do this here because we need to add the IncludePredicate before we initialise the control.
            AddChild(DeckCardListControl, true, true);

            List <CardData> availableCards = CentralCardRegistry.ConvertToDataList(PlayerDataRegistry.Instance.PlayerData.CardDataAssets);

            RegistryCardListControl = new CardGridControl(availableCards, registryColumns, new Vector2(Size.X * (1 - ratio), Size.Y), new Vector2(-ratio * 0.5f * Size.X, 0));
            // Find all cards of our type that are also not in our deck already
            RegistryCardListControl.IncludePredicate = new Predicate <CardData>(x => x.Type == CardType);
            RegistryCardListControl.OnLeftClicked   += AddToDeck;

            // Do this here because we need to add the IncludePredicate before we initialise the control.
            AddChild(RegistryCardListControl, true, true);
        }
Exemple #2
0
        public override void LoadContent()
        {
            CheckShouldLoad();

            foreach (KeyValuePair <string, Dictionary <string, CardData> > cardData in CardData)
            {
                CardGridControl cardGridControl = new CardGridControl(cardData.Value.Values.ToList(), 4, CardGridControlSize, new Vector2(0, CardGridControlSize.Y * 0.5f));
                cardGridControl.Name = cardData.Key;

                if (CardOnLeftClicked != null)
                {
                    cardGridControl.OnLeftClicked += CardOnLeftClicked;
                }
                else
                {
                    // Empty delegate if no click method specified
                    cardGridControl.OnLeftClicked += delegate { };
                }

                AddChild(cardGridControl);
            }

            base.LoadContent();
        }