Exemplo n.º 1
0
    public void OnEnter(InputAction.CallbackContext context)
    {
        if (context.started == true)
        {
            //reset scaling for each adjustment.
            translationStep = Constants.BASE_TRANSLATION;
            rotationStep    = Constants.BASE_ROTATION;
            switch (appStatus.GetState())
            {
            case AppState.Status.INTRO_1:
                appStatus.SetState(AppState.Status.INTRO_2);
                sounds.PlayClip("enter");
                break;

            case AppState.Status.INTRO_2:
                appStatus.SetState(AppState.Status.INTRO_3);
                sounds.PlayClip("enter");
                break;

            case AppState.Status.INTRO_3:
                appStatus.SetState(AppState.Status.EXPLORATION);
                sounds.PlayClip("enter");
                break;

            case AppState.Status.EXPLORATION:
                appStatus.SetState(AppState.Status.FIND_MARKER);
                sounds.PlayClip("enter");
                break;

            case AppState.Status.FIND_MARKER:
                cursor.SetActive(true);
                sounds.PlayClip("enter");
                appStatus.SetState(AppState.Status.FIND_TARGET);
                appStatus.SaveMarker();
                break;

            case AppState.Status.FIND_TARGET:

                if (appStatus.AddNewTarget())
                {
                    sounds.PlayClip("enter");
                    cursor.SetActive(false);
                    appStatus.SetState(AppState.Status.ADJUST_ROTATIONY);
                    toggledControlsOnce = false;
                }
                else
                {
                    sounds.PlayClip("enter failed");
                }
                break;

            case AppState.Status.ADJUST_ROTATIONY:
            case AppState.Status.ADJUST_ROTATIONX:
            case AppState.Status.ADJUST_NORMAL:
            case AppState.Status.ADJUST_DEPTH:
                if (!toggledControlsOnce)
                {
                    statusMessage.text = "Position the target before confirming!";
                }
                else
                {
                    if ((appStatus.GetTargetCount() + 1) >= Constants.NUM_TARGETS)
                    {
                        appStatus.ResetMarkers();

                        appStatus.SetState(AppState.Status.CONFIRM_MARKER);
                    }
                    else
                    {
                        sounds.PlayClip("enter");
                        if ((appStatus.GetTargetCount() + 1) % 2 == 0)
                        {
                            appStatus.SetState(AppState.Status.FIND_MARKER);
                        }
                        else
                        {
                            cursor.SetActive(true);
                            appStatus.SetState(AppState.Status.FIND_TARGET);
                        }
                    }
                    appStatus.ConfirmPlacement();
                }
                break;

            case AppState.Status.CONFIRM_MARKER:
                sounds.PlayClip("enter");
                if ((appStatus.GetMarkerCount() + 1) == Constants.NUM_MARKERS)
                {
                    appStatus.SetState(AppState.Status.ALIGNMENT_READY);
                }

                appStatus.SaveMarker();
                if (appStatus.GetMarkerCount() != Constants.NUM_MARKERS)
                {
                    //appStatus.RemoveMarkerAnchor();
                }

                break;

            case AppState.Status.ALIGNMENT_READY:
                appStatus.ComputeAlignment();
                sounds.PlayClip("enter");
                break;
            }
        }
    }