| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DroneGame |
| | 4 | | { |
| | 5 | | /// <summary>Mostly for debug purposes, it is an arrow that points towards a neighbor tile</summary> |
| | 6 | | class Connector : MonoBehaviour |
| | 7 | | { |
| | 8 | | public TileData from; |
| | 9 | | public TileData to; |
| | 10 | | public float distance; |
| | 11 | |
|
| | 12 | | /// <summary>Since Unity does not allow arguments trough Instantiate we create a startup function</summary> |
| | 13 | | /// <param name="from">Node that contains the neighbor</param> |
| | 14 | | /// <param name="to">Neighbor node that the arrow shall point to</param> |
| | 15 | | public void Initialize(TileData from, TileData to, float distance) |
| 224 | 16 | | { |
| 224 | 17 | | this.from = from; |
| 224 | 18 | | this.to = to; |
| 224 | 19 | | this.distance = distance; |
| 224 | 20 | | var toCoordinate = to.globalCoordinates; |
| | 21 | |
|
| | 22 | | // Place Connector between two tiles |
| 224 | 23 | | var connectorPosition = Vector3.Lerp(from.globalCoordinates, toCoordinate, 0.5f); |
| 224 | 24 | | transform.localPosition = connectorPosition; |
| 224 | 25 | | transform.LookAt(toCoordinate); |
| 224 | 26 | | } |
| | 27 | | } |
| | 28 | | } |