< Summary

Class:DroneGame.Selection
Assembly:Drone
File(s):/github/workspace/Assets/Scripts/Selection.cs
Covered lines:0
Uncovered lines:13
Coverable lines:13
Total lines:41
Line coverage:0% (0 of 13)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%6200%
OnMouseClick(...)0%6200%

File(s)

/github/workspace/Assets/Scripts/Selection.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.InputSystem;
 3
 4using TMPro;
 5
 6namespace DroneGame
 7{
 8  class Selection : MonoBehaviour
 9  {
 10    public Transform selected;
 11    TextMeshProUGUI _informationText;
 12
 13    void Awake()
 014    {
 015      _informationText = GameObject.Find("Canvas/SelectionInformation")
 16                                   .GetComponent<TextMeshProUGUI>()
 17                                   ?? throw new("Component Not found");
 018    }
 19
 20    /// <summary>Function executed when the players select a tile</summary>
 21    void OnMouseClick(InputValue value)
 022    {
 023      var mousePosition = Mouse.current
 24                               .position
 25                               .ReadValue();
 026      var ray = Camera.main
 27                      .ScreenPointToRay(mousePosition);
 28
 029      if (Physics.Raycast(ray, out RaycastHit hit))
 030      {
 031        selected = hit.collider
 32                      .transform
 33                      .parent;
 034        var connector = selected.GetComponent<Connector>();
 035        _informationText.text = $@"From {connector.from.letterCoordinate}
 36To {connector.to.letterCoordinate}
 37Distance {connector.distance}";
 038      }
 039    }
 40  }
 41}