示例#1
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange))
        {
            if (hit.transform.tag == "Stove")
            {
                Transform tmpPos = hit.transform.Find("PotLocation");
                if (tmpPos.childCount > 0)
                {
                    GameObject oldPot = tmpPos.GetChild(0).gameObject;
                    Destroy(oldPot);
                    inventory.replaceHoldableItem(ih.getSelectedItem(), emptyBucket);

                    GameObject tmpPot = Instantiate(filledPlacedPot, tmpPos);
                    tmpPot.name = filledPlacedPot.name;
                }
            }
            else if (hit.transform.name == "potEmtyPickUpeble")
            {
                Transform tmpPos;
                if (hit.transform.parent.name == "PotLocation")
                {
                    tmpPos = hit.transform.parent;
                    Destroy(hit.transform.gameObject);
                    inventory.replaceHoldableItem(ih.getSelectedItem(), emptyBucket);

                    GameObject tmpPot = Instantiate(filledPlacedPot, tmpPos);
                    tmpPot.name = filledPlacedPot.name;
                }
            }
        }
    }
示例#2
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange))
        {
            if (hit.transform.tag == "Terrain")
            {
                //Fill With Snow;
                //Exchange Object
                print("Fill With Snow");

                //inventory.removeHoldableItem(ih.getSelectedItem());
                inventory.replaceHoldableItem(ih.getSelectedItem(), filledHoldeblePot);
                //inventory.addItem(filledHoldeblePot);
                Destroy(gameObject);
                //ih.IncrementSelectedItem();
            }
            else
            {
                print("Aint allowed to take snow from this Item");
            }
        }
    }
示例#3
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange, layerMask))
        {
            print(hit.transform.gameObject);
            if (hit.transform.name == locationName)
            {
                GameObject placedTrap = Instantiate(trapToPlace, hit.point, Quaternion.identity);
                Destroy(hit.transform.gameObject);
                inventory.removeHoldableItem(ih.getSelectedItem());
                Destroy(gameObject);
                Vector3 rotation = new Vector3(0f, playerCam.transform.rotation.eulerAngles.y + rotationDegrees, 0f);
                placedTrap.transform.Rotate(rotation);
            }
            else
            {
                Debug.Log(hit.transform.gameObject);
                //  print("Aint allowed to put trap here");
            }
        }
        else
        {
            //   print("Aint allowed to put trap here");
        }
    }
示例#4
0
    public void Use(ItemHand ih)
    {
        inventory = Inventory.instance;
        //Debug.Log(ih.ActiveItem);
        Vector3 throwDirection = Camera.main.transform.forward;

        rb.isKinematic = false;
        rb.AddForce(throwDirection * throwForce, ForceMode.Impulse);
        rb.AddRelativeTorque((new Vector3(0f, -1f, 0f)) * 10000);
        rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
        rb.transform.GetComponent <Collider>().enabled = true;
        rb.gameObject.layer = 0;
        transform.parent    = null;
        inventory.removeHoldableItem(ih.getSelectedItem());
        GameObject.FindGameObjectWithTag("Dog").GetComponent <Dog> ().Fetch(transform);
        //ih.ActiveItem = null;
    }
示例#5
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange))
        {
            if (hit.transform.tag == "Stove")
            {
                print("Place On Stove");
                Transform  tmpPos = hit.transform.Find("PotLocation");
                GameObject tmpPot = Instantiate(filledPlacedPot, tmpPos);
                tmpPot.name = filledPlacedPot.name;
                inventory.removeHoldableItem(ih.getSelectedItem());
                Destroy(gameObject);
            }
            else
            {
                print("Aint allowed to Place Item Here");
            }
        }
    }