< Summary

Class:Crystal
Assembly:Test
File(s):D:/--UnityProject/VR/subjects1_for_analysis/unity-vr-maze-master/unity-vr-maze-master/Assets/Maze/Scripts/Crystal.cs
Covered lines:29
Uncovered lines:35
Coverable lines:64
Total lines:124
Line coverage:45.3% (29 of 64)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:9
Method coverage:44.4% (4 of 9)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Crystal()0%000100%
Start()0%000100%
Update()0%00040.91%
Awake()0%000100%
Touch()0%0000%
TakeCoins()0%0000%
Teleport()0%0000%
Restart()0%0000%
MakeClickable()0%0000%

File(s)

D:/--UnityProject/VR/subjects1_for_analysis/unity-vr-maze-master/unity-vr-maze-master/Assets/Maze/Scripts/Crystal.cs

#LineLine coverage
 1using UnityEngine;
 2using System.Collections;
 3using UnityEngine.SceneManagement;
 4
 5public class Crystal : MonoBehaviour {
 6
 27    private Vector3 _rotationVector = Vector3.forward;
 28    private float _rotationSpeed = 50f;
 29    private float _blinkSpeed = 0.2f;
 10    private Color _emissionColor;
 11    private AudioSource _audio;
 212    private bool _touched = false;
 213    private bool _hide_dialog = true;
 214    private bool _teleporting = false;
 15
 16    public GameObject speechBubble;
 17
 18    [Header("Sounds")]
 19    public AudioClip teleport_sound;
 20
 21    [Header("Dialogs")]
 22    public GameObject dialog_hi;
 23    public GameObject dialog_teleport;
 24    public GameObject dialog_end;
 25    public GameObject dialog_fail;
 26
 27    // Use this for initialization
 128    void Start () {
 29        // save material emission color
 130        _emissionColor = gameObject.GetComponentInChildren<MeshRenderer>().material.GetColor("_EmissionColor");
 31
 32        // initially, do not allow to click on crystal
 33        // player needs to enter the temple
 134        gameObject.GetComponent<MeshCollider>().enabled = false;
 135    }
 36
 37  // Update is called once per frame
 1813338  void Update () {
 39        // rotate
 1813340        gameObject.transform.Rotate(_rotationVector * _rotationSpeed * Time.deltaTime);
 41
 42        // change emission color
 1813343        float emission = Mathf.PingPong(Time.time * _blinkSpeed, 1.0f);
 1813344        gameObject.GetComponentInChildren<MeshRenderer>().material.SetColor("_EmissionColor", _emissionColor * Mathf.Lin
 45
 1813346        if (_touched) {
 47            // size pulsation
 048            gameObject.transform.localScale = Vector3.one + 0.2f * Vector3.one * Mathf.Abs(Mathf.Sin(Time.time * 3f));
 049        }
 50
 51        // show dialogs after greetings audio is played
 1813352        if (!_hide_dialog && !_audio.isPlaying) {
 053            speechBubble.GetComponent<Canvas>().enabled = true;
 054        }
 55
 56        // show oops dialog after teleport audio is played
 1813357        if (_teleporting && !_audio.isPlaying) {
 058            dialog_end.SetActive(true);
 059            _teleporting = false;
 060        }
 61
 62        // vibrate while teleporting
 1813363        if (_teleporting)
 064        {
 065            Handheld.Vibrate();
 066        }
 1813367    }
 68
 69    public void Awake()
 170    {
 171        speechBubble.GetComponent<Canvas>().enabled = false;
 172        _audio = gameObject.GetComponent<AudioSource>();
 73
 74        // init state values
 175        _hide_dialog = true;
 176        _touched = false;
 77
 78        // init dialogs
 179        dialog_hi.SetActive(true);
 180        dialog_teleport.SetActive(false);
 181        dialog_end.SetActive(false);
 182        dialog_fail.SetActive(false);
 183    }
 84
 85    public void Touch()
 086    {
 87        // play sound and then show dialog
 088        _audio.Play();
 089        _hide_dialog = false;
 090        _touched = true;
 091    }
 92
 93    public void TakeCoins()
 094    {
 095        dialog_hi.SetActive(false);
 96        // check if coins collected
 097        if (GameObject.FindGameObjectsWithTag("Coin").Length == 0) {
 98            // all coins collected
 099            dialog_teleport.SetActive(true);
 0100        } else {
 0101            dialog_fail.SetActive(true);
 0102        }
 0103    }
 104
 105    public void Teleport()
 0106    {
 0107        dialog_teleport.SetActive(false);
 108        // play sound and then show end dialog
 0109        _audio.clip = teleport_sound;
 0110        _audio.Play();
 0111        _teleporting = true;
 0112    }
 113
 114    public void Restart()
 0115    {
 0116        SceneManager.LoadScene(0);
 0117    }
 118
 119    // called when player enters temple
 120    public void MakeClickable()
 0121    {
 0122        gameObject.GetComponent<MeshCollider>().enabled = true;
 0123    }
 124}