Пример #1
0
 public void Update()
 {
     if (KeyMouseReader.KeyPressed(Keys.Space))
     {
         Item redItem  = (ItemDatabase.items[1]);;
         bool breakOut = false;
         for (int i = 0; i < xNumberOfSlots; i++)
         {
             for (int j = 0; j < yNumberOfSlots; j++)
             {
                 if (invSlot[i, j].InventoryFull == false)
                 {
                     invSlot[i, j].Item          = redItem;
                     invSlot[i, j].InventoryFull = true;
                     breakOut = true;
                     break;
                 }
             }
             if (breakOut == true)
             {
                 break;
             }
         }
     }
     if (KeyMouseReader.LeftClick())
     {
         if (ItemInHand != true)
         {
             for (int i = 0; i < xNumberOfSlots; i++)
             {
                 for (int j = 0; j < yNumberOfSlots; j++)
                 {
                     if (new Rectangle(invSlot[i, j].GraphicLocationX, invSlot[i, j].GraphicLocationY, 64, 64).Contains(KeyMouseReader.mouseState.Position))
                     {
                         if (invSlot[i, j].Item == null)
                         {
                             break;
                         }
                         itemInHand         = inPlayerHand.Item;
                         inPlayerHand.Item  = invSlot[i, j].Item;
                         invSlot[i, j].Item = itemInHand;
                         ItemInHand         = true;
                         if (invSlot[i, j].Item == null)
                         {
                             invSlot[i, j].InventoryFull = false;
                         }
                         else
                         {
                             invSlot[i, j].InventoryFull = true;
                         }
                         break;
                     }
                 }
             }
         }
         else
         {
             for (int i = 0; i < xNumberOfSlots; i++)
             {
                 for (int j = 0; j < yNumberOfSlots; j++)
                 {
                     if (new Rectangle(invSlot[i, j].GraphicLocationX, invSlot[i, j].GraphicLocationY, 64, 64).Contains(KeyMouseReader.mouseState.Position))
                     {
                         itemInHand         = inPlayerHand.Item;
                         inPlayerHand.Item  = invSlot[i, j].Item;
                         invSlot[i, j].Item = itemInHand;
                         if (inPlayerHand.Item == null)
                         {
                             ItemInHand = false;
                         }
                         if (invSlot[i, j].Item == null)
                         {
                             invSlot[i, j].InventoryFull = false;
                         }
                         else
                         {
                             invSlot[i, j].InventoryFull = true;
                         }
                     }
                 }
             }
         }
     }
 }