コード例 #1
0
ファイル: ShopScreen.cs プロジェクト: AlanWills/SpaceCardGame
        /// <summary>
        /// Updates all of the UI on the screen to adjust for the current state, including Player's money, new cards, invalid options (e.g. buying stuff they can't afford).
        /// </summary>
        private void RefreshUI()
        {
            Money.Label.Text = PlayerMoney.ToString();

            if (PlayerMoney < packPrice)
            {
                BuyPackButton.Disable();
            }

            foreach (CardGridControl gridControl in CardTabControl.TabbedObjects)
            {
                foreach (Card card in gridControl)
                {
                    // If card price is greater than money, turn it grey and disable the click module so we cannot buy it
                    if (card.CardData.Price > PlayerMoney)
                    {
                        card.Colour = Color.Red;
                        card.ClickableModule.Hide();        // This will disable the clicking
                    }
                    else
                    {
                        card.Colour = Color.White;
                        card.ClickableModule.Show();        // Enable the card for clicking
                    }
                }
            }
        }
コード例 #2
0
ファイル: ShopScreen.cs プロジェクト: AlanWills/SpaceCardGame
        protected override void AddInitialUI()
        {
            base.AddInitialUI();

            Label title = AddScreenUIObject(new Label("Shop", new Vector2(ScreenCentre.X, ScreenDimensions.Y * 0.1f)));

            title.Colour = Color.Green;

            Money        = AddScreenUIObject(new ImageAndLabel(PlayerDataRegistry.Instance.PlayerData.CurrentMoney.ToString(), new Vector2(ScreenCentre.X, ScreenDimensions.Y * 0.9f), "UI\\MoneyIcon"));
            Money.Colour = Color.Black;

            BuyPackButton = AddScreenUIObject(new Button("Click to Buy Packs (" + packPrice.ToString() + ")", new Vector2(ScreenDimensions.X * 0.1f, ScreenCentre.Y), Card.CardBackTextureAsset, Card.CardBackTextureAsset));
            BuyPackButton.AddModule(new ToolTipModule("Contains 5 cards, one of which is at least rare."));
            BuyPackButton.ClickableModule.OnLeftClicked += PurchasePack;

            // Add a card tab control for all of the cards registered with the registry
            CardTabControl = AddScreenUIObject(new CardTypesTabControl(CentralCardRegistry.CardData,
                                                                       new Vector2(ScreenDimensions.X * 0.8f, ScreenDimensions.Y * 0.05f),
                                                                       new Vector2(ScreenDimensions.X * 0.8f, ScreenDimensions.Y * 0.7f),
                                                                       new Vector2(ScreenDimensions.X * 0.6f, ScreenDimensions.Y * 0.2f),
                                                                       PurchaseCard));
        }