< Summary

Class:DroneGame.Tile
Assembly:Drone
File(s):/github/workspace/Assets/Scripts/Tile.cs
Covered lines:7
Uncovered lines:2
Coverable lines:9
Total lines:47
Line coverage:77.7% (7 of 9)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:3
Method coverage:33.3% (1 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetColor(...)0%2100%
ResetColor()0%2100%
Initialize(...)0%220100%

File(s)

/github/workspace/Assets/Scripts/Tile.cs

#LineLine coverage
 1using UnityEngine;
 2using System.Collections.Generic;
 3
 4using TMPro;
 5
 6namespace DroneGame
 7{
 8  [SerializeField]
 9  /// <summary>struct that holds information about the tiles from the API</summary>
 10  public struct TileData
 11  {
 12  /// <summary>World coordinates of the tile</summary>
 13    public Vector3 globalCoordinates;
 14
 15    /// <summary>Original letter and number coordinate</summary>
 16    public string letterCoordinate;
 17
 18  /// <summary>Dict with the tile neighbors, key is letterCoordinate and value is  distance to the neighbor</summary>
 19    public Dictionary<string, float> neighbors;
 20  }
 21
 22  /// <summary>Component of the tile, mainly used for Unity</summary>
 23  public class Tile : MonoBehaviour
 24  {
 25    Material _tileMaterial;
 26    Color _startColor;
 27
 28    /// <summary>Set color of the tile</summary>
 029    public void SetColor(Color color) =>_tileMaterial.color = color;
 30
 31    /// <summary>Set color of the tile back to the original</summary>
 032    public void ResetColor() => SetColor(_startColor);
 33
 34    /// <summary>Since Unity does not allow arguments trough Instantiate we create a startup function
 35    /// Position and initialize tile from the TileData</summary>
 36    public void Initialize(TileData data)
 6437    {
 6438      _tileMaterial = transform.Find("TileModel").GetComponent<MeshRenderer>().material ?? throw new("TileMaterial not f
 6439      _startColor = _tileMaterial.color;
 6440      transform.localPosition = data.globalCoordinates;
 6441      var text = transform.Find("Text").GetComponent<TextMeshPro>();
 6442      text.text = data.letterCoordinate;
 6443    }
 44
 45
 46  }
 47}