Пример #1
0
 public void RemoveItem(Item item)
 {
     if (item == outputItem)
     {
         // Removed output item
         ConsumeRecipeItems();
         CreateOutput();
         OnGridChanged?.Invoke(this, EventArgs.Empty);
     }
     else
     {
         // Removed item from grid
         for (int x = 0; x < GRID_SIZE; x++)
         {
             for (int y = 0; y < GRID_SIZE; y++)
             {
                 if (GetItem(x, y) == item)
                 {
                     // Removed this one
                     RemoveItem(x, y);
                 }
             }
         }
     }
 }
Пример #2
0
 public void SetItem(Item item, int x, int y)
 {
     if (item != null)
     {
         item.RemoveFromItemHolder();
         item.SetItemHolder(this);
     }
     itemArray[x, y] = item;
     CreateOutput();
     OnGridChanged?.Invoke(this, EventArgs.Empty);
 }
Пример #3
0
 public void DecreaseItemAmount(int x, int y)
 {
     if (GetItem(x, y) != null)
     {
         GetItem(x, y).amount--;
         if (GetItem(x, y).amount == 0)
         {
             RemoveItem(x, y);
         }
         OnGridChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #4
0
        private void GridChanged()
        {
            _isSaveDirty = true;
            OnGridChanged?.Invoke();

            if (_grid is not null && _grid.IsSudokuSolved())
            {
                _gameTimerManager.StopTimer();
                if (CurrentModalState == ModalState.None)
                {
                    SetModalState(ModalState.EndGame);
                }
            }
        }
Пример #5
0
 public void IncreaseItemAmount(int x, int y)
 {
     GetItem(x, y).amount++;
     OnGridChanged?.Invoke(this, EventArgs.Empty);
 }
Пример #6
0
 public GridListener(OnGridChanged onGridChanged)
 {
     this.ActionOnGridChange = onGridChanged;
 }