Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------[]
        public void SortItems()
        {
            var inventoryCells = new InventoryCell[_width, _height];

            for (int i = 0; i < _width; i++)
            {
                for (int j = 0; j < _height; j++)
                {
                    inventoryCells[i, j] = new InventoryCell(i, j);
                }
            }

            var items = new List <IItem>();

            items.AddRange(_inventoryItemsList.Where(t => t.Size == 4));
            items.AddRange(_inventoryItemsList.Where(t => t.Width == 2 && t.Height == 1));
            items.AddRange(_inventoryItemsList.Where(t => t.Width == 1 && t.Height == 2));
            items.AddRange(_inventoryItemsList.Where(t => t.Size == 1));

            SortItemsSimpleAlgorithm(items, inventoryCells);

            _inventoryCellsAfterSort = inventoryCells;

            if (OnSortItems != null)
            {
                OnSortItems();
            }

            _inventoryCells = _inventoryCellsAfterSort;
        }
Exemplo n.º 2
0
        //===============================================================================================[]
        #endregion



        #region Routines
        //===============================================================================================[]
        private void FillInventoryCells(
            int width,
            int height)
        {
            _inventoryCells = new InventoryCell[width, height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    _inventoryCells[i, j] = new InventoryCell(i, j);
                }
            }
        }