10
0

TestTarget.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //***********************************************************
  2. // Filename: TestTarget.cs
  3. // Author: Niclas
  4. // Last changes: Mittwoch, 8. August 2018
  5. // Content: Behaviour of the targets
  6. //***********************************************************
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using UnityEngine;
  10. /// <summary>
  11. /// Behaviour script of the generated targets to be reached. Used to send target data.
  12. /// </summary>
  13. public class TestTarget : MonoBehaviour {
  14. // ID of this target, doubles as the count of targets starting with zero. Gets set by TargetManager on spawn
  15. public int id=0;
  16. // Realtime when the target was instantiated
  17. public float startTime;
  18. // Use this for initialization
  19. void Start () {
  20. startTime = Time.time;
  21. }
  22. /// <summary>
  23. /// On target destruction, which signals reaching the target, fire a TargetReachedEvent with target data
  24. /// </summary>
  25. private void OnDestroy()
  26. {
  27. TargetReachedEvent tre = new TargetReachedEvent
  28. {
  29. description = "Target has been locked",
  30. targetId = id,
  31. targetTransform = transform,
  32. playerTransform = GameObject.FindGameObjectWithTag("MainCamera").transform,
  33. time = Time.time - startTime
  34. };
  35. tre.FireEvent();
  36. }
  37. }