public virtual void ToggleSubMenu(bool isOn)
        {
            isSubMenuOn = isOn;
            RenderSubBtns(isOn);

            ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

            if (isSubMenuOn)
            {
                subBtnScripts[HoverredButton].renderer.material.SetInt("_Hovered", 1);
                subBtnScripts[HoverredButton].isShrinking = false;
                Enlarge(subBtnScripts[HoverredButton]);
                ViveSR_Experience_ControllerDelegate.touchpadDelegate += HandleTouchpadInput_SubMenu;
            }
            else
            {
                subBtnScripts[HoverredButton].renderer.material.SetInt("_Hovered", 0);
                subBtnScripts[HoverredButton].isEnlarging = false;
                Shirnk(subBtnScripts[HoverredButton]);
                ViveSR_Experience_ControllerDelegate.touchpadDelegate -= HandleTouchpadInput_SubMenu;
            }

            if (!isOn)
            {
                for (int i = 0; i < subBtnScripts.Count; i++)
                {
                    if (subBtnScripts[i].isOn == true)
                    {
                        subBtnScripts[i].Execute();
                    }
                }
            }
        }
        public override void ConfirmSelection()
        {
            if (tutorial.currentInput == ControllerInputIndex.left || tutorial.currentInput == ControllerInputIndex.right)
            {
                if (!CalibrationScript.isActiveAndEnabled)
                {
                    base.ConfirmSelection();
                }
            }
            else if (tutorial.currentInput == ControllerInputIndex.up || tutorial.currentInput == ControllerInputIndex.down)
            {
                if (!CalibrationScript.isActiveAndEnabled)
                {
                    tutorial.SetCanvas(TextCanvas.onRotator, true);

                    //Set rotator message for calibration
                    ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;
                    tutorial.SetCanvasText(TextCanvas.onRotator, tutorial.SubLineManagers[CurrentButton.ButtonType].SubBtns[SubMenu.HoverredButton].lines.First(x => x.messageType == "Available").text);
                }
            }
            else if (tutorial.currentInput == ControllerInputIndex.mid)
            {
                MidPressedDown();
            }
        }
示例#3
0
        IEnumerator _ColorFade(ViveSR_Experience_IButton button, bool isFading)
        {
            Color newColor;

            bool a = true, b = true;

            Color iconColor = button.renderer.material.color;

            while (a && b)
            {
                iconColor = button.renderer.material.color;

                newColor = new Color(iconColor.r, iconColor.g, iconColor.b,
                                     button.renderer.material.color.a + 2f * Time.deltaTime * (isFading ? -1 : 1));

                button.SetIconColor(newColor);
                a = isFading ? (iconColor.a > 0.3f) : (iconColor.a < 0.95f);
                b = isFading ? button.isShrinking : button.isEnlarging;

                yield return(new WaitForEndOfFrame());
            }

            Color disableColor     = ViveSR_Experience_Demo.instance.DisableColor;
            Color originalColor    = ViveSR_Experience_Demo.instance.OriginalEmissionColor;
            Color brightFrameColor = ViveSR_Experience_Demo.instance.BrightFrameColor;

            button.SetIconColor((isFading || CurrentButton.disabled) ? disableColor : originalColor);
            button.SetFrameColor(isFading ? disableColor : brightFrameColor);
        }
示例#4
0
        void Enlarge(ViveSR_Experience_IButton button, System.Action done = null)
        {
            ViveSR_Experience.instance.SoundManager.PlayAtAttachPoint(AudioClipIndex.Slide);
            ColorFade(CurrentButton, false);

            StartCoroutine(_Enlarge(true, button, done));
        }
