public override void Clear()
        {
            algorithmSelection.Algorithm.OnValueChangedHandler -= OnAlgorithmChanged;

            teamToggle.OnCourseSelectedHandler -= OnCourseSelected;

            teamToggle.OnCourseToggledHandler -= OnCourseToggled;

            sidebar.IsToggleAlgorithm.OnValueChangedHandler -= OnAlgorithmToggled;

            sidebar.IsToggleGreyboxLabyrinth.OnValueChangedHandler -= OnGreyBoxToggled;


            base.Clear();

            first = null;

            if (algorithmSequence != null)
            {
                algorithmSequence.OnMoveIndexChangedHandler -= algorithmSelection.OnAlgorithmMoveIndexChanged;

                algorithmSequence.gameObject.Destroy();

                algorithmSequence = null;
            }


            if (labyrinthObject != null)
            {
                labyrinthObject.gameObject.Destroy();
                labyrinthObject = null;
            }

            foreach (var team in playerSequences)
            {
                if (team.Value == null)
                {
                    continue;
                }

                team.Value.gameObject.Destroy();
            }


            playerSequences.Clear();

            activeSequences.Clear();

            teamToggle.OnReplayCourseRemoveAllHandler?.Invoke();
        }
        public override void Initialize()
        {
            base.Initialize();

            // TODO playback
            controls.PlaybackSpeed = 2f;

            labyrinthObject = Labyrinths.Resources.Instance
                              .GetLabyrinthObject(level.Labyrinth)
                              .Create(level.Labyrinth);

            labyrinthObject.GenerateLabyrinthVisual();

            labyrinthObject.Init(enableCamera: true);

            labyrinthObject.Camera.OutputToTexture = true;

            UI.ReplayDisplay.Instance.ViewRawImage.texture = labyrinthObject.Camera.RenderTexture;

            lposition = labyrinthObject.GetLabyrithStartPosition();

            wposition = labyrinthObject.GetLabyrinthPositionInWorldPosition(lposition);

            algorithmSequence =
                Resources.Instance.AlgorithmSequence.Create(
                    this,
                    labyrinthObject,
                    level.Algorithm,
                    lposition
                    );

            algorithmSequence.OnMoveIndexChangedHandler += algorithmSelection.OnAlgorithmMoveIndexChanged;

            //algorithmSequence.OnChangedHandler += OnAlgorithmChanged;

            SetMoveCount();

            //algorithmSelection.Algorithm.OnValueChangedHandler += (x) => algorithmSequence.Algorithm = x;

            foreach (Course course in level.Courses)
            {
                AddCourse(course);
            }
        }