Beispiel #1
0
 public bool containsItem(InventoryItem [,] i, InventoryItem it)
 {
     foreach(InventoryItem itt in i)
     {
         if(it.Equals(itt))
         {
             return true;
         }
     }
     return false;
 }
Beispiel #2
0
 public bool containsItem(InventoryItem [,] i, InventoryItem it)
 {
     foreach (InventoryItem itt in i)
     {
         if (it.Equals(itt))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
        /*
         * public bool addItemFromBox(InventoryItem i)
         * {
         *  for (int x = 0; x < items.GetLength(0); x++)
         *  {
         *      for (int y = 0; y < items.GetLength(1); y++)
         *      {
         *          Vector2 itemCenter = i.getCenter();
         *          itemCenter.X -= this.x;
         *          itemCenter.Y -= this.y;
         *
         *          if (itemRectangles[x, y].Contains(itemCenter) && (items[x, y] == null || (items[x, y] != null && !items[x, y].Equals(i))))
         *          {
         *              if (items[x, y] == null)
         *              {
         *                  items[x, y] = i;
         *                  i.setX(itemRectangles[x, y].X);
         *                  i.setY(itemRectangles[x, y].Y);
         *                  return true;
         *              }
         *              else
         *              {
         *              }
         *
         *          }
         *      }
         *  }
         *  return false;
         *
         * }*/

        public void removeItem(InventoryItem i)
        {
            for (int x = 0; x < items.GetLength(0); x++)
            {
                for (int y = 0; y < items.GetLength(1); y++)
                {
                    if (i.Equals(items[x, y]))
                    {
                        items[x, y] = null;
                        return;
                    }
                }
            }
        }
Beispiel #4
0
 public void returnItemToSlot(InventoryItem i)
 {
     for (int x = 0; x < items.GetLength(0); x++)
     {
         for (int y = 0; y < items.GetLength(1); y++)
         {
             if (i.Equals(items[x, y]))
             {
                 i.setX(itemRectangles[x, y].X);
                 i.setY(itemRectangles[x, y].Y);
                 return;
             }
         }
     }
 }
Beispiel #5
0
 public void returnItemToSlot(InventoryItem i)
 {
     for (int x = 0; x < items.GetLength(0); x++)
     {
         for (int y = 0; y < items.GetLength(1); y++)
         {
             if (i.Equals(items[x, y]))
             {
                 i.setX(itemRectangles[x, y].X);
                 i.setY(itemRectangles[x, y].Y);
                 return;
             }
         }
     }
 }
Beispiel #6
0
        /*
        public bool addItemFromBox(InventoryItem i)
        {
            for (int x = 0; x < items.GetLength(0); x++)
            {
                for (int y = 0; y < items.GetLength(1); y++)
                {
                    Vector2 itemCenter = i.getCenter();
                    itemCenter.X -= this.x;
                    itemCenter.Y -= this.y;

                    if (itemRectangles[x, y].Contains(itemCenter) && (items[x, y] == null || (items[x, y] != null && !items[x, y].Equals(i))))
                    {
                        if (items[x, y] == null)
                        {
                            items[x, y] = i;
                            i.setX(itemRectangles[x, y].X);
                            i.setY(itemRectangles[x, y].Y);
                            return true;
                        }
                        else
                        {
                        }

                    }
                }
            }
            return false;

        }*/
        public void removeItem(InventoryItem i)
        {
            for (int x = 0; x < items.GetLength(0); x++)
            {
                for (int y = 0; y < items.GetLength(1); y++)
                {
                    if(i.Equals(items[x,y]))
                    {
                        items[x, y] = null;
                        return;
                    }
                }
            }
        }