ControlButtons.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using ObjectScripts;
  5. namespace UIScripts
  6. {
  7. public class ControlButtons : MonoBehaviour
  8. {
  9. ///<summary>
  10. /// AbstractManager to control
  11. ///</summary>
  12. [SerializeField] AbstractManager ManagerObject;
  13. ///<summary>
  14. /// Text in the scene for the velocity.
  15. ///</summary>
  16. [SerializeField] UnityEngine.UI.Text VelocityText;
  17. private void Update()
  18. {
  19. //Set Text in Scene
  20. SetVelocityText(ManagerObject.GameVelocity, ManagerObject.forward);
  21. }
  22. ///<summary>
  23. /// On playbutton pressed
  24. ///</summary>
  25. public void PlayPressed()
  26. {
  27. ManagerObject.PlayPressed();
  28. }
  29. ///<summary>
  30. /// Sets the velocity text in the scene
  31. ///</summary>
  32. private void SetVelocityText(float vel, bool forward)
  33. {
  34. if (forward)
  35. VelocityText.text = vel.ToString();
  36. else
  37. VelocityText.text = "-" + vel.ToString();
  38. }
  39. ///<summary>
  40. /// On stopbutton pressed
  41. ///</summary>
  42. public void StopPressed()
  43. {
  44. ManagerObject.StopPressed();
  45. }
  46. ///<summary>
  47. /// On reversebutton pressed
  48. ///</summary>
  49. public void ReversePressed()
  50. {
  51. ManagerObject.ReversePressed();
  52. }
  53. ///<summary>
  54. /// On playbutton pressed
  55. ///</summary>
  56. public void PlusPressed()
  57. {
  58. ManagerObject.PlusPressed();
  59. }
  60. ///<summary>
  61. /// on minusbutton pressed
  62. ///</summary>
  63. public void MinusPressed()
  64. {
  65. ManagerObject.MinusPressed();
  66. }
  67. }
  68. }