< 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)
 59020    {
 59021        Target target = other.gameObject.GetComponent<Target>();
 22
 59023        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
 59034        {
 59035            StartCoroutine(Wait());
 59036        }
 37
 59038        XRTarget XRTarget = other.gameObject.GetComponent<XRTarget>();
 39        // Only attempts to inflict damage if the other game object has
 40        // the 'EnemyAi' component
 59041        if (XRTarget != null)
 4442        {
 4443            Debug.Log("Hit");
 44
 4445            XRTarget.Hit(damage);
 46
 4447            Destroy(gameObject); // Deletes the round
 48
 4449        }
 50
 51        else
 54652        {
 54653            StartCoroutine(Wait());
 54654        }
 55
 59056        EnemyAi EnemyHealth = other.gameObject.GetComponent<EnemyAi>();
 57        // Only attempts to inflict damage if the other game object has
 58        // the 'EnemyAi' component
 59059        if (EnemyHealth != null)
 060        {
 061            Debug.Log("Hit");
 62
 063            EnemyHealth.TakeDamage(damage);
 64
 065            Destroy(gameObject); // Deletes the round
 66
 067        }
 68        else
 59069        {
 59070            StartCoroutine(Wait());
 71
 59072        }
 59073    }
 74
 75    IEnumerator Wait() //  <-  its a standalone method
 172676    {
 172677        Debug.Log("Hello");
 78        //wait 3 seconds
 172679        yield return new WaitForSeconds(5);
 75680        Debug.Log("Goodbye");
 75681        Destroy(gameObject); // Deletes the round
 75682    }
 83}