< Summary

Class:DCL.Tutorial.TutorialController
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialController.cs
Covered lines:200
Uncovered lines:76
Coverable lines:276
Total lines:698
Line coverage:72.4% (200 of 276)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TutorialController()0%110100%
CreateTutorialView()0%110100%
SetConfiguration(...)0%3.13077.78%
Dispose()0%4.034087.5%
SetTutorialEnabled(...)0%2100%
SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(...)0%6200%
SetBuilderInWorldTutorialEnabled()0%2100%
SetupTutorial(...)0%9.069090.91%
SetTutorialDisabled()0%8.068090%
StartTutorialFromStep()0%17.1517092%
ShowTeacher3DModel(...)0%330100%
SetTeacherPosition(...)0%4.374071.43%
PlayTeacherAnimation(...)0%220100%
SetTeacherCanvasSortingOrder(...)0%2.062075%
SkipTutorial(...)0%7.336066.67%
GoToSpecificStep(...)0%90900%
SetNextSkippedSteps(...)0%2100%
SetEagleEyeCameraActive(...)0%440100%
OnRenderingStateChanged(...)0%5.035088.89%
ExecuteSteps()0%26.8126089.36%
SetUserTutorialStepAsCompleted(...)0%110100%
MoveTeacher()0%6.976070%
IsSettingsHUDInitialized_OnChange(...)0%20400%
OnRestartTutorial()0%2100%
IsPlayerInScene()0%3.143075%
IsPlayerInsideGenesisPlaza()0%7.237083.33%
SendStepStartedSegmentStats(...)0%2100%
SendStepCompletedSegmentStats(...)0%2100%
SendSkipTutorialSegmentStats(...)0%2100%
EagleEyeCameraRotation()0%330100%
BlockPlayerCameraUntilBlendingIsFinished()0%15150100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialController.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Interface;
 4using System;
 5using System.Collections;
 6using System.Collections.Generic;
 7using UnityEngine;
 8
 9namespace DCL.Tutorial
 10{
 11    /// <summary>
 12    /// Controller that handles all the flow related to the onboarding tutorial.
 13    /// </summary>
 14    public class TutorialController : IPlugin
 15    {
 16        [Serializable]
 17        public class TutorialInitializationMessage
 18        {
 19            public string fromDeepLink;
 20            public string enableNewTutorialCamera;
 21        }
 22
 23        [Flags]
 24        public enum TutorialFinishStep
 25        {
 26            None = 0,
 27            OldTutorialValue = 99, // NOTE: old tutorial set tutorialStep to 99 when finished
 28            EmailRequested = 128, // NOTE: old email prompt set tutorialStep to 128 when finished
 29            NewTutorialFinished = 256
 30        }
 31
 32        public enum TutorialType
 33        {
 34            Initial,
 35            BuilderInWorld
 36        }
 37
 38        internal enum TutorialPath
 39        {
 40            FromGenesisPlaza,
 41            FromDeepLink,
 42            FromResetTutorial,
 43            FromBuilderInWorld,
 44            FromUserThatAlreadyDidTheTutorial
 45        }
 46
 1047        public static TutorialController i { get; private set; }
 48
 049        public HUDController hudController { get => HUDController.i; }
 50
 051        public int currentStepIndex { get; internal set; }
 52        public event Action OnTutorialEnabled;
 53        public event Action OnTutorialDisabled;
 54
 55        private const string PLAYER_PREFS_START_MENU_SHOWED = "StartMenuFeatureShowed";
 56
 57        internal TutorialSettings configuration;
 58        internal TutorialView tutorialView;
 59
 60        internal bool openedFromDeepLink = false;
 61        internal bool playerIsInGenesisPlaza = false;
 62        internal TutorialStep runningStep = null;
 63        internal bool tutorialReset = false;
 64        internal float elapsedTimeInCurrentStep = 0f;
 65        internal TutorialPath currentPath;
 66        internal int currentStepNumber;
 67        internal TutorialType tutorialType = TutorialType.Initial;
 68        internal int nextStepsToSkip = 0;
 69
 70        private Coroutine executeStepsCoroutine;
 71        private Coroutine teacherMovementCoroutine;
 72        private Coroutine eagleEyeRotationCoroutine;
 73
 074        internal bool userAlreadyDidTheTutorial { get; set; }
 75
 3976        public TutorialController ()
 77        {
 3978            tutorialView = CreateTutorialView();
 3979            SetConfiguration(tutorialView.configuration);
 3980        }
 81
 82        internal TutorialView CreateTutorialView()
 83        {
 3984            GameObject tutorialGO = GameObject.Instantiate(Resources.Load<GameObject>("TutorialView"));
 3985            tutorialGO.name = "TutorialController";
 3986            TutorialView tutorialView = tutorialGO.GetComponent<TutorialView>();
 3987            tutorialView.ConfigureView(this);
 88
 3989            return tutorialView;
 90        }
 91
 92        public void SetConfiguration(TutorialSettings configuration)
 93        {
 7894            this.configuration = configuration;
 95
 7896            i = this;
 7897            ShowTeacher3DModel(false);
 98
 7899            if (DataStore.i.settings.isInitialized.Get())
 0100                IsSettingsHUDInitialized_OnChange(true, false);
 101            else
 78102                DataStore.i.settings.isInitialized.OnChange += IsSettingsHUDInitialized_OnChange;
 103
 78104            if (configuration.debugRunTutorial)
 105            {
 0106                SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 107                {
 108                    fromDeepLink = configuration.debugOpenedFromDeepLink.ToString(),
 109                    enableNewTutorialCamera = false.ToString()
 110                }));
 111            }
 78112        }
 113
 114        public void Dispose()
 115        {
 39116            SetTutorialDisabled();
 117
 39118            DataStore.i.settings.isInitialized.OnChange -= IsSettingsHUDInitialized_OnChange;
 119
 39120            if (hudController != null &&
 121                hudController.settingsPanelHud != null)
 122            {
 0123                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 124            }
 125
 39126            NotificationsController.disableWelcomeNotification = false;
 127
 39128            if (tutorialView != null)
 39129                GameObject.Destroy(tutorialView.gameObject);
 39130        }
 131
 132        public void SetTutorialEnabled(string json)
 133        {
 0134            TutorialInitializationMessage msg = JsonUtility.FromJson<TutorialInitializationMessage>(json);
 0135            SetupTutorial(msg.fromDeepLink, msg.enableNewTutorialCamera, TutorialType.Initial);
 0136        }
 137
 138        public void SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(string json)
 139        {
 0140            TutorialInitializationMessage msg = JsonUtility.FromJson<TutorialInitializationMessage>(json);
 141
 142            // TODO (Santi): This a TEMPORAL fix. It will be removed when we refactorize the tutorial system in order to
 0143            if (PlayerPrefsUtils.GetInt(PLAYER_PREFS_START_MENU_SHOWED) == 1)
 0144                return;
 145
 0146            SetupTutorial(false.ToString(), msg.enableNewTutorialCamera, TutorialType.Initial, true);
 0147        }
 148
 0149        public void SetBuilderInWorldTutorialEnabled() { SetupTutorial(false.ToString(), false.ToString(), TutorialType.
 150
 151        /// <summary>
 152        /// Enables the tutorial controller and waits for the RenderingState is enabled to start to execute the correspo
 153        /// </summary>
 154        internal void SetupTutorial(string fromDeepLink, string enableNewTutorialCamera, TutorialType tutorialType, bool
 155        {
 1156            if (DataStore.i.common.isTutorialRunning.Get())
 0157                return;
 158
 1159            if (Convert.ToBoolean(enableNewTutorialCamera))
 160            {
 1161                configuration.eagleCamInitPosition = new Vector3(15, 115, -30);
 1162                configuration.eagleCamInitLookAtPoint = new Vector3(16, 105, 6);
 1163                configuration.eagleCamRotationActived = false;
 164            }
 165
 1166            DataStore.i.common.isTutorialRunning.Set(true);
 1167            DataStore.i.virtualAudioMixer.sceneSFXVolume.Set(0f);
 1168            this.userAlreadyDidTheTutorial = userAlreadyDidTheTutorial;
 1169            CommonScriptableObjects.allUIHidden.Set(false);
 1170            CommonScriptableObjects.tutorialActive.Set(true);
 1171            openedFromDeepLink = Convert.ToBoolean(fromDeepLink);
 1172            this.tutorialType = tutorialType;
 173
 1174            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(false);
 1175            hudController?.profileHud?.HideProfileMenu();
 176
 1177            NotificationsController.disableWelcomeNotification = true;
 178
 1179            WebInterface.SetDelightedSurveyEnabled(false);
 180
 1181            if (!CommonScriptableObjects.rendererState.Get())
 1182                CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
 183            else
 0184                OnRenderingStateChanged(true, false);
 185
 1186            OnTutorialEnabled?.Invoke();
 1187        }
 188
 189        /// <summary>
 190        /// Stop and disables the tutorial controller.
 191        /// </summary>
 192        public void SetTutorialDisabled()
 193        {
 65194            CommonScriptableObjects.featureKeyTriggersBlocked.Set(false);
 195
 65196            if (executeStepsCoroutine != null)
 197            {
 0198                CoroutineStarter.Stop(executeStepsCoroutine);
 0199                executeStepsCoroutine = null;
 200            }
 201
 65202            if (runningStep != null)
 203            {
 1204                UnityEngine.Object.Destroy(runningStep.gameObject);
 1205                runningStep = null;
 206            }
 207
 65208            tutorialReset = false;
 65209            DataStore.i.common.isTutorialRunning.Set(false);
 65210            DataStore.i.virtualAudioMixer.sceneSFXVolume.Set(1f);
 65211            ShowTeacher3DModel(false);
 65212            WebInterface.SetDelightedSurveyEnabled(true);
 213
 65214            if (Environment.i != null && Environment.i.world != null)
 215            {
 65216                WebInterface.SendSceneExternalActionEvent(Environment.i.world.state.currentSceneId, "tutorial", "end");
 217            }
 218
 65219            NotificationsController.disableWelcomeNotification = false;
 220
 65221            hudController?.settingsPanelHud?.SetTutorialButtonEnabled(true);
 222
 65223            CommonScriptableObjects.tutorialActive.Set(false);
 224
 65225            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 226
 65227            OnTutorialDisabled?.Invoke();
 2228        }
 229
 230        /// <summary>
 231        /// Starts to execute the tutorial from a specific step (It is needed to call SetTutorialEnabled() before).
 232        /// </summary>
 233        /// <param name="stepIndex">First step to be executed.</param>
 234        public IEnumerator StartTutorialFromStep(int stepIndex)
 235        {
 27236            if (!DataStore.i.common.isTutorialRunning.Get())
 2237                yield break;
 238
 25239            if (runningStep != null)
 240            {
 10241                runningStep.OnStepFinished();
 10242                GameObject.Destroy(runningStep.gameObject);
 10243                runningStep = null;
 244            }
 245
 25246            yield return new WaitUntil(IsPlayerInScene);
 247
 25248            playerIsInGenesisPlaza = IsPlayerInsideGenesisPlaza();
 249
 25250            switch (tutorialType)
 251            {
 252                case TutorialType.Initial:
 23253                    if (userAlreadyDidTheTutorial)
 254                    {
 2255                        yield return ExecuteSteps(TutorialPath.FromUserThatAlreadyDidTheTutorial, stepIndex);
 2256                    }
 21257                    else if (playerIsInGenesisPlaza || tutorialReset)
 258                    {
 19259                        if (tutorialReset)
 260                        {
 2261                            yield return ExecuteSteps(TutorialPath.FromResetTutorial, stepIndex);
 2262                        }
 263                        else
 264                        {
 17265                            yield return ExecuteSteps(TutorialPath.FromGenesisPlaza, stepIndex);
 266                        }
 17267                    }
 2268                    else if (openedFromDeepLink)
 269                    {
 2270                        yield return ExecuteSteps(TutorialPath.FromDeepLink, stepIndex);
 2271                    }
 272                    else
 273                    {
 0274                        SetTutorialDisabled();
 0275                        yield break;
 276                    }
 277
 278                    break;
 279                case TutorialType.BuilderInWorld:
 2280                    yield return ExecuteSteps(TutorialPath.FromBuilderInWorld, stepIndex);
 281                    break;
 282            }
 25283        }
 284
 285        /// <summary>
 286        /// Shows the teacher that will be guiding along the tutorial.
 287        /// </summary>
 288        /// <param name="active">True for show the teacher.</param>
 289        public void ShowTeacher3DModel(bool active)
 290        {
 160291            if (configuration.teacherCamera != null)
 160292                configuration.teacherCamera.enabled = active;
 293
 160294            if (configuration.teacherRawImage != null)
 115295                configuration.teacherRawImage.gameObject.SetActive(active);
 160296        }
 297
 298        /// <summary>
 299        /// Move the tutorial teacher to a specific position.
 300        /// </summary>
 301        /// <param name="position">Target position.</param>
 302        /// <param name="animated">True for apply a smooth movement.</param>
 303        public void SetTeacherPosition(Vector2 position, bool animated = true)
 304        {
 22305            if (teacherMovementCoroutine != null)
 0306                CoroutineStarter.Stop(teacherMovementCoroutine);
 307
 22308            if (configuration.teacherRawImage != null)
 309            {
 2310                if (animated)
 0311                    teacherMovementCoroutine = CoroutineStarter.Start(MoveTeacher(configuration.teacherRawImage.rectTran
 312                else
 2313                    configuration.teacherRawImage.rectTransform.position = position;
 314            }
 22315        }
 316
 317        /// <summary>
 318        /// Plays a specific animation on the tutorial teacher.
 319        /// </summary>
 320        /// <param name="animation">Animation to apply.</param>
 321        public void PlayTeacherAnimation(TutorialTeacher.TeacherAnimation animation)
 322        {
 44323            if (configuration.teacher == null)
 17324                return;
 325
 27326            configuration.teacher.PlayAnimation(animation);
 27327        }
 328
 329        /// <summary>
 330        /// Set sort order for canvas containing teacher RawImage
 331        /// </summary>
 332        /// <param name="sortOrder"></param>
 333        public void SetTeacherCanvasSortingOrder(int sortOrder)
 334        {
 14335            if (configuration.teacherCanvas == null)
 0336                return;
 337
 14338            configuration.teacherCanvas.sortingOrder = sortOrder;
 14339        }
 340
 341        /// <summary>
 342        /// Finishes the current running step, skips all the next ones and completes the tutorial.
 343        /// </summary>
 344        public void SkipTutorial(bool ignoreStatsSending = false)
 345        {
 5346            if (!ignoreStatsSending && !configuration.debugRunTutorial && configuration.sendStats)
 347            {
 0348                SendSkipTutorialSegmentStats(
 349                    configuration.tutorialVersion,
 350                    runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 351            }
 352
 5353            int skipIndex = configuration.stepsOnGenesisPlaza.Count +
 354                            configuration.stepsFromDeepLink.Count +
 355                            configuration.stepsFromReset.Count +
 356                            configuration.stepsFromBuilderInWorld.Count +
 357                            configuration.stepsFromUserThatAlreadyDidTheTutorial.Count;
 358
 5359            CoroutineStarter.Start(StartTutorialFromStep(skipIndex));
 360
 5361            hudController?.taskbarHud?.SetVisibility(true);
 0362        }
 363
 364        /// <summary>
 365        /// Jump to a specific step.
 366        /// </summary>
 367        /// <param name="stepIndex">Step to jump.</param>
 368        public void GoToSpecificStep(string stepName)
 369        {
 0370            int stepIndex = 0;
 0371            switch (tutorialType)
 372            {
 373                case TutorialType.Initial:
 0374                    if (userAlreadyDidTheTutorial)
 375                    {
 0376                        stepIndex = configuration.stepsFromUserThatAlreadyDidTheTutorial.FindIndex(x => x.name == stepNa
 0377                    }
 0378                    else if (playerIsInGenesisPlaza || tutorialReset)
 379                    {
 0380                        if (tutorialReset)
 381                        {
 0382                            stepIndex = configuration.stepsFromReset.FindIndex(x => x.name == stepName);
 0383                        }
 384                        else
 385                        {
 0386                            stepIndex = configuration.stepsOnGenesisPlaza.FindIndex(x => x.name == stepName);
 387                        }
 0388                    }
 0389                    else if (openedFromDeepLink)
 390                    {
 0391                        stepIndex = configuration.stepsFromDeepLink.FindIndex(x => x.name == stepName);
 392                    }
 0393                    break;
 394                case TutorialType.BuilderInWorld:
 0395                    stepIndex = configuration.stepsFromBuilderInWorld.FindIndex(x => x.name == stepName);
 396                    break;
 397            }
 398
 0399            nextStepsToSkip = 0;
 400
 0401            if (stepIndex >= 0)
 0402                CoroutineStarter.Start(StartTutorialFromStep(stepIndex));
 403            else
 0404                SkipTutorial(true);
 0405        }
 406
 407        /// <summary>
 408        /// Set the number of steps that will be skipped in the next iteration.
 409        /// </summary>
 410        /// <param name="skippedSteps">Number of steps to skip.</param>
 0411        public void SetNextSkippedSteps(int skippedSteps) { nextStepsToSkip = skippedSteps; }
 412
 413        /// <summary>
 414        /// Activate/deactivate the eagle eye camera.
 415        /// </summary>
 416        /// <param name="isActive">True for activate the eagle eye camera.</param>
 417        public void SetEagleEyeCameraActive(bool isActive)
 418        {
 6419            configuration.eagleEyeCamera.gameObject.SetActive(isActive);
 6420            CoroutineStarter.Start(BlockPlayerCameraUntilBlendingIsFinished(isActive));
 421
 6422            if (isActive)
 423            {
 3424                configuration.eagleEyeCamera.transform.position = configuration.eagleCamInitPosition;
 3425                configuration.eagleEyeCamera.transform.LookAt(configuration.eagleCamInitLookAtPoint);
 426
 3427                if (configuration.eagleCamRotationActived)
 2428                    eagleEyeRotationCoroutine = CoroutineStarter.Start(EagleEyeCameraRotation(configuration.eagleCamRota
 2429            }
 3430            else if (eagleEyeRotationCoroutine != null)
 431            {
 2432                CoroutineStarter.Stop(eagleEyeRotationCoroutine);
 433            }
 4434        }
 435
 436        internal void OnRenderingStateChanged(bool renderingEnabled, bool prevState)
 437        {
 2438            if (!renderingEnabled)
 0439                return;
 440
 2441            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 442
 2443            if (configuration.debugRunTutorial)
 1444                currentStepIndex = configuration.debugStartingStepIndex >= 0 ? configuration.debugStartingStepIndex : 0;
 445            else
 1446                currentStepIndex = 0;
 447
 2448            PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.Reset);
 2449            executeStepsCoroutine = CoroutineStarter.Start(StartTutorialFromStep(currentStepIndex));
 2450        }
 451
 452        private IEnumerator ExecuteSteps(TutorialPath tutorialPath, int startingStepIndex)
 453        {
 25454            List<TutorialStep> steps = new List<TutorialStep>();
 455
 456            switch (tutorialPath)
 457            {
 458                case TutorialPath.FromGenesisPlaza:
 17459                    steps = configuration.stepsOnGenesisPlaza;
 17460                    break;
 461                case TutorialPath.FromDeepLink:
 2462                    steps = configuration.stepsFromDeepLink;
 2463                    break;
 464                case TutorialPath.FromResetTutorial:
 2465                    steps = configuration.stepsFromReset;
 2466                    break;
 467                case TutorialPath.FromBuilderInWorld:
 2468                    steps = configuration.stepsFromBuilderInWorld;
 2469                    break;
 470                case TutorialPath.FromUserThatAlreadyDidTheTutorial:
 2471                    steps = configuration.stepsFromUserThatAlreadyDidTheTutorial;
 472                    break;
 473            }
 474
 25475            currentPath = tutorialPath;
 476
 25477            elapsedTimeInCurrentStep = 0f;
 130478            for (int i = startingStepIndex; i < steps.Count; i++)
 479            {
 40480                if (nextStepsToSkip > 0)
 481                {
 0482                    nextStepsToSkip--;
 0483                    continue;
 484                }
 485
 40486                var stepPrefab = steps[i];
 487
 488                // TODO (Santi): This a TEMPORAL fix. It will be removed when we refactorize the tutorial system in orde
 40489                if (stepPrefab is TutorialStep_Tooltip_ExploreButton &&
 490                    !DataStore.i.exploreV2.isInitialized.Get())
 491                    continue;
 492
 40493                if (stepPrefab.letInstantiation)
 15494                    runningStep = GameObject.Instantiate(stepPrefab, tutorialView.transform).GetComponent<TutorialStep>(
 495                else
 25496                    runningStep = steps[i];
 497
 40498                runningStep.gameObject.name = runningStep.gameObject.name.Replace("(Clone)", "");
 40499                currentStepIndex = i;
 500
 40501                elapsedTimeInCurrentStep = Time.realtimeSinceStartup;
 40502                currentStepNumber = i + 1;
 503
 40504                if (!configuration.debugRunTutorial && configuration.sendStats)
 505                {
 0506                    SendStepStartedSegmentStats(
 507                        configuration.tutorialVersion,
 508                        tutorialPath,
 509                        i + 1,
 510                        runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""));
 511                }
 512
 40513                runningStep.OnStepStart();
 40514                yield return runningStep.OnStepExecute();
 40515                if (i < steps.Count - 1)
 20516                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.StepCompleted);
 517                else
 20518                    PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.QuickGoodbye);
 519
 40520                yield return runningStep.OnStepPlayHideAnimation();
 40521                runningStep.OnStepFinished();
 40522                elapsedTimeInCurrentStep = Time.realtimeSinceStartup - elapsedTimeInCurrentStep;
 523
 40524                if (!configuration.debugRunTutorial &&
 525                    configuration.sendStats &&
 526                    tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 527                {
 0528                    SendStepCompletedSegmentStats(
 529                        configuration.tutorialVersion,
 530                        tutorialPath,
 531                        i + 1,
 532                        runningStep.name.Replace("(Clone)", "").Replace("TutorialStep_", ""),
 533                        elapsedTimeInCurrentStep);
 534                }
 535
 40536                GameObject.Destroy(runningStep.gameObject);
 537
 40538                if (i < steps.Count - 1 && configuration.timeBetweenSteps > 0)
 0539                    yield return new WaitForSeconds(configuration.timeBetweenSteps);
 540            }
 541
 25542            if (!configuration.debugRunTutorial &&
 543                tutorialPath != TutorialPath.FromBuilderInWorld &&
 544                tutorialPath != TutorialPath.FromUserThatAlreadyDidTheTutorial)
 545            {
 21546                SetUserTutorialStepAsCompleted(TutorialFinishStep.NewTutorialFinished);
 547            }
 548
 25549            runningStep = null;
 550
 25551            SetTutorialDisabled();
 25552        }
 553
 42554        private void SetUserTutorialStepAsCompleted(TutorialFinishStep finishStepType) { WebInterface.SaveUserTutorialSt
 555
 556        internal IEnumerator MoveTeacher(Vector2 fromPosition, Vector2 toPosition)
 557        {
 1558            if (configuration.teacherRawImage == null)
 0559                yield break;
 560
 1561            float t = 0f;
 562
 2563            while (Vector2.Distance(configuration.teacherRawImage.rectTransform.position, toPosition) > 0)
 564            {
 2565                t += configuration.teacherMovementSpeed * Time.deltaTime;
 2566                if (t <= 1.0f)
 2567                    configuration.teacherRawImage.rectTransform.position = Vector2.Lerp(fromPosition, toPosition, config
 568                else
 0569                    configuration.teacherRawImage.rectTransform.position = toPosition;
 570
 2571                yield return null;
 572            }
 0573        }
 574
 575        private void IsSettingsHUDInitialized_OnChange(bool current, bool previous)
 576        {
 0577            if (current &&
 578                hudController != null &&
 579                hudController.settingsPanelHud != null)
 580            {
 0581                hudController.settingsPanelHud.OnRestartTutorial -= OnRestartTutorial;
 0582                hudController.settingsPanelHud.OnRestartTutorial += OnRestartTutorial;
 583            }
 0584        }
 585
 586        internal void OnRestartTutorial()
 587        {
 0588            SetTutorialDisabled();
 0589            tutorialReset = true;
 0590            SetTutorialEnabled(JsonUtility.ToJson(new TutorialInitializationMessage
 591            {
 592                fromDeepLink = false.ToString(),
 593                enableNewTutorialCamera = false.ToString()
 594            }));
 0595        }
 596
 597        internal bool IsPlayerInScene()
 598        {
 25599            IWorldState worldState = Environment.i.world.state;
 600
 25601            if (worldState == null || worldState.currentSceneId == null)
 0602                return false;
 603
 25604            return true;
 605        }
 606
 607        internal static bool IsPlayerInsideGenesisPlaza()
 608        {
 25609            if (Environment.i.world == null)
 0610                return false;
 611
 25612            IWorldState worldState = Environment.i.world.state;
 613
 25614            if (worldState == null || worldState.currentSceneId == null)
 0615                return false;
 616
 25617            Vector2Int genesisPlazaBaseCoords = new Vector2Int(-9, -9);
 618
 25619            IParcelScene currentScene = null;
 25620            if (worldState.loadedScenes != null)
 25621                currentScene = worldState.loadedScenes[worldState.currentSceneId];
 622
 25623            if (currentScene != null && currentScene.IsInsideSceneBoundaries(genesisPlazaBaseCoords))
 21624                return true;
 625
 4626            return false;
 627        }
 628
 629        private void SendStepStartedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepName
 630        {
 0631            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 632            {
 633                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 634                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 635                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 636                new WebInterface.AnalyticsPayload.Property("step name", stepName)
 637            };
 0638            WebInterface.ReportAnalyticsEvent("tutorial step started", properties);
 0639        }
 640
 641        private void SendStepCompletedSegmentStats(int version, TutorialPath tutorialPath, int stepNumber, string stepNa
 642        {
 0643            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 644            {
 645                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 646                new WebInterface.AnalyticsPayload.Property("path", tutorialPath.ToString()),
 647                new WebInterface.AnalyticsPayload.Property("step number", stepNumber.ToString()),
 648                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 649                new WebInterface.AnalyticsPayload.Property("elapsed time", elapsedTime.ToString("0.00"))
 650            };
 0651            WebInterface.ReportAnalyticsEvent("tutorial step completed", properties);
 0652        }
 653
 654        private void SendSkipTutorialSegmentStats(int version, string stepName)
 655        {
 0656            WebInterface.AnalyticsPayload.Property[] properties = new WebInterface.AnalyticsPayload.Property[]
 657            {
 658                new WebInterface.AnalyticsPayload.Property("version", version.ToString()),
 659                new WebInterface.AnalyticsPayload.Property("path", currentPath.ToString()),
 660                new WebInterface.AnalyticsPayload.Property("step number", currentStepNumber.ToString()),
 661                new WebInterface.AnalyticsPayload.Property("step name", stepName),
 662                new WebInterface.AnalyticsPayload.Property("elapsed time", (Time.realtimeSinceStartup - elapsedTimeInCur
 663            };
 0664            WebInterface.ReportAnalyticsEvent("tutorial skipped", properties);
 0665        }
 666
 667        internal IEnumerator EagleEyeCameraRotation(float rotationSpeed)
 668        {
 2669            while (true)
 670            {
 4671                configuration.eagleEyeCamera.transform.Rotate(Vector3.up * Time.deltaTime * rotationSpeed, Space.World);
 4672                yield return null;
 673            }
 674        }
 675
 676        private IEnumerator BlockPlayerCameraUntilBlendingIsFinished(bool hideUIs)
 677        {
 6678            if (hideUIs)
 679            {
 3680                hudController?.minimapHud?.SetVisibility(false);
 3681                hudController?.profileHud?.SetVisibility(false);
 682            }
 683
 6684            CommonScriptableObjects.cameraBlocked.Set(true);
 685
 6686            yield return null;
 12687            yield return new WaitUntil(() => !CommonScriptableObjects.cameraIsBlending.Get());
 688
 6689            CommonScriptableObjects.cameraBlocked.Set(false);
 690
 6691            if (!hideUIs)
 692            {
 3693                hudController?.minimapHud?.SetVisibility(true);
 3694                hudController?.profileHud?.SetVisibility(true);
 695            }
 6696        }
 697    }
 698}

Methods/Properties

i()
i(DCL.Tutorial.TutorialController)
hudController()
currentStepIndex()
currentStepIndex(System.Int32)
userAlreadyDidTheTutorial()
userAlreadyDidTheTutorial(System.Boolean)
TutorialController()
CreateTutorialView()
SetConfiguration(DCL.Tutorial.TutorialSettings)
Dispose()
SetTutorialEnabled(System.String)
SetTutorialEnabledForUsersThatAlreadyDidTheTutorial(System.String)
SetBuilderInWorldTutorialEnabled()
SetupTutorial(System.String, System.String, DCL.Tutorial.TutorialController/TutorialType, System.Boolean)
SetTutorialDisabled()
StartTutorialFromStep()
ShowTeacher3DModel(System.Boolean)
SetTeacherPosition(UnityEngine.Vector2, System.Boolean)
PlayTeacherAnimation(DCL.Tutorial.TutorialTeacher/TeacherAnimation)
SetTeacherCanvasSortingOrder(System.Int32)
SkipTutorial(System.Boolean)
GoToSpecificStep(System.String)
SetNextSkippedSteps(System.Int32)
SetEagleEyeCameraActive(System.Boolean)
OnRenderingStateChanged(System.Boolean, System.Boolean)
ExecuteSteps()
SetUserTutorialStepAsCompleted(DCL.Tutorial.TutorialController/TutorialFinishStep)
MoveTeacher()
IsSettingsHUDInitialized_OnChange(System.Boolean, System.Boolean)
OnRestartTutorial()
IsPlayerInScene()
IsPlayerInsideGenesisPlaza()
SendStepStartedSegmentStats(System.Int32, DCL.Tutorial.TutorialController/TutorialPath, System.Int32, System.String)
SendStepCompletedSegmentStats(System.Int32, DCL.Tutorial.TutorialController/TutorialPath, System.Int32, System.String, System.Single)
SendSkipTutorialSegmentStats(System.Int32, System.String)
EagleEyeCameraRotation()
BlockPlayerCameraUntilBlendingIsFinished()