Esempio n. 1
0
        private void ungrabItem()
        {
            isGrabbing = false;
            if (currentGrabbable == null)
            {
                return;
            }

            currentGrabbableRb.isKinematic = false;

            resetLaser();
            currentGrabbable.Ungrabbed();

            constrainPosition = null;
            sliderControl     = null;
        }
Esempio n. 2
0
        private IEnumerator AddComponent()
        {
            yield return(null);

            Log("H");
            GameObject g1 = new GameObject();
            GameObject g2 = new GameObject();

            foreach (var i in FindObjectsOfType <GameObject>().Where(x => x.name.Contains("Royal Gaurd")))
            {
                if (i.name.Contains("(1)"))
                {
                    g2 = i;
                }
                else
                {
                    g1 = i;
                }
                i.SetActive(false);
            }
            GameObject   pv       = Instantiate(PVPoP.preloadedGO["pv"]);
            PlayMakerFSM _control = pv.LocateMyFSM("Control");

            _control.FsmVariables.FindFsmFloat("Left X").Value        = 214.2f;
            _control.FsmVariables.FindFsmFloat("Right X").Value       = 244.2f;
            _control.FsmVariables.FindFsmFloat("TeleRange Max").Value = 242f;
            _control.FsmVariables.FindFsmFloat("TeleRange Min").Value = 216f;
            _control.FsmVariables.FindFsmFloat("Plume Y").Value       = 135f; //129f
            ConstrainPosition cp = pv.GetComponent <ConstrainPosition>();

            //214 244
            cp.xMax = 243f;
            cp.xMin = 215.2f;
            pv.transform.SetPosition2D(g2.transform.position.x, g2.transform.position.y);
            pv.SetActive(false);
            yield return(new WaitWhile(() => HeroController.instance.transform.GetPositionX() < 227f || HeroController.instance.transform.GetPositionY() > 139.6f));

            Log("H2");
            pv.SetActive(true);
            Log("Done");
            pv.LocateMyFSM("Control").enabled          = true;
            pv.AddComponent <PVFixer>().guard          = g2;
            pv.GetComponent <HealthManager>().OnDeath += DoOnDeath;
        }
Esempio n. 3
0
        private void grabItem()
        {
            // get current object targeted by raycast
            InteractiveItem currentInteractible = controllerRayCaster.CurrentInteractible;

            // get it's Grabbable component
            currentGrabbable = currentInteractible.gameObject.GetComponent <Grabbable>();
            if (currentGrabbable == null)
            {
                return;
            }

            // don't grab it if it has IsGrabbable = false;
            if (!currentGrabbable.IsGrabbable)
            {
                return;
            }

            // make kinematic
            currentGrabbableRb             = currentGrabbable.gameObject.GetComponent <Rigidbody>();
            currentGrabbableRb.isKinematic = true;

            // calculate distance to obj
            Vector3 controllerPos = OVRInput.GetLocalControllerPosition(KosmosStatics.Controller);

            localToWorld = trackingSpace.localToWorldMatrix;
            Vector3 controllerPosWorld = localToWorld.MultiplyPoint(controllerPos);
            Vector3 objectPos          = currentGrabbable.transform.position;

            DistanceToObj = Vector3.Distance(controllerPosWorld, objectPos);

            isGrabbing = true;

            currentGrabbable.Grabbed();

            // check if it has a ConstrainPosition component
            constrainPosition = currentInteractible.gameObject.GetComponent <ConstrainPosition>();

            // check if it has a SliderControl component
            sliderControl = currentInteractible.gameObject.GetComponent <SliderControl>();
        }