Пример #1
0
        void Update()
        {
            if (rumbleBuffer > 0.0f)
            {
                TBInput.SetRumble(controller, rumbleIntensity);
                rumbleBuffer -= Time.deltaTime;
            }
            else
            {
                TBInput.SetRumble(controller, 0.0f);
            }

            AnimateControllerModel();

            bool actionTeleportation, shiftLeft, shiftRight, actionInteract, actionRelease;

            DetectInputs(out actionTeleportation, out shiftLeft, out shiftRight, out actionInteract, out actionRelease);

            if (actionTeleportation)
            {
                teleportationController.InitiateTeleport();
                teleportInitiated = true;
            }
            else if (teleportInitiated)
            {
                teleportationController.ConcludeTeleport();
                teleportInitiated = false;
            }

            if (shiftLeft)
            {
                teleportationController.ShiftLeft();
                shiftLeft = false;
            }
            else if (shiftRight)
            {
                teleportationController.ShiftRight();
                shiftRight = false;
            }

            if (actionInteract && grabPossible && !objectGrabbed)
            {
                HideController();
                grabbedObject.GetComponent <Interaction.ObjectGrabbable>().attachToController(gameObject);
                globalAudio.clip = grabSound;
                globalAudio.Play();
                objectGrabbed = true;
            }
            else if (actionRelease && objectGrabbed)
            {
                grabbedObject.GetComponent <Interaction.ObjectGrabbable>().returnToInitialLocation();
                ShowController();
                globalAudio.clip = dropSound;
                globalAudio.Play();
                objectGrabbed = false;
            }
            else if (actionInteract && rotatePossible)
            {
                rotateableObject.GetComponent <Interaction.ObjectRotateable>().RotateTowardPivot(gameObject);
                objectInRotation = true;
            }
            else if (actionRelease && objectInRotation)
            {
                rotateableObject.GetComponent <Interaction.ObjectRotateable>().StopRotating();
                objectInRotation = false;
            }
            else if (actionInteract && pushPossible)
            {
                pushableObject.GetComponent <Interaction.ObjectPushable>().Use();
            }
            else if (actionInteract && joystickPossible)
            {
                joystickObject.GetComponent <Interaction.JoystickInteraction>().Grabbed(gameObject);
                HideController();
                joystickUsed = true;
            }
            else if (actionRelease && joystickUsed)
            {
                joystickObject.GetComponent <Interaction.JoystickInteraction>().Dropped();
                ShowController();
                joystickUsed = false;
            }
        }