< Summary

Class:Round
Assembly:Test
File(s):D:/--UnityProject/VR/VRExplorer_subjects/VGuns-Unity-VR/Assets/Test/Round.cs
Covered lines:28
Uncovered lines:11
Coverable lines:39
Total lines:83
Line coverage:71.7% (28 of 39)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
OnTriggerEnter(...)0%00066.67%
Wait()0%000100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using Unity.XR.CoreUtils;
 4using UnityEngine;
 5using UnityEngine.XR.Interaction.Toolkit;
 6
 7public class Round : MonoBehaviour
 8{
 9
 10    public GameObject self;
 11
 12    public GameObject explosion;
 13
 14    public Rigidbody Rigidbody;
 15
 16    public int damage;
 17
 18
 19    void OnTriggerEnter(Collider other)
 59420    {
 59421        Target target = other.gameObject.GetComponent<Target>();
 22
 59423        if (target != null)
 024        {
 025            Debug.Log("Hit");
 26
 027            target.Hit(damage);
 28
 029            Instantiate(explosion, self.transform.position, self.transform.rotation);
 30
 031            Destroy(gameObject); // Deletes the round
 032        }
 33        else
 59434        {
 59435            StartCoroutine(Wait());
 59436        }
 37
 59438        XRTarget XRTarget = other.gameObject.GetComponent<XRTarget>();
 39        // Only attempts to inflict damage if the other game object has
 40        // the 'EnemyAi' component
 59441        if (XRTarget != null)
 4542        {
 4543            Debug.Log("Hit");
 44
 4545            XRTarget.Hit(damage);
 46
 4547            Destroy(gameObject); // Deletes the round
 48
 4549        }
 50
 51        else
 54952        {
 54953            StartCoroutine(Wait());
 54954        }
 55
 59456        EnemyAi EnemyHealth = other.gameObject.GetComponent<EnemyAi>();
 57        // Only attempts to inflict damage if the other game object has
 58        // the 'EnemyAi' component
 59459        if (EnemyHealth != null)
 060        {
 061            Debug.Log("Hit");
 62
 063            EnemyHealth.TakeDamage(damage);
 64
 065            Destroy(gameObject); // Deletes the round
 66
 067        }
 68        else
 59469        {
 59470            StartCoroutine(Wait());
 71
 59472        }
 59473    }
 74
 75    IEnumerator Wait() //  <-  its a standalone method
 173776    {
 173777        Debug.Log("Hello");
 78        //wait 3 seconds
 173779        yield return new WaitForSeconds(5);
 72680        Debug.Log("Goodbye");
 72681        Destroy(gameObject); // Deletes the round
 72682    }
 83}