Beispiel #1
0
    public void PickUpItem(HeldItem h)
    {
        bool tf = false;
        Type t  = h.GetType();



        HeldItem thing = null;

        foreach (HeldItem go in items)
        {
            // print("T: " + t.ToString() + " curr: " + go.GetType().ToString());

            if (go.GetType() == t)
            {
                tf    = true;
                thing = go;
                break;
            }
        }



        if (tf)
        {
            // print("Here");
            thing.OnPickUpSecondItem(h);
            Destroy(h.gameObject);
        }
        else
        {
            h.OnPickup.Invoke();
            h.transform.SetParent(hand);
            h.transform.localPosition = Vector3.zero;
            h.transform.localRotation = Quaternion.identity;
            items.Add(h);
            h.gameObject.SetActive(false);
            h.transform.GetChild(0).localPosition    = h.posOffset;
            h.transform.GetChild(0).localRotation    = Quaternion.Euler(h.rotationOffset);
            h.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
            if (currentItem == null)
            {
                EquipItem(0);
            }
            if (h.GetComponent <Billboard>())
            {
                Destroy(h.GetComponent <Billboard>());
            }
            ItemButton i = Instantiate(itemButtonPrefab, buttonSpot);
            i.init(h.icon, h);
            buttons.Add(i);
            h.itemButton = i;
            h.OnInitialSetup(this);
        }
    }