Пример #1
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, 100, ~ignoreMe);

        if (hit.collider != null)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (hit.collider.gameObject.tag == "Item Slot")
                {
                    ItemSlot slotScript = hit.collider.gameObject.GetComponent <ItemSlot> ();
                    if (slotScript.amount > 0 && currentIngredient == null)
                    {
                        currentIngredient = slotScript.currentIngredient;
                        slotScript.amount--;
                    }
                    else
                    {
                        if (currentIngredient == slotScript.currentIngredient)
                        {
                            currentIngredient = null;
                            slotScript.amount++;
                        }
                    }
                }
                if (hit.collider.gameObject.tag == "Cauldron Slot")
                {
                    CauldronSlot slotScript = hit.collider.gameObject.GetComponent <CauldronSlot> ();
                    if (slotScript.currentIngredient == null && currentIngredient != null)
                    {
                        slotScript.currentIngredient = currentIngredient;
                        currentIngredient            = null;
                    }
                    else
                    {
                        currentIngredient            = slotScript.currentIngredient;
                        slotScript.currentIngredient = null;
                    }
                }
            }
        }
        if (currentIngredient != null)
        {
            rend.enabled = true;
            rend.sprite  = currentIngredient.itemSprite;
        }
        else
        {
            rend.enabled = false;
        }

        Debug.Log(currentIngredient.itemName);


        Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        transform.position = mousePos;
    }
        public override int GetHashCode()
        {
            int hash = 1;

            if (CauldronId != 0L)
            {
                hash ^= CauldronId.GetHashCode();
            }
            if (CauldronSlot != 0)
            {
                hash ^= CauldronSlot.GetHashCode();
            }
            if (requestedRewards_ != null)
            {
                hash ^= RequestedRewards.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }