Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (holding)
        {
            PickUpItem itemInHand = holdPosition.GetChild(0).GetComponent <PickUpItem>();

            GameObject handObject = character.handObject;
            rb_heldObject.gameObject.transform.position = handObject.transform.position - (handObject.transform.forward * 0.1f);
            if (itemInHand.ignoreHandRotation)
            {
            }
            else
            {
                rb_heldObject.gameObject.transform.rotation = handObject.transform.rotation;
            }

            //If player is holding a torch
            if (itemInHand && itemInHand.getItemDefinition() == 0)
            {
                torch = holdPosition.GetChild(0).Find("Bulb").GetComponent <Torchbehaviour>();
                SetCurrentBatteryLife(torch);
                if (Input.GetKeyDown(KeyCode.F))
                {
                    torch.TurnOnLight();
                }

                if (Input.GetKeyDown(KeyCode.R))
                {
                    torch.replaceBatteries();
                }
            }
        }

        //Any Object to drop
        if (Input.GetMouseButton(1))

        {
            DropItem();
        }
    }
Ejemplo n.º 2
0
 public void SetCurrentBatteryLife(Torchbehaviour torch)
 {
     batteryPercent = torch.GetBatteryLife();
 }