private void DragManager_OnDragEnded(DraggableItem dItem, DraggableItem newSpawnedItem, int amount) { MouseState m = Mouse.GetState(); DrawGrid = false; if (GlobalBounds.Contains(m.X, m.Y)) { if (newSpawnedItem != null) { OnItemCreated.Invoke(newSpawnedItem); Items.Add(newSpawnedItem); newSpawnedItem.LocalBounds = new Rectangle(0, 0, GridWidth, GridHeight); newSpawnedItem.OnDragStarted += () => DragManager.StartDrag(newSpawnedItem, 1); newSpawnedItem.OnDragEnded += () => DragManager.Drop(); } } if (Items.Contains(dItem) && dItem.Item.CurrentAmount <= 0) { DragManager.Slots[dItem.Parent] = null; dItem.Parent.RemoveChild(dItem); Items.Remove(dItem); OnItemDestroyed.Invoke(dItem); } OnChanged.Invoke(); }
private void OnDestroyingMatchesStateEnter() { var matches = Cells.GetMatches(); if (matches.Count > 0) { foreach (var matchedCell in matches) { OnItemDestroyed?.Invoke(matchedCell.Item.StaticItem); matchedCell.DestroyItem(); } SetState(CellsFieldState.ItemsFalling); return; } SetState(CellsFieldState.Idle); }
public virtual void DeleteItem(PlayerController controller) { OnItemDestroyed?.Invoke(); controller.Inventory.DeleteItem(this); }