private void FinishLift() { _lifting = false; Destroy(_clonedLiftedItem.gameObject); _clonedLiftedItem = null; _originalLiftedItem._canvasGroup.alpha = 1; _originalLiftedItem = null; }
public void HandleRightClick(ItemInstanceView item) { if (!_lifting && !item.IsEmpty) { Lift(item, true); } else if (_lifting) { OnCancel(); } }
public void HandleClick(ItemInstanceView item) { if (_singleMode && _lifting) { return; } else if (!_lifting && !item.IsEmpty) { Lift(item); } else if (_lifting && item == _originalLiftedItem) { OnCancel(); } else if (_lifting) { OnTryLiftEnd(item); } }
public void Lift(ItemInstanceView original, bool half = false) { _originalLiftedItem = original; _clonedLiftedItem = Instantiate(_originalLiftedItem).GetComponent <ItemInstanceView>(); _clonedLiftedItem._canvasGroup.blocksRaycasts = false; _clonedLiftedItem._canvasGroup.interactable = false; _clonedLiftedItem.SetItem(new ItemInstance(_originalLiftedItem.Item)); var clonedRect = _clonedLiftedItem.GetComponent <RectTransform>(); clonedRect.sizeDelta = new Vector2(64, 64); // todo; hacky clonedRect.pivot = Vector2.one / 2f; int amount = _originalLiftedItem.Item.Quantity.Value; if (_singleMode) { amount = 1; } else if (half) { amount = Mathf.Max(1, _originalLiftedItem.Item.Quantity.Value / 2); } Lift(amount); original._canvasGroup.alpha = 0.33f; _clonedLiftedItem.transform.SetParent(_mainCanvas); _clonedLiftedItem.transform.localScale = Vector3.one; var rect = _clonedLiftedItem.transform as RectTransform; rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); MoveRectToMouse(rect); _lifting = true; Observable.EveryUpdate().TakeWhile((x) => _lifting).Subscribe(x => { MoveRectToMouse(rect); }); }