< Summary

Class:Timer
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/Edutainment-Escape-Room/Assets/Scripts/Test/Final Puzzle Room/Timer.cs
Covered lines:20
Uncovered lines:33
Coverable lines:53
Total lines:90
Line coverage:37.7% (20 of 53)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:8
Method coverage:62.5% (5 of 8)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Timer()0%000100%
Start()0%000100%
Update()0%00023.53%
removeOutOfTime()0%0000%
onOutOfTime()0%0000%
TimeDisplay(...)0%00066.67%
OnTriggerEnter(...)0%0000%
onWin()0%000100%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/Edutainment-Escape-Room/Assets/Scripts/Test/Final Puzzle Room/Timer.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.UI;
 5using TMPro;
 6using System;
 7
 8public class Timer : MonoBehaviour
 9{
 10    public ExitDoor exitDoor;
 211    public float timeCountdown = 180;
 12    public TextMeshProUGUI timerText;
 213    public bool StartTimer = false;
 14    [SerializeField] private AudioSource myAudio;
 15    private bool gameDone;
 216    public int oneTimeEvent = 1;
 17
 18    public Clock clock;
 19
 20    public GameObject tempOutOfTime;
 21
 222    public bool outOfTime = false;
 23
 24    public void Start()
 125    {
 126        tempOutOfTime.SetActive(false);
 127    }
 28
 29    // Update is called once per frame
 30    void Update()
 273531    {
 273532        if (StartTimer == true && !gameDone)
 033        {
 034            if (timeCountdown > 0)
 035            {
 036                timeCountdown -= Time.deltaTime;
 037            }
 38            else
 039            {
 040                if(!outOfTime)
 041                {
 042                    timeCountdown = 0;
 043                    onOutOfTime();
 044                }
 045            }
 046        }
 273547        TimeDisplay(timeCountdown);
 273548    }
 49
 50    internal void removeOutOfTime()
 051    {
 052        tempOutOfTime.SetActive(false);
 053    }
 54
 55    private void onOutOfTime()
 056    {
 057        tempOutOfTime.SetActive(true);
 058        outOfTime = true;
 059        clock.onTimeOut();
 060        exitDoor.onFinish();
 061    }
 62
 63    void TimeDisplay(float timeToDisplay)
 273564    {
 273565        if(timeToDisplay < 0)
 066        {
 067            timeToDisplay = 0;
 068        }
 69
 273570        float minutes = Mathf.FloorToInt(timeToDisplay / 60);
 273571        float seconds = Mathf.FloorToInt(timeToDisplay % 60);
 273572        timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
 273573    }
 74
 75    public void OnTriggerEnter(Collider other)
 076    {
 077        StartTimer = true;
 78
 079        if (oneTimeEvent == 1)
 080        {
 081            myAudio.Play();
 082            oneTimeEvent += 1;
 083        }
 084    }
 85
 86    public void onWin()
 387    {
 388        gameDone = true;
 389    }
 90}