< Summary

Class:DCL.Controllers.BlockerAnimationHandler
Assembly:WorldBlockersController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BlockerController/BlockerAnimationHandler.cs
Covered lines:5
Uncovered lines:13
Coverable lines:18
Total lines:56
Line coverage:27.7% (5 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FadeIn(...)0%110100%
FadeOut(...)0%2100%
FadeInCoroutine()0%5.264057.14%
FadeOutCoroutine()0%42600%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BlockerController/BlockerAnimationHandler.cs

#LineLine coverage
 1using System.Collections;
 2using DCL.Helpers;
 3using UnityEngine;
 4
 5namespace DCL.Controllers
 6{
 7    public interface IBlockerAnimationHandler
 8    {
 9        void FadeIn(GameObject go);
 10        void FadeOut(GameObject go, System.Action OnFinish);
 11    }
 12
 13    /// <summary>
 14    /// This class is in charge of handling the FadeIn/FadeOut animation
 15    /// of blockers.
 16    /// </summary>
 17    public class BlockerAnimationHandler : IBlockerAnimationHandler
 18    {
 4819        public void FadeIn(GameObject go) { CoroutineStarter.Start(FadeInCoroutine(go)); }
 20
 021        public void FadeOut(GameObject go, System.Action OnFinish) { CoroutineStarter.Start(FadeOutCoroutine(go, OnFinis
 22
 23        IEnumerator FadeInCoroutine(GameObject go)
 24        {
 2425            Renderer rend = go.GetComponent<Renderer>();
 26
 2427            Color color = rend.material.GetColor(ShaderUtils.BaseColor);
 28
 2429            while (color.a < 0.5f)
 30            {
 031                color.a += Time.deltaTime;
 032                rend.material.SetColor(ShaderUtils.BaseColor, color);
 033                yield return null;
 34            }
 2435        }
 36
 37        IEnumerator FadeOutCoroutine(GameObject go, System.Action OnFinish)
 38        {
 039            Renderer rend = go.GetComponent<Renderer>();
 40
 041            Color color = rend.material.GetColor(ShaderUtils.BaseColor);
 42
 043            while (color.a > 0)
 44            {
 045                if (rend == null)
 46                    break;
 47
 048                color.a -= Time.deltaTime;
 049                rend.material.SetColor(ShaderUtils.BaseColor, color);
 050                yield return null;
 51            }
 52
 053            OnFinish?.Invoke();
 054        }
 55    }
 56}