예제 #1
0
        public PlayGameScreen(Game game) : base()
        {
            mGame = game;

            Controls.Add(new StatsControl(mGame.Hero, new Rect(0, 0, 14, 31)));
            mOverheadControl = new OverheadControl(mGame, new Rect(15, 1, 50, 30));
            Controls.Add(mOverheadControl);
            Controls.Add(new StatusControl(mGame, new Rect(15, 31, 50, 1)));

            // top single-line log
            Controls.Add(new LogControl(mGame.Log, new Rect(15, 0, 50, 1)));

            // main log
            Controls.Add(new LogControl(mGame.Log, new Rect(0, 32, 65, 17)));
            Controls.Add(new InventoryControl(mGame, new Rect(66, 0, 54, 21), this));
            Controls.Add(new DescriptionControl(mGame, new Rect(66, 32, 54, 17)));
            Controls.Add(new StatusBar());
            Controls.Add(new PlayerInputControl(mGame));

            mYesNoPrompt         = new PromptYesNoBar("Save and quit the game?");
            mYesNoPrompt.Visible = false;
            Controls.Add(mYesNoPrompt);

            mDirectionPrompt         = new PromptDirectionBar("Close the door in which direction?");
            mDirectionPrompt.Visible = false;
            Controls.Add(mDirectionPrompt);

            mTargetPrompt         = new PromptTargetBar(mOverheadControl);
            mTargetPrompt.Visible = false;
            Controls.Add(mTargetPrompt);

            ListenTo(mGame.StoreEntered, Game_StoreEntered);
        }
예제 #2
0
        public void Sell(NotNull <Item> item, NotNull <Store> store)
        {
            int quantity = PromptForItemQuantity(item, item.Value.Quantity, item.Value.Quantity);
            int price    = store.Value.GetSellPrice(mGame.Hero, item);

            if (quantity != 0)
            {
                // confirm the purchase
                PromptYesNoBar prompt = new PromptYesNoBar("Sell " + item.Value.ToString(quantity, ItemStringOptions.ShowQuantity) + " for " + (price * quantity) + "?");
                Controls.Add(prompt);
                bool sell = prompt.Read(true, false);
                Controls.Remove(prompt);

                if (sell)
                {
                    mGame.Hero.SetNextAction(new SellAction(mGame.Hero, item, quantity, price, store));

                    ProcessGame();
                }
            }
        }
예제 #3
0
        public void Buy(NotNull <Item> item, NotNull <Store> store)
        {
            int price = store.Value.GetBuyPrice(mGame.Hero, item);

            // ask how many to buy
            int maxAffordable = mGame.Hero.Currency / price;
            int quantity      = PromptForItemQuantity(item, 1, Math.Min(item.Value.Quantity, maxAffordable));

            if (quantity != 0)
            {
                // confirm the purchase
                PromptYesNoBar prompt = new PromptYesNoBar("Buy " + item.Value.ToString(quantity, ItemStringOptions.ShowQuantity) + " for " + (price * quantity) + "?");
                Controls.Add(prompt);
                bool buy = prompt.Read(true, false);
                Controls.Remove(prompt);

                if (buy)
                {
                    mGame.Hero.SetNextAction(new BuyAction(mGame.Hero, item, quantity, store));

                    ProcessGame();
                }
            }
        }