コード例 #1
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  HandleNavigation()
        //------------------------------------------------------------------------------------------------------------------------
        private void HandleNavigation()
        {
            if (Input.GetKeyDown(Key.LEFT))
            {
                MoveSelection(-1, 0);
            }
            if (Input.GetKeyDown(Key.RIGHT))
            {
                MoveSelection(1, 0);
            }
            if (Input.GetKeyDown(Key.UP))
            {
                MoveSelection(0, -1);
            }
            if (Input.GetKeyDown(Key.DOWN))
            {
                MoveSelection(0, 1);
            }

            if (Input.GetKeyDown(Key.SPACE))
            {
                shopController.Buy();
            }
            if (Input.GetKeyDown(Key.BACKSPACE))
            {
                shopController.Sell();
            }
        }
コード例 #2
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                  InitializeButtons()
 //------------------------------------------------------------------------------------------------------------------------
 //This method adds a listener to the 'Buy' and 'Sell' button. They are forwarded to the controller to the shop.
 private void InitializeButtons()
 {
     buyButton.onClick.AddListener(
         delegate {
         shopController.Buy();
         RepopulateItemIconView();     //we need an Event system instead of this
     }
         );
     sellButton.onClick.AddListener(
         delegate {
         shopController.Sell();
         RepopulateItemIconView();     //we need an Event system instead of this
     }
         );
 }