Exemple #1
0
 public void CreateTiles()
 {
     for (int i = 0; i < invTiles.GetLength(0); i++)
     {
         for (int j = 0; j < invTiles.GetLength(1); j++)
         {
             invTiles[i, j] = new InventoryTile(
                 new Vector2(rectLayer1.X + rectLayer1.Width / 2 - invTileTotalWidth / 2 + invTileLeftMargin * (i + 1) + invTileSize * i, rectLayer1.Y + rectLayer1.Height / 2 - invTileTotalHeight / 2 + invTileTopMargin * (j + 1) + invTileSize * j),
                 invTileSize,
                 pixelInvTile,
                 Spritesheet);
         }
     }
 }
Exemple #2
0
        public virtual void Pickup()
        {
            bool roomAvailable = false;

            for (int i = 0; i < Inventory.invTiles.GetLength(0); i++)
            {
                for (int j = 0; j < Inventory.invTiles.GetLength(1); j++)
                {
                    InventoryTile currentTile = Inventory.invTiles[i, j];

                    if (!currentTile.occupied)
                    {
                        if (verticalTileSlotSize == 2 && j != 7)
                        {
                            if (!Inventory.invTiles[i, j + 1].occupied)
                            {
                                roomAvailable        = true;
                                rectItemInv          = new Rectangle(currentTile.rectangle.X, currentTile.rectangle.Y, Inventory.invTileSize, Inventory.invTileSize * 2 + Inventory.invTileTopMargin);
                                currentTile.occupied = true;
                                Inventory.invTiles[i, j + 1].occupied = true;
                            }
                        }
                        else if (verticalTileSlotSize == 1)
                        {
                            roomAvailable        = true;
                            rectItemInv          = currentTile.rectangle;
                            currentTile.occupied = true;
                        }
                    }
                    if (roomAvailable)
                    {
                        Inventory.invTiles[i, j] = currentTile;
                        break;
                    }
                }
                if (roomAvailable)
                {
                    isInBag = true;
                    break;
                }
            }
        }