< Summary

Class:DCL.Tutorial.TutorialStep_GenesisGreetings
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_GenesisGreetings.cs
Covered lines:0
Uncovered lines:32
Coverable lines:32
Total lines:91
Line coverage:0% (0 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnStepStart()0%56700%
OnStepExecute()0%12300%
OnStepPlayHideAnimation()0%20400%
OnStepFinished()0%2100%
OnOkButtonClick()0%2100%
OnChangePlayerCoords(...)0%20400%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_GenesisGreetings.cs

#LineLine coverage
 1using DCL.Interface;
 2using System.Collections;
 3using TMPro;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7namespace DCL.Tutorial
 8{
 9    /// <summary>
 10    /// Class that represents the onboarding tutorial step related to the greetings showed in Genesis Plaza.
 11    /// </summary>
 12    public class TutorialStep_GenesisGreetings : TutorialStep
 13    {
 14        private const int TEACHER_CANVAS_SORT_ORDER_START = 4;
 15        private const int GENESIS_PLAZA_TUTORIAL_LOCATION = 3;
 16
 17        [SerializeField]
 18        Button okButton;
 19
 20        [SerializeField]
 21        TMP_Text titleText;
 22
 23        private bool stepIsFinished = false;
 24        private int defaultTeacherCanvasSortOrder;
 25
 26        public override void OnStepStart()
 27        {
 028            base.OnStepStart();
 29
 030            OnChangePlayerCoords(new Vector2Int(0, 0), CommonScriptableObjects.playerCoords.Get());
 031            CommonScriptableObjects.playerCoords.OnChange += OnChangePlayerCoords;
 32
 033            CommonScriptableObjects.userMovementKeysBlocked.Set(true);
 034            CommonScriptableObjects.featureKeyTriggersBlocked.Set(true);
 35
 036            titleText.text = titleText.text.Replace("{userName}", UserProfile.GetOwnUserProfile().userName);
 37
 038            okButton.onClick.AddListener(OnOkButtonClick);
 39
 040            if (tutorialController != null)
 41            {
 042                tutorialController.SetEagleEyeCameraActive(true);
 43
 044                if (tutorialController.configuration.teacherCanvas != null)
 045                    defaultTeacherCanvasSortOrder = tutorialController.configuration.teacherCanvas.sortingOrder;
 46
 047                tutorialController.SetTeacherCanvasSortingOrder(TEACHER_CANVAS_SORT_ORDER_START);
 48
 049                tutorialController.hudController?.taskbarHud?.SetVisibility(false);
 50
 051                if (Environment.i != null && Environment.i.world != null)
 52                {
 053                    WebInterface.SendSceneExternalActionEvent(Environment.i.world.state.GetCurrentSceneNumber(), "tutori
 54                }
 55            }
 056        }
 57
 058        public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); }
 59
 60        public override IEnumerator OnStepPlayHideAnimation()
 61        {
 062            tutorialController?.SetEagleEyeCameraActive(false);
 063            yield return base.OnStepPlayHideAnimation();
 064        }
 65
 66        public override void OnStepFinished()
 67        {
 068            base.OnStepFinished();
 069            tutorialController.SetTeacherCanvasSortingOrder(defaultTeacherCanvasSortOrder);
 70
 071            CommonScriptableObjects.userMovementKeysBlocked.Set(false);
 72
 073            CommonScriptableObjects.playerCoords.OnChange -= OnChangePlayerCoords;
 074        }
 75
 076        internal void OnOkButtonClick() { stepIsFinished = true; }
 77
 78        private void OnChangePlayerCoords(Vector2Int prevCoords, Vector2Int coords)
 79        {
 080            if (stepIsFinished)
 081                return;
 82
 083            if (Mathf.Abs(coords.x) > GENESIS_PLAZA_TUTORIAL_LOCATION ||
 84                Mathf.Abs(coords.y) > GENESIS_PLAZA_TUTORIAL_LOCATION)
 85            {
 086                stepIsFinished = true;
 087                return;
 88            }
 089        }
 90    }
 91}