public void Open(Tapestry_Inventory _leftInv, Tapestry_EquipmentProfile _equip, Tapestry_Inventory _rightInv = null, string _leftName = "Inventory", string _rightName = "Target")
    {
        left.Clear();
        right.Clear();
        this.gameObject.SetActive(true);
        _isOpen = true;
        Tapestry_WorldClock.IsPaused = true;
        left.Init(displayPrefab, _leftInv, _leftName, _equip);
        leftInv   = _leftInv;
        leftName  = _leftName;
        player    = FindObjectOfType <Tapestry_Player>();
        equipment = _equip;

        if (_rightInv == null)
        {
            right.gameObject.SetActive(false);
        }
        else
        {
            right.gameObject.SetActive(true);
            right.Init(displayPrefab, _rightInv, _rightName);
            rightInv  = _rightInv;
            rightName = _rightName;
        }
    }
Ejemplo n.º 2
0
    public Tapestry_Inventory GenerateInventory(Transform source)
    {
        Tapestry_Inventory export = new Tapestry_Inventory();

        export.items = GenerateItems();

        return(export);
    }
 public void Close()
 {
     this.gameObject.SetActive(false);
     _isOpen = false;
     Tapestry_WorldClock.IsPaused = false;
     left.Clear();
     right.Clear();
     leftInv   = null;
     rightInv  = null;
     equipment = null;
 }
Ejemplo n.º 4
0
    protected override void Reset()
    {
        if (ReferenceEquals(inventory, null))
        {
            inventory = (Tapestry_Inventory)ScriptableObject.CreateInstance("Tapestry_Inventory");
        }
        if (damageProfile == null)
        {
            damageProfile = new Tapestry_DamageProfile();
        }
        if (attributeProfile == null)
        {
            attributeProfile = new Tapestry_AttributeProfile();
        }
        if (skillProfile == null)
        {
            skillProfile = new Tapestry_SkillProfile();
        }
        if (keywords == null)
        {
            keywords = (Tapestry_KeywordRegistry)ScriptableObject.CreateInstance("Tapestry_KeywordRegistry");
        }
        if (effects == null)
        {
            effects = new List <Tapestry_Effect>();
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            if (transform.GetChild(i).name == "T_Points")
            {
                GameObject pointContainer = transform.GetChild(i).gameObject;
                for (int j = 0; j < pointContainer.transform.childCount; j++)
                {
                    if (transform.GetChild(i).name == "P_Attach")
                    {
                        attachPoint = pointContainer.transform.GetChild(j).gameObject;
                    }
                }
            }
        }

        base.Reset();
    }
    public void Init(Tapestry_UI_InventoryDisplayTextElement displayPrefab, Tapestry_Inventory inv, string inventoryName, Tapestry_EquipmentProfile eq = null)
    {
        title.text = inventoryName;

        elements = new List <Tapestry_UI_InventoryDisplayTextElement>();
        int y      = -24;
        int height = 24;

        if (!ReferenceEquals(eq, null))
        {
            if (eq.GetNumberOfEquippedItems() == 0)
            {
                Tapestry_UI_InventoryDisplayTextElement e =
                    (Tapestry_UI_InventoryDisplayTextElement)Instantiate(displayPrefab, content);
                e.GetComponent <RectTransform>().localPosition = new Vector3(e.GetComponent <RectTransform>().localPosition.x, y, 0);
                e.title.text    = "<i>Nothing equipped</i>";
                e.title.color   = new Color(1, 1, 1, 0.5f);
                e.quantity.text = "";
                e.size.text     = "";
                elements.Add(e);
                y      -= 24;
                height += 24;
            }
            else
            {
                Dictionary <Tapestry_EquipSlot, Tapestry_ItemStack> dict = eq.ToDict();
                foreach (Tapestry_EquipSlot slot in dict.Keys)
                {
                    Tapestry_UI_InventoryDisplayTextElement e =
                        (Tapestry_UI_InventoryDisplayTextElement)Instantiate(displayPrefab, content);
                    e.GetComponent <RectTransform>().localPosition = new Vector3(e.GetComponent <RectTransform>().localPosition.x, y, 0);
                    e.SetData(dict[slot]);
                    y               -= 24;
                    height          += 24;
                    e.equippedInSlot = slot;
                    if (slot == Tapestry_EquipSlot.LeftHand)
                    {
                        e.SetEquippedState(1);
                    }
                    else if (slot == Tapestry_EquipSlot.RightHand)
                    {
                        e.SetEquippedState(2);
                    }
                    else if (slot == Tapestry_EquipSlot.BothHands)
                    {
                        e.SetEquippedState(3);
                    }
                    else
                    {
                        e.SetEquippedState(4);
                    }
                    elements.Add(e);
                }
            }
        }
        if (inv.items.Count == 0)
        {
            Tapestry_UI_InventoryDisplayTextElement e =
                (Tapestry_UI_InventoryDisplayTextElement)Instantiate(displayPrefab, content);
            e.GetComponent <RectTransform>().localPosition = new Vector3(e.GetComponent <RectTransform>().localPosition.x, y, 0);
            e.title.text    = "<i>No items</i>";
            e.title.color   = new Color(1, 1, 1, 0.5f);
            e.quantity.text = "";
            e.size.text     = "";
            elements.Add(e);
            y      -= 24;
            height += 24;
        }
        else
        {
            foreach (Tapestry_ItemStack stack in inv.items)
            {
                Tapestry_UI_InventoryDisplayTextElement e =
                    (Tapestry_UI_InventoryDisplayTextElement)Instantiate(displayPrefab, content);
                e.GetComponent <RectTransform>().localPosition = new Vector3(e.GetComponent <RectTransform>().localPosition.x, y, 0);
                e.SetData(stack);
                y      -= 24;
                height += 24;
                elements.Add(e);
            }
        }
        height += 24;
    }