示例#1
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  ShopView()
        //------------------------------------------------------------------------------------------------------------------------
        public ShopView(ShopController pShopController, Actor pCustomer) : base(340, 340)
        {
            _shopController = pShopController;
            _commandManager = ServiceLocator.Instance.GetService <CommandManager>();
            _items          = new List <Item>();
            _customer       = pCustomer;

            x = (game.width - width) / 2;
            y = (game.height - height) / 2;

            //----------------------------- Create Commands --------------------------------//
            var moveSelectionLeft  = new MoveSelectionCommand(_shopController, this, -1, 0);
            var moveSelectionRight = new MoveSelectionCommand(_shopController, this, 1, 0);
            var moveSelectionUp    = new MoveSelectionCommand(_shopController, this, 0, -1);
            var moveSelectionDown  = new MoveSelectionCommand(_shopController, this, 0, 1);
            var buyItem            = new BuyItemCommand(_shopController, _customer);

            //-------------------------- Add Commands to list ------------------------------//
            _keyCommands = new List <KeyCommand>()
            {
                new KeyCommand((int)Key.LEFT, moveSelectionLeft),
                new KeyCommand((int)Key.RIGHT, moveSelectionRight),
                new KeyCommand((int)Key.UP, moveSelectionUp),
                new KeyCommand((int)Key.DOWN, moveSelectionDown),
                new KeyCommand((int)Key.SPACE, buyItem),
            };
        }
示例#2
0
 void tbY_LostFocus(object sender, EventArgs e)
 {
     if (NeedsCommand((TextBox)sender))
     {
         MoveSelectionCommand command = new MoveSelectionCommand(new Vex.Point(0, newValue - originalValue));
         DoCommand(command);
     }
 }