コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 private void disposeItem(ItemBehaviour item)
 {
     disposalCooldownTimer = definition.cooldown;
     OnDisposal.Invoke();
     Destroy(item.gameObject);
 }
コード例 #7
0
        private ItemBehaviour popItemFromStack()
        {
            ItemBehaviour item = itemStack.Pop();

            return(item);
        }