Пример #1
0
    // --------------------------------------- Demo Device ---------------------------------------
    #region Demo device / controller input
    public void PerformDemoDeviceAction(string itemID, bool otherSource)
    {
        switch (itemID)
        {
        case DemoDevice.STEP_BACK:
            if (!WaitingForSupportToFinish())
            {
                // Report backward step
                PlayerStepByStepInput(false);

                // Give feedback incase of invalid step
                if (!demoManager.IsValidStep)
                {
                    StartCoroutine(SetFeedbackDisplayDuration("First instruction reached.\nCan't decrement."));
                }
                else
                {
                    StartCoroutine(SetFeedbackDisplayDuration("Backward step"));
                }
            }
            else
            {
                StartCoroutine(SetFeedbackDisplayDuration("Support working (" + waitForSupportToComplete + "). Wait a second and try again."));
            }
            break;

        case DemoDevice.PAUSE:
            // Toggle pause
            UserPausedTask = !userPausedTask;
            Debug.Log("Pause action: " + userPausedTask);

            if (useDebugText && debugText != null)
            {
                debugText.text += "\nPause action: " + userPausedTask;
            }

            // Tips display
            string pauseOrUnPauseText = UserPausedText(UserPausedTask);
            SetFeedbackDisplay(pauseOrUnPauseText);

            // Demo device button replacing
            demoDevice.TransitionPause(userPausedTask);

            if (otherSource)
            {
                demoDevice.OtherSourceClick(DemoDevice.PAUSE);
            }

            if (userPausedTask)
            {
                // Step back when paused (otherwise it'll skip 1 instruction)
                demoManager.DecrementToPreviousInstruction();     //demoManager.CurrentInstructionNr--;

                // Save the current speed used
                demoSpeedBeforePause = GetTeachingAlgorithm().DemoStepDuration;

                // Set to step-by-step speed (instant)
                GetTeachingAlgorithm().DemoStepDuration = stepByStepMode;     // If pause -> Step by step (player choose pace themself)
            }
            else
            {
                GetTeachingAlgorithm().DemoStepDuration = demoSpeedBeforePause;     // Use demo speed
            }
            break;

        case DemoDevice.STEP_FORWARD:
            if (!WaitingForSupportToFinish())
            {
                // Report forward step
                PlayerStepByStepInput(true);

                // Give feedback incase of invalid step
                if (!demoManager.IsValidStep)
                {
                    StartCoroutine(SetFeedbackDisplayDuration("Final instruction reached.\nCan't increment."));
                }
                else
                {
                    StartCoroutine(SetFeedbackDisplayDuration("Forward step"));
                }
            }
            else
            {
                StartCoroutine(SetFeedbackDisplayDuration("Support working (" + waitForSupportToComplete + "). Wait a second and try again."));
            }
            break;

        case DemoDevice.REDUCE_SPEED:
            if (Settings.AlgorithmSpeedLevel > 0)
            {
                Settings.AlgorithmSpeedLevel--;
                GetTeachingAlgorithm().DemoStepDuration = new WaitForSeconds(Settings.AlgorithmSpeed);

                switch (Settings.AlgorithmSpeedLevel)
                {
                case 0: demoDevice.ButtonActive(DemoDevice.REDUCE_SPEED, false); break;

                case 2: demoDevice.ButtonActive(DemoDevice.INCREASE_SPEED, true); break;
                }
                StartCoroutine(SetFeedbackDisplayDuration("Speed: " + Util.algorithSpeedConverterDict[Settings.AlgorithmSpeedLevel]));
            }
            else
            {
                StartCoroutine(SetFeedbackDisplayDuration("Minimum speed already set."));
            }
            break;

        case DemoDevice.INCREASE_SPEED:
            if (Settings.AlgorithmSpeedLevel < 3)
            {
                Settings.AlgorithmSpeedLevel++;
                GetTeachingAlgorithm().DemoStepDuration = new WaitForSeconds(Settings.AlgorithmSpeed);

                switch (Settings.AlgorithmSpeedLevel)
                {
                case 1: demoDevice.ButtonActive(DemoDevice.REDUCE_SPEED, true); break;

                case 3: demoDevice.ButtonActive(DemoDevice.INCREASE_SPEED, false); break;
                }
                StartCoroutine(SetFeedbackDisplayDuration("Speed: " + Util.algorithSpeedConverterDict[Settings.AlgorithmSpeedLevel]));
            }
            else
            {
                StartCoroutine(SetFeedbackDisplayDuration("Maximum speed already set."));
            }
            break;
        }
    }