< Summary

Class:LoadingHUD.LoadingTipsRandomizer
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingTipsRandomizer.cs
Covered lines:12
Uncovered lines:1
Coverable lines:13
Total lines:52
Line coverage:92.3% (12 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LoadingTipsRandomizer()0%110100%
Awake()0%220100%
ShowRandomTipsRoutine()0%3.143075%
SetTip(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingTipsRandomizer.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5using TMPro;
 6using UnityEngine;
 7using UnityEngine.UI;
 8
 9namespace LoadingHUD
 10{
 11
 12    public class LoadingTipsRandomizer : MonoBehaviour
 13    {
 14        [SerializeField] internal LoadingTip[] tips;
 15        [SerializeField] internal Image image;
 16        [SerializeField] internal TextMeshProUGUI label;
 1117        [SerializeField] internal float secondsBetweenTips = 7.5f;
 18
 1119        private List<LoadingTip> randomizedTips = new List<LoadingTip>();
 1120        private int tipIndex = -1;
 21
 22        private void Awake()
 23        {
 824            randomizedTips = tips.OrderBy(x => Guid.NewGuid()).ToList();
 125            StartCoroutine(ShowRandomTipsRoutine());
 126        }
 27
 28        private IEnumerator ShowRandomTipsRoutine()
 29        {
 030            while (true)
 31            {
 132                tipIndex = (tipIndex + 1) % randomizedTips.Count;
 133                SetTip(randomizedTips[tipIndex]);
 134                yield return WaitForSecondsCache.Get(secondsBetweenTips);
 35            }
 36        }
 37
 38        private void SetTip(LoadingTip tip)
 39        {
 140            label.text = tip.text;
 141            image.sprite = tip.sprite;
 142        }
 43    }
 44
 45    [Serializable]
 46    public class LoadingTip
 47    {
 48        public string text;
 49        public Sprite sprite;
 50    }
 51
 52}