Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  MoveSelection()
        //------------------------------------------------------------------------------------------------------------------------
        private void MoveSelection(int moveX, int moveY)
        {
            int itemIndex           = shop.GetSelectedItemIndex();
            int currentSelectionX   = GetColumnByIndex(itemIndex);
            int currentSelectionY   = GetRowByIndex(itemIndex);
            int requestedSelectionX = currentSelectionX + moveX;
            int requestedSelectionY = currentSelectionY + moveY;

            if (requestedSelectionX >= 0 && requestedSelectionX < Columns) //check horizontal boundaries
            {
                int newItemIndex = GetIndexFromGridPosition(requestedSelectionX, requestedSelectionY);
                if (newItemIndex >= 0 && newItemIndex <= shop.GetItemCount()) //check vertical boundaries
                {
                    Item item = shop.GetItemByIndex(newItemIndex);
                    shopController.SelectItem(item);
                }
            }
        }