< Summary

Class:XRTarget
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/VGuns-Unity-VR/Assets/Test/XRTarget.cs
Covered lines:39
Uncovered lines:2
Coverable lines:41
Total lines:99
Line coverage:95.1% (39 of 41)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:3
Method coverage:100% (3 of 3)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Update()0%00090.91%
Wait()0%000100%
Hit(...)0%000100%

File(s)

D:/--UnityProject/VR/VRExplorer_subjects/VGuns-Unity-VR/Assets/Test/XRTarget.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using TMPro;
 5using UnityEngine;
 6using UnityEngine.SceneManagement;
 7
 8public class XRTarget : MonoBehaviour {
 9
 10    public float health;
 11
 12    public TextMeshPro livesText;
 13
 14    public GameObject deathScreen;
 15
 16    public GameObject LocomotionSystem;
 17
 18    public GameObject ray_Right;
 19    public GameObject ray_Left;
 20
 21    public GameObject TeleportManagerLeft;
 22    public GameObject TeleportManagerRight;
 23
 24    public GameObject[] enemies;
 25
 26
 27    void Update()
 719828    {
 719829        livesText.text = "Health: " + health;
 30
 982031        if(health <= 0) {
 262232            if (deathScreen.activeSelf)
 262133            {
 262134                enemies = GameObject.FindGameObjectsWithTag("Enemy");
 35
 786336                foreach (GameObject enemy in enemies){
 037                    enemy.SetActive(false);
 038                }
 39
 262140                ray_Right.SetActive(true);
 262141                ray_Left.SetActive(true);
 42
 262143                LocomotionSystem.SetActive(false);
 44
 262145                TeleportManagerLeft.SetActive(false);
 262146                TeleportManagerRight.SetActive(false);
 47
 262148                deathScreen.SetActive(true);
 49
 262150                StartCoroutine(Wait());
 51
 52                //SceneManager.LoadScene(0);
 262153            }
 54            else
 155            {
 156                if (!deathScreen.activeSelf)
 157                {
 58
 159                    enemies = GameObject.FindGameObjectsWithTag("Enemy");
 60
 1861                    foreach (GameObject enemy in enemies){
 562                        enemy.SetActive(false);
 563                    }
 64
 65
 166                    ray_Right.SetActive(true);
 167                    ray_Left.SetActive(true);
 68
 169                    LocomotionSystem.SetActive(false);
 70
 171                    TeleportManagerLeft.SetActive(false);
 172                    TeleportManagerRight.SetActive(false);
 73
 174                    deathScreen.SetActive(true);
 75
 176                    StartCoroutine(Wait());
 77
 78                    //SceneManager.LoadScene(0);
 179                }
 80
 181            }
 82
 262283        }
 719884    }
 85
 86
 87    IEnumerator Wait()
 262288    {
 89        //yield on a new YieldInstruction that waits for 5 seconds.
 262290        yield return new WaitForSecondsRealtime(5);
 201891    }
 92
 93
 94    /// 'Hits' the target for a certain amount of damage
 4495    public void Hit(float damage) {
 4496        health -= damage;
 4497    }
 98
 99}

Methods/Properties

Update()
Wait()
Hit(System.Single)