示例#5
0
        public void SetMainMessage()
        {
            string msgType;

            ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

            if (CurrentButton.disabled)
            {
                msgType = "Disabled";
            }
            else if (CurrentButton.isOn)
            {
                msgType = "On";
            }
            else
            {
                msgType = "Available";
            }

            ViveSR_Experience_Tutorial_Line TextLineFound = MainLineManagers[CurrentButton.ButtonType].mainLines.FirstOrDefault(x => x.messageType == msgType);

            if (TextLineFound != null)
            {
                SetCanvasText(TextCanvas.onRotator, MainLineManagers[CurrentButton.ButtonType].mainLines.First(x => x.messageType == msgType).text);
            }
            else
            {
                SetCanvasText(TextCanvas.onRotator, "Message Not Found.");
            }
        }
        //When mid is pressed...
        protected virtual void Execute()
        {
            ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

            if (!CurrentButton.disabled && !subBtnScripts[HoverredButton].disabled)
            {
                SelectedButton = HoverredButton;
                subBtnScripts[SelectedButton].Execute();
                ViveSR_Experience.instance.SoundManager.PlayAtAttachPoint(subBtnScripts[SelectedButton].isOn ? AudioClipIndex.Select_On : AudioClipIndex.Select_Off);
            }
            ;
        }
示例#7
0
        IEnumerator Rotate(bool isTouchPositive)
        {
            SetRotator(false);

            /*---The Old Button---*/
            CurrentButton.isEnlarging = false;
            Shirnk(CurrentButton);

            if (CurrentButton.isOn && CurrentButton.disableWhenRotatedAway)
            {
                CurrentButton.ActOnRotator(false);
            }

            ViveSR_Experience_IButton oldBtn = CurrentButton;

            /*--------------------*/

            /*---The New Button---*/
            CurrentButton = GetButtons(isTouchPositive, 1);

            //Enlarge
            CurrentButton.isShrinking = false;
            Enlarge(CurrentButton);

            //Set the target degree.
            targetY = localY + (360 / (int)MenuButton.MaxNum) * (isTouchPositive ? 1 : -1);

            CurrentButton.gameObject.transform.GetChild(0).transform.localScale *= 1.2f;

            while (isTouchPositive ? localY <targetY : localY> targetY)
            {
                localY += (isTouchPositive ? 1 : -1) * rotateSpeed * Time.deltaTime;
                transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, localY, transform.localEulerAngles.z);

                yield return(new WaitForEndOfFrame());
            }

            targetY = localY = (360 / IncludedBtns.Count) * CurrentButton.rotatorIdx;
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, targetY, transform.localEulerAngles.z);

            oldBtn.gameObject.transform.GetChild(0).transform.localScale = Vector3.one * 0.03f;

            AdjustUITransform();
            SetRotator(true);

            /*--------------------*/
        }
示例#8
0
        protected virtual void LeftRightPressedDown()
        {
            ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

            if (SubMenu == null || !CurrentButton.SubMenu.isSubMenuOn)
            {
                tutorial.SetMainMessage();

                tutorial.SetTouchpadSprite(!CurrentButton.disabled, ControllerInputIndex.mid);
                tutorial.SetTouchpadSprite(true, false, ControllerInputIndex.left, ControllerInputIndex.right);
                tutorial.SetTouchpadSprite(false, false, ControllerInputIndex.up, ControllerInputIndex.down);

                tutorial.SetCanvas(TextCanvas.onRotator, true);
                tutorial.SetCanvas(TextCanvas.onTrigger, false);
                tutorial.SetCanvas(TextCanvas.onGrip, false);
            }
        }
示例#9
0
        void HandleTrigger_Tutorial(ButtonStage buttonStage, Vector2 axis)
        {
            ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

            if (IsTutorialOn && CurrentButton.isOn)
            {
                switch (buttonStage)
                {
                case ButtonStage.PressDown:
                    InputHandlers[CurrentButton.ButtonType].TriggerDown();
                    break;

                case ButtonStage.PressUp:
                    InputHandlers[CurrentButton.ButtonType].TriggerUp();
                    break;
                }
            }
        }
