Esempio n. 1
0
        private void PurchaseCard(BaseObject clickedObject)
        {
            // The clicked object has the card data stored (this is set up by the CardGridControl)
            Debug.Assert(clickedObject is Card);
            CardData cardData = (clickedObject as Card).CardData;

            Debug.Assert(PlayerMoney >= cardData.Price);
            PlayerMoney -= cardData.Price;

            PlayerDataRegistry.Instance.PlayerData.CardDataAssets.Add(CentralCardRegistry.FindCardDataAsset(cardData));
            Debug.Fail("Add UI for cards we already own/don't own");

            RefreshUI();
        }
Esempio n. 2
0
        /// <summary>
        /// A click callback when we click on a pack.
        /// Opens the pack and populates our screen with cards
        /// </summary>
        /// <param name="baseObject"></param>
        private void OnPackLeftClicked(BaseObject baseObject)
        {
            // Remove any previous cards from packs we have opened
            foreach (Card card in CardsFromPack)
            {
                card.Die();
            }

            // Clear our previous packs from the reference list
            CardsFromPack.Clear();

            // Remove the image in the grid control
            baseObject.Die();

            // Remove an available pack from our player
            PlayerDataRegistry.Instance.PlayerData.AvailablePacksToOpen--;

            // Pick random cards from the registry
            List <CardData> cardData = CentralCardRegistry.PickCardsForPackOpening();

            Debug.Assert(cardData.Count == CentralCardRegistry.PackSize);

            // Add cards to our screen to show these new cards
            for (int i = 0; i < cardData.Count; i++)
            {
                // Position the cards incrementally along the screen and halfway between the top of the grid control and the top of the screen
                // CreateCard calls LoadContent and Initialise
                Card card = AddScreenUIObject(cardData[i].CreateCard(null));
                card.LocalPosition = new Vector2(300 * (i + 1), (PacksGridControl.WorldPosition.Y - PacksGridControl.Size.Y * 0.5f) * 0.5f);
                card.ClickableModule.OnLeftClicked += OnCardLeftClicked;
                card.Flip(CardFlipState.kFaceDown);         // Make sure the card is face down initially, so we have the excitement of turning it over!
                card.StoredObject = PlayerDataRegistry.Instance.PlayerData.CardDataAssets.Contains(CentralCardRegistry.FindCardDataAsset(cardData[i]));
                card.HandAnimationModule.OffsetToHighlightedPosition = Vector2.Zero;

                CardsFromPack.Add(card);
            }

            // Add the newly unlocked cards to the Player's card registry
            PlayerDataRegistry.Instance.PlayerData.CardDataAssets.AddRange(CentralCardRegistry.ConvertToAssetList(cardData));

            // Stop our grid control from accepting input
            PacksGridControl.ShouldHandleInput = false;
        }