public override bool OnInteract(PlayerBehaviour player) { ItemBehaviour item = player.PeekItemStack(); if (isEnabled && item != null && disposalCooldownTimer == 0f && definition.IsItemAllowed(item.ItemDefinition)) { disposeItem(player.PopItemStack()); return(true); } return(false); }
private void pushItemToStack(ItemBehaviour item) { if (itemStack.Count >= definition.maxStackItemCount) { return; } item.SetSpriteLayer(Settings.Constant.itemSortingLayer); item.SetSpriteLayerOrder(itemStack.Count + 1); item.transform.SetParent(stackPositionRoot); item.transform.localPosition = item.ItemDefinition.GenerateItemStackPosition(itemStack.Count, true); item.transform.localRotation = item.ItemDefinition.GenerateItemStackRotation(true); itemStack.Push(item); }
private ItemBehaviour removeItemFromStack() { ItemBehaviour item = itemStack.Pop(); if (state == EBehaviourState.FAILING && itemStack.Count < definition.maxStackItemCount) { state = EBehaviourState.OK; pointTimer = 0; animator.SetInteger("state", 0); onStateChange.Invoke(); } return(item); }
public override bool OnInteract(PlayerBehaviour player) { ItemBehaviour item = player.PeekItemStack(); if (isEnabled && state != EBehaviourState.FAILED && itemStack.Count < definition.maxStackItems && item != null && definition.demandItem == item.ItemDefinition) { pushItemToStack(player.PopItemStack()); levelBehaviour.AddScore(1); return(true); } return(false); }
private void pushItemToStack(ItemBehaviour item) { item.SetSpriteLayer(Settings.Constant.itemSortingLayer); item.SetSpriteLayerOrder(itemStack.Count + 1); item.transform.SetParent(stackPositionRoot); item.transform.localPosition = item.ItemDefinition.GenerateItemStackPosition(itemStack.Count, true); item.transform.localRotation = item.ItemDefinition.GenerateItemStackRotation(true); itemStack.Push(item); if (state == EBehaviourState.FAILING) { state = EBehaviourState.OK; animator.SetInteger("state", 0); pointTimer = 0; onStateChange.Invoke(); } if (progressBarBehaviour) { progressBarBehaviour.SetTicks(itemStack.Count); } }
private void disposeItem(ItemBehaviour item) { disposalCooldownTimer = definition.cooldown; OnDisposal.Invoke(); Destroy(item.gameObject); }
private ItemBehaviour popItemFromStack() { ItemBehaviour item = itemStack.Pop(); return(item); }