Ejemplo n.º 1
0
        void Use()
        {
            Debug.Log("A use!");
            print(selectedItem.name);
            print(selectedItem.GetComponent <Image>().sprite.name);
            GameObject itemUsed = GameObject.Find(selectedItem.GetComponent <Image>().sprite.name + "Dialogue");

            print(itemUsed.name);
            StartDialogue(itemUsed.GetComponent <NPC>(), "Use");
            itemUsed = null;
            selectedItem.UpdateItem(null);
        }
Ejemplo n.º 2
0
    private void SwapInfo(UIItem p_dragged)
    {
        // swap the images/amounts around
        Image           image            = GetComponent <Image>();
        Image           draggedImage     = p_dragged.GetComponent <Image>();
        Image           otherGhost       = p_dragged.m_ghost;
        TextMeshProUGUI amount           = GetComponentInChildren <TextMeshProUGUI>();
        TextMeshProUGUI otherAmount      = draggedImage.GetComponentInChildren <TextMeshProUGUI>();
        TextMeshProUGUI otherGhostAmount = p_dragged.m_ghostAmount;

        image.sprite        = draggedImage.sprite;
        draggedImage.sprite = m_ghost.sprite;
        otherGhost.sprite   = draggedImage.sprite;
        m_ghost.sprite      = image.sprite;

        amount.text           = otherAmount.text;
        otherAmount.text      = m_ghostAmount.text;
        m_ghostAmount.text    = otherAmount.text;
        otherGhostAmount.text = otherAmount.text;

        Color otherColor         = draggedImage.color;
        bool  otherAmountEnabled = otherAmount.enabled;

        draggedImage.color  = image.color;
        image.color         = otherColor;
        otherAmount.enabled = amount.enabled;
        amount.enabled      = otherAmountEnabled;

        Item current = m_item;

        m_item           = p_dragged.m_item;
        p_dragged.m_item = current;
    }
Ejemplo n.º 3
0
    public void LoadEmptyItem(UIItem p_uiItem, Item p_item)
    {
        Image image = p_uiItem.GetComponent <Image>();

        p_uiItem.m_item = p_item;
        image.color     = new Color(1, 1, 1, 0);
        p_uiItem.GetComponentInChildren <TextMeshProUGUI>().enabled = false;
    }
Ejemplo n.º 4
0
    public void LoadOutline(UIItem p_uiItem, Item p_item)
    {
        Image           image  = p_uiItem.GetComponent <Image>();
        TextMeshProUGUI amount = p_uiItem.GetComponentInChildren <TextMeshProUGUI>();

        image.sprite = p_item.m_outlineSprite;
        image.color  = new Color(1, 1, 1, 1);
        amount.text  = "";
    }
Ejemplo n.º 5
0
    private void CopyInfo(UIItem p_dragged)
    {
        Image           image        = GetComponent <Image>();
        Image           draggedImage = p_dragged.GetComponent <Image>();
        TextMeshProUGUI amount       = GetComponentInChildren <TextMeshProUGUI>();
        TextMeshProUGUI otherAmount  = draggedImage.GetComponentInChildren <TextMeshProUGUI>();

        image.sprite   = draggedImage.sprite;
        m_ghost.sprite = image.sprite;

        amount.text        = otherAmount.text;
        m_ghostAmount.text = otherAmount.text;

        image.color    = draggedImage.color;
        amount.enabled = otherAmount.enabled;
    }
Ejemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        UIItem item = target as UIItem;


        RectTransform rect     = item.GetComponent <RectTransform>();
        RectTransform root     = rect.root.GetComponent <RectTransform>();
        Vector2       size     = root.sizeDelta;
        Vector2       itemSize = rect.sizeDelta;
        CanvasScaler  cs       = root.GetComponent <CanvasScaler>();

        Bounds bounds = RectTransformUtility.CalculateRelativeRectTransformBounds(root, rect);

        Vector2 center = new Vector2(
            bounds.center.x + cs.referenceResolution.x / 2,
            cs.referenceResolution.y / 2 - bounds.center.y);

        Vector2 pivot = rect.pivot - new Vector2(0.5f, 0.5f);

        pivot.y = -pivot.y;
        center  = center + new Vector2(pivot.x * itemSize.x, pivot.y * itemSize.y);

        center.x = ToFixed(center.x / 2);
        center.y = ToFixed(center.y / 2);

        EditorGUILayout.Vector2Field("position", center);

        EditorGUILayout.Vector2Field("min", new Vector2(
                                         ToFixed((cs.referenceResolution.x / 2 + bounds.min.x) / 2),
                                         ToFixed((cs.referenceResolution.y / 2 - bounds.min.y - itemSize.y) / 2)
                                         ));

        EditorGUILayout.Vector2Field("max", new Vector2(
                                         ToFixed((cs.referenceResolution.x / 2 + bounds.max.x) / 2),
                                         ToFixed((cs.referenceResolution.y / 2 - bounds.max.y + itemSize.y) / 2)
                                         ));



        //if (GUILayout.Button("LookAtOrigin")) {

        //}

        //GUILayout.EndHorizontal();
    }
Ejemplo n.º 7
0
    public override void AcceptModal()
    {
        UIItem toDelete = m_info as UIItem;
        Image  image    = toDelete.GetComponent <Image>();

        if (toDelete == UIItem.HeldItem)
        {
            toDelete.HideHeldItem();
        }

        toDelete.m_item.m_inventory.Remove(toDelete.m_item);
        toDelete.m_item = new Item(toDelete.m_item.m_inventory, toDelete.m_item.m_inventoryIndex);
        image.color     = new Color(255, 255, 255, 0);
        toDelete.GetComponentInChildren <TextMeshProUGUI>().enabled = false;

        if (m_eventToFireOnSuccess)
        {
            m_eventToFireOnSuccess.Raise();
        }
        CloseModal();
    }
Ejemplo n.º 8
0
    public void LoadItem(UIItem p_uiItem, Item p_item)
    {
        Image           image  = p_uiItem.GetComponent <Image>();
        TextMeshProUGUI amount = p_uiItem.GetComponentInChildren <TextMeshProUGUI>();

        p_uiItem.m_item         = p_item;
        image.sprite            = p_item.m_item.m_sprite;
        p_uiItem.m_ghost.sprite = image.sprite;

        image.color            = new Color(255, 255, 255, 255);
        p_uiItem.m_ghost.color = new Color(255, 255, 255, 255);

        if (p_item.m_amount == 1 && p_item.m_item.m_maxStackSize == 1)
        {
            amount.text = "";
        }
        else
        {
            amount.text = p_item.m_amount.ToString();
        }
    }