示例#1
0
    private void UpdateGame()
    {
        //Deal with gesture starting and stopping and hand grabbing
        if (grabAction.GetAxis(SteamVR_Input_Sources.LeftHand) >= 0.1f)
        {
            if (!leftHand.GetGrabbing())
            {
                leftHand.ToggleGrabbing();
                gestureManager.BeginGesture(this, true, true);
            }
        }
        else
        {
            if (leftHand.GetGrabbing())
            {
                leftHand.ToggleGrabbing();
                spellHandler.CastSpell(gestureManager.EndGesture(), gestureManager.CurrentHand());
            }
        }

        if (grabAction.GetAxis(SteamVR_Input_Sources.RightHand) >= 0.1f)
        {
            if (!rightHand.GetGrabbing())
            {
                rightHand.ToggleGrabbing();
                gestureManager.BeginGesture(this, false, true);
            }
        }
        else
        {
            if (rightHand.GetGrabbing())
            {
                rightHand.ToggleGrabbing();
                spellHandler.CastSpell(gestureManager.EndGesture(), gestureManager.CurrentHand());
            }
        }

        gestureManager.Update(this, Time.deltaTime, true);

        //Deal with player movement
        CalcMovement();

        //Remove the shield material if the shield is gone
        if (healthComp.ShieldBroke())
        {
            leftHand.GetComponentInChildren <SkinnedMeshRenderer>().material  = baseMaterial;
            rightHand.GetComponentInChildren <SkinnedMeshRenderer>().material = baseMaterial;
        }

        leftHand.SetGems(healthComp.GetHealth() / (float)startingHP);
        rightHand.SetGems(healthComp.GetHealth() / (float)startingHP);
    }