< Summary

Class:Round
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/VGuns-Unity-VR/Assets/Test/Round.cs
Covered lines:23
Uncovered lines:16
Coverable lines:39
Total lines:83
Line coverage:58.9% (23 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%00051.52%
Wait()0%000100%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/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)
 6020    {
 6021        Target target = other.gameObject.GetComponent<Target>();
 22
 6023        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
 6034        {
 6035            StartCoroutine(Wait());
 6036        }
 37
 6038        XRTarget XRTarget = other.gameObject.GetComponent<XRTarget>();
 39        // Only attempts to inflict damage if the other game object has
 40        // the 'EnemyAi' component
 6041        if (XRTarget != null)
 042        {
 043            Debug.Log("Hit");
 44
 045            XRTarget.Hit(damage);
 46
 047            Destroy(gameObject); // Deletes the round
 48
 049        }
 50
 51        else
 6052        {
 6053            StartCoroutine(Wait());
 6054        }
 55
 6056        EnemyAi EnemyHealth = other.gameObject.GetComponent<EnemyAi>();
 57        // Only attempts to inflict damage if the other game object has
 58        // the 'EnemyAi' component
 6059        if (EnemyHealth != null)
 060        {
 061            Debug.Log("Hit");
 62
 063            EnemyHealth.TakeDamage(damage);
 64
 065            Destroy(gameObject); // Deletes the round
 66
 067        }
 68        else
 6069        {
 6070            StartCoroutine(Wait());
 71
 6072        }
 6073    }
 74
 75    IEnumerator Wait() //  <-  its a standalone method
 18076    {
 18077        Debug.Log("Hello");
 78        //wait 3 seconds
 18079        yield return new WaitForSeconds(5);
 5780        Debug.Log("Goodbye");
 5781        Destroy(gameObject); // Deletes the round
 5782    }
 83}