< Summary

Class:Timer
Assembly:Assembly-CSharp
File(s):D:/--UnityProject/VR/_____ISSTA 26/Edutainment-Escape-Room/Assets/Scripts/Test2/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%000100%
onOutOfTime()0%0000%
TimeDisplay(...)0%00066.67%
OnTriggerEnter(...)0%0000%
onWin()0%0000%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/Edutainment-Escape-Room/Assets/Scripts/Test2/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;
 1211    public float timeCountdown = 180;
 12    public TextMeshProUGUI timerText;
 1213    public bool StartTimer = false;
 14    [SerializeField] private AudioSource myAudio;
 15    private bool gameDone;
 1216    public int oneTimeEvent = 1;
 17
 18    public Clock clock;
 19
 20    public GameObject tempOutOfTime;
 21
 1222    public bool outOfTime = false;
 23
 24    public void Start()
 625    {
 626        tempOutOfTime.SetActive(false);
 627    }
 28
 29    // Update is called once per frame
 30    void Update()
 1220631    {
 1220632        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        }
 1220647        TimeDisplay(timeCountdown);
 1220648    }
 49
 50    internal void removeOutOfTime()
 451    {
 452        tempOutOfTime.SetActive(false);
 453    }
 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)
 1220664    {
 1220665        if(timeToDisplay < 0)
 066        {
 067            timeToDisplay = 0;
 068        }
 69
 1220670        float minutes = Mathf.FloorToInt(timeToDisplay / 60);
 1220671        float seconds = Mathf.FloorToInt(timeToDisplay % 60);
 1220672        timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
 1220673    }
 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()
 087    {
 088        gameDone = true;
 089    }
 90}