1
0

PrefabDemoDisplay.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. public class PrefabDemoDisplay : MonoBehaviour {
  5. public Text uiText;
  6. public GameObject BikeTrainerButtons;
  7. // Use this for initialization
  8. void Start() {
  9. }
  10. // Update is called once per frame
  11. void Update() {
  12. uiText.text = "";
  13. if (GameObject.Find("CadenceDisplay")) {
  14. uiText.text = "Cadence sensor - is connected ? " + GameObject.Find("CadenceDisplay").GetComponent<CadenceDisplay>().connected + "\n";
  15. uiText.text += "cadence: " + GameObject.Find("CadenceDisplay").GetComponent<CadenceDisplay>().cadence + "\n";
  16. uiText.text += "----------------------------------------------\n";
  17. }
  18. if (GameObject.Find("SpeedCadenceDisplay")) {
  19. uiText.text += "SpeedCadence sensor - is connected ? " + GameObject.Find("SpeedCadenceDisplay").GetComponent<SpeedCadenceDisplay>().connected + "\n";
  20. uiText.text += "cadence = " + GameObject.Find("SpeedCadenceDisplay").GetComponent<SpeedCadenceDisplay>().cadence +"\n";
  21. uiText.text += "speed = " + GameObject.Find("SpeedCadenceDisplay").GetComponent<SpeedCadenceDisplay>().speed + "\n";
  22. uiText.text += "distance = " + GameObject.Find("SpeedCadenceDisplay").GetComponent<SpeedCadenceDisplay>().distance + "\n";
  23. uiText.text += "----------------------------------------------\n";
  24. }
  25. if (GameObject.Find("HeartRateDisplay")) {
  26. uiText.text += "Heart rate sensor - is connected ? " + GameObject.Find("HeartRateDisplay").GetComponent<HeartRateDisplay>().connected + "\n";
  27. uiText.text += "HR = " + GameObject.Find("HeartRateDisplay").GetComponent<HeartRateDisplay>().heartRate + "\n";
  28. uiText.text += "----------------------------------------------\n";
  29. }
  30. if (GameObject.Find("SpeedDisplay")) {
  31. uiText.text += "Speed sensor - is connected ? " + GameObject.Find("SpeedDisplay").GetComponent<SpeedDisplay>().connected + "\n";
  32. uiText.text += "speed = " + GameObject.Find("SpeedDisplay").GetComponent<SpeedDisplay>().speed + "\n";
  33. uiText.text += "distance = " + GameObject.Find("SpeedDisplay").GetComponent<SpeedDisplay>().distance + "\n";
  34. uiText.text += "----------------------------------------------\n";
  35. }
  36. if (GameObject.Find("PowerMeterDisplay")) {
  37. uiText.text += "Power sensor - is connected ? " + GameObject.Find("PowerMeterDisplay").GetComponent<PowerMeterDisplay>().connected + "\n";
  38. uiText.text += "power = " + GameObject.Find("PowerMeterDisplay").GetComponent<PowerMeterDisplay>().instantaneousPower + "\n";
  39. uiText.text += "cadence = " + GameObject.Find("PowerMeterDisplay").GetComponent<PowerMeterDisplay>().instantaneousCadence + "\n";
  40. uiText.text += "----------------------------------------------\n";
  41. }
  42. if (GameObject.Find("FitnessEquipmentDisplay")) {
  43. BikeTrainerButtons.SetActive(true);
  44. uiText.text += "Fitness E: - is connected ? " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().connected + "\n";
  45. uiText.text += "power = " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().instantaneousPower + "\n";
  46. uiText.text += "speed= " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().speed + "\n";
  47. uiText.text += "elapsedTime= " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().elapsedTime + "\n";
  48. uiText.text += "heartRate= " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().heartRate + "\n";
  49. uiText.text += "distanceTraveled= " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().distanceTraveled + "\n";
  50. uiText.text += "cadence= " + GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().cadence + "\n";
  51. uiText.text += "----------------------------------------------\n";
  52. }
  53. }
  54. public void FitnessButton1() {
  55. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().SetTrainerResistance(0);
  56. }
  57. public void FitnessButton2() {
  58. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().SetTrainerResistance(50);
  59. }
  60. public void FitnessButton3() {
  61. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().SetTrainerResistance(100);
  62. }
  63. public void FitnessButton4() {
  64. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().RequestTrainerCapabilities();
  65. }
  66. public void FitnessButton5() {
  67. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().SetTrainerUserConfiguration(10, 80); //set the user weight
  68. }
  69. public void FitnessButton6() {
  70. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().SetTrainerTargetPower(200); // set the target power in watt
  71. }
  72. public void FitnessButton7() {
  73. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().SetTrainerSlope(5); //set the trainer simulation slope in % (grade) between -200 & 200%
  74. }
  75. public void FitnessButton8() {
  76. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().RequestCommandStatus();
  77. }
  78. public void FitnessButton9() {
  79. GameObject.Find("FitnessEquipmentDisplay").GetComponent<FitnessEquipmentDisplay>().RequestUserConfig();
  80. }
  81. }