示例#1
0
    public void TakeItem(OptButton btn)
    {
        if (character == InventoryView.instance.currentCharacter)
        {
            return;
        }

        if (ItemSlot.currentlyDraggingSlot != null)
        {
            NoTakeItemReason reason = GetNoTakeItemReason();
            switch (reason)
            {
            case NoTakeItemReason.GIVER_NO_INTERACTION:
                Debug.LogError("Giver needs interaction!");
                break;

            case NoTakeItemReason.TAKER_NO_INTERACTION:
                Debug.LogError("TAKER needs interaction!");
                break;

            case NoTakeItemReason.TAKER_NO_ROOM:
                Debug.LogError("TAKER has no room left!");
                break;

            case NoTakeItemReason.GIVER_OR_TAKER_NOT_ACTING:
                Debug.LogError("Giver or taker must be acting.");
                break;

            case NoTakeItemReason.OUT_OF_RANGE:
                Debug.LogError("Giver and taker must be within " + GiveItem.GIVE_DISTANCE + " squares of each other.");
                break;

            case NoTakeItemReason.NO_REASON__CAN_TAKE:
                Debug.Log("You may add, my son!");

                //do action
                if (InventoryView.instance.IsBattleMode)
                {
                    GiveItem act = GiveAndTakeAction();
                    act.Perform();
                }
                else
                {
                    character.inventory.AddItem(ItemSlot.currentlyDraggingSlot.GiveUpItem());
                }


                InventoryView.instance.RefreshUi();
                break;

            default:
                break;
            }
        }
    }
示例#2
0
    private void IndicateDroppableness(OptButton btn)
    {
        Debug.Log("this! " + name);
        if (character == InventoryView.instance.currentCharacter)
        {
            return;
        }

        if (ItemSlot.currentlyDraggingSlot != null)
        {
            NoTakeItemReason reason = GetNoTakeItemReason();
            string           tooltipText;
            switch (reason)
            {
            case NoTakeItemReason.GIVER_OR_TAKER_NOT_ACTING:
                tooltipText = "One of the characters involved in a trade\nneeds to be currently acting.";
                break;

            case NoTakeItemReason.GIVER_NO_INTERACTION:
                tooltipText = "You have no action or interaction left";
                break;

            case NoTakeItemReason.TAKER_NO_INTERACTION:
                tooltipText = "The receiver of this item no action or interaction left";
                break;

            case NoTakeItemReason.TAKER_NO_ROOM:
                tooltipText = "The receiver of this item has no inventory room";
                break;

            case NoTakeItemReason.OUT_OF_RANGE:
                tooltipText = "The two characters need to be within " + GiveItem.GIVE_DISTANCE + " of each other.";
                break;

            case NoTakeItemReason.NO_REASON__CAN_TAKE:
                string giverActionType = "interaction";
                string takerActionType = "interaction";
                if (GiverInDrop.UsedInteraction())
                {
                    giverActionType = "action";
                }
                if (TakerInDrop.UsedInteraction())
                {
                    takerActionType = "action";
                }
                tooltipText = "This will cost the following actions this round:\n" +
                              InventoryView.instance.currentCharacter.Name + ": " + giverActionType + "\n"
                              + character.Name + ": " + takerActionType;

                break;

            default:
                tooltipText = "ERROR";
                break;
            }

            if (InventoryView.instance.IsBattleMode)
            {
                UIManager.instance.Tooltip.SetText(tooltipText);
            }
            else
            {
                if (reason == NoTakeItemReason.NO_REASON__CAN_TAKE)
                {
                    UIManager.instance.Tooltip.SetText("Drop to give item");
                }
                else
                {
                    UIManager.instance.Tooltip.SetText(tooltipText);
                }
            }

            UIManager.instance.Tooltip.Show(transform as RectTransform, Tooltip.TooltipPosition.RIGHT);
        }
    }