示例#10
0
        IEnumerator _Enlarge(bool on, ViveSR_Experience_IButton button, System.Action done)
        {
            if (on)
            {
                button.isEnlarging = true;
            }
            else
            {
                button.isShrinking = true;
            }

            bool a = true;
            bool b = true;

            //on ? enlarge : shrink
            while (a && b)
            {
                button.transform.localScale += (on ? 1 : -1) * new Vector3(buttonEnlargingSpeed * Time.deltaTime, buttonEnlargingSpeed * Time.deltaTime, buttonEnlargingSpeed * Time.deltaTime);

                a = on ? button.transform.localScale.x <EnlargedSize : button.transform.localScale.x> RegularSize;
                b = on ? button.isEnlarging : button.isShrinking;

                yield return(new WaitForEndOfFrame());
            }

            button.transform.localScale       = on ? Vector_Enlarged : Vector_RegularSize;
            button.frame.transform.localScale = Vector3.one * (on ? 1.13f : 0.9f);

            if (on)
            {
                button.isEnlarging = false;
            }
            else
            {
                button.isShrinking = false;
            }

            if (done != null)
            {
                done();
            }
        }
        void SetTriggerMessage(bool isTriggerDown)
        {
            if (!DartGenerator)
            {
                DartGenerator = dartGeneratorMgr_portal.DartGenerators[dartGeneratorMgr_portal.dartPlacementMode];
            }

            string targetLine = "";

            if (isTriggerDown)
            {
                if (DartGenerator.isActiveAndEnabled)
                {
                    if (DartGenerator.currentDartPrefeb == 2)
                    {
                        targetLine = "Trigger(Sword)";
                    }
                    else if (DartGenerator.currentDartPrefeb == 0)
                    {
                        targetLine = "Trigger(Sphere)";
                    }
                    else if (DartGenerator.currentDartPrefeb == 1)
                    {
                        targetLine = "Trigger(ViveDeer)";
                    }

                    ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

                    tutorial.SetCanvasText(TextCanvas.onRotator, tutorial.MainLineManagers[CurrentButton.ButtonType].mainLines.First(x => x.messageType == targetLine).text);
                }
            }
            else
            {
                tutorial.SetMainMessage();
            }
        }
示例#12
0
 void ColorFade(ViveSR_Experience_IButton button, bool isFading)
 {
     StartCoroutine(_ColorFade(button, isFading));
 }
示例#13
0
        void Shirnk(ViveSR_Experience_IButton button, System.Action done = null)
        {
            ColorFade(CurrentButton, true);

            StartCoroutine(_Enlarge(false, button, done));
        }
示例#14
0
        void HandleTouchpad_Tutorial(ButtonStage buttonStage, Vector2 axis)
        {
            if (IsTutorialOn)
            {
                previosuInput = currentInput;
                currentInput  = GetCurrentSprite(axis);
                ViveSR_Experience_IButton CurrentButton = ViveSR_Experience_Demo.instance.Rotator.CurrentButton;

                #region VIVEPro
                if (ViveSR_Experience.instance.CurrentDevice == DeviceType.Vive)
                {
                    switch (buttonStage)
                    {
                    case ButtonStage.Press:
                        InputHandlers[CurrentButton.ButtonType].MatchRotator();
                        break;

                    case ButtonStage.PressUp:
                        InputHandlers[CurrentButton.ButtonType].MatchRotatorUp();
                        break;

                    case ButtonStage.PressDown:
                        InputHandlers[CurrentButton.ButtonType].ConfirmSelection();
                        break;

                    case ButtonStage.TouchUp:
                        InputHandlers[CurrentButton.ButtonType].ResetTouchpadSprite();
                        break;

                    case ButtonStage.Touch:
                        InputHandlers[CurrentButton.ButtonType].SetTouchpadText(axis);
                        break;
                    }
                }
                #endregion
                #region VIVET2
                else if (ViveSR_Experience.instance.CurrentDevice == DeviceType.ViveT2)
                {
                    switch (buttonStage)
                    {
                    case ButtonStage.Press:
                        InputHandlers[CurrentButton.ButtonType].MatchRotator();
                        break;

                    case ButtonStage.PressUp:
                        InputHandlers[CurrentButton.ButtonType].MatchRotatorUp();
                        break;

                    case ButtonStage.PressDown:
                        InputHandlers[CurrentButton.ButtonType].ConfirmSelection();
                        break;

                    case ButtonStage.TouchUp:
                        InputHandlers[CurrentButton.ButtonType].ResetTouchpadSprite();
                        break;

                    case ButtonStage.Touch:
                        InputHandlers[CurrentButton.ButtonType].SetTouchpadText(axis);
                        if (currentInput != previosuInput)
                        {
                            InputHandlers[CurrentButton.ButtonType].MatchRotator();
                        }
                        break;
                    }
                }
                #endregion
            }
        }