NibiruRemindBox.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using UnityEngine;
  2. namespace Nxr.Internal
  3. {
  4. /// <summary>
  5. ///
  6. /// </summary>
  7. public class NibiruRemindBox : NibiruRemindBoxBase
  8. {
  9. public static NibiruRemindBox Instance { set; get; }
  10. // [SerializeField]
  11. private bool isAutoClose = true;
  12. private Vector2 VOLUMESIZE = new Vector2(60, 1.2f);
  13. private int VOLUMESTART = -20;
  14. // private int VOLUMEEND = 36;
  15. private string typeName = "";
  16. void Start()
  17. {
  18. Instance = this;
  19. // CloseBox();
  20. // Calibration();
  21. }
  22. /// <summary>
  23. /// The dialog of low battery。
  24. /// </summary>
  25. public void Electricity()
  26. {
  27. typeName = "electricity";
  28. if (this.Init(3))
  29. {
  30. Create("BGIcon", new Vector3(0, 0, 0), new Vector2(150, 20));
  31. Create("Context", LocalizationManager.GetInstance.GetValue("remindbox_lower_power"),
  32. new Vector3(0, 0, 0), new Vector2(500, 100));
  33. if (isAutoClose)
  34. Close();
  35. }
  36. }
  37. public void CalibrationDelay()
  38. {
  39. Loom.QueueOnMainThread((param) => { Calibration(); }, true);
  40. }
  41. /// <summary>
  42. /// The dialog of calibration.
  43. /// </summary>
  44. public void Calibration()
  45. {
  46. typeName = "calibration";
  47. if (this.Init(3))
  48. {
  49. Create("BGIcon", new Vector3(0, 0, 0), new Vector2(150, 20));
  50. Create("Context", LocalizationManager.GetInstance.GetValue("remindbox_nkey_tip"), new Vector3(0, 0, 0),
  51. new Vector2(600, 100));
  52. Create("HandleIcon", new Vector3(0, 48, 0), new Vector2(15, 65));
  53. if (isAutoClose)
  54. Close();
  55. }
  56. }
  57. // public void CloseBox()
  58. // {
  59. // typeName = "close";
  60. // if (this.Init(4))
  61. // {
  62. // Create("Close", LocalizationManager.GetInstance.GetValue("remindbox_shutdown"), new Vector3(0, 10, 0),
  63. // new Vector2(500, 100));
  64. // Create("ReStart", LocalizationManager.GetInstance.GetValue("remindbox_reboot"), new Vector3(0, -10, 0),
  65. // new Vector2(500, 100));
  66. // Create("CloseIcon", new Vector3(-40, 10, 0), new Vector2(10, 10));
  67. // Create("ReStartIcon", new Vector3(-40, -10, 0), new Vector2(10, 10));
  68. // #if NIBIRU_VR
  69. // Create("dialog_dismiss_normal", new Vector3(50, 16, 0), new Vector2(20, 20));
  70. // Create("CloseMeIcon", new Vector3(50, 16, 0), new Vector2(20, 20), OnLiftBack);
  71. // #else
  72. // Create("dialog_dismiss_normal", new Vector3(70, 16, 0), new Vector2(20, 20));
  73. // Create("CloseMeIcon", new Vector3(70, 16, 0), new Vector2(20, 20), OnLiftBack);
  74. // #endif
  75. // Create("CloseBGIcon", new Vector3(0, 9, 0), new Vector2(100, 18), TurnOff);
  76. // Create("ReStartBGIcon", new Vector3(0, -9, 0), new Vector2(100, 18), ReStart);
  77. // if (isAutoClose)
  78. // Close();
  79. // }
  80. // }
  81. /// <summary>
  82. /// The dialog of volume.
  83. /// </summary>
  84. /// <param name="param"></param>
  85. public void Volume(string param)
  86. {
  87. if (this.typeName.Equals("volume") && remindbox != null)
  88. {
  89. Create(new Vector3(VOLUMESTART + (56 * int.Parse(param)) / 15, 0, 0), new Vector2(4.8f, 4.8f));
  90. }
  91. else if (this.Init(2))
  92. {
  93. this.Create("BGIcon", new Vector3(0, 0, 0), new Vector2(100, 20));
  94. this.Create("VolumeIcon", new Vector3(-35.8f, 0, 0), new Vector2(7.6f, 7.6f));
  95. this.Create("VolumeWrite", new Vector3(8, 0, 0), VOLUMESIZE);
  96. //TODO:更改图标
  97. this.Create("VolumeTag", new Vector3(VOLUMESTART + (56 * int.Parse(param)) / 15, 0, 0),
  98. new Vector2(4.8f, 4.8f));
  99. if (isAutoClose) Close();
  100. }
  101. typeName = "volume";
  102. }
  103. public void TurnOff()
  104. {
  105. NxrViewer.Instance.TurnOff();
  106. ReleaseDestory();
  107. }
  108. public void ReStart()
  109. {
  110. NxrViewer.Instance.Reboot();
  111. ReleaseDestory();
  112. }
  113. public void OnLiftBack()
  114. {
  115. if (remindbox != null)
  116. {
  117. ReleaseDestory();
  118. }
  119. }
  120. #if UNITY_EDITOR
  121. private void Update()
  122. {
  123. if (Input.GetKeyDown(KeyCode.V))
  124. {
  125. Volume("1");
  126. // CloseBox();
  127. }
  128. }
  129. #endif
  130. }
  131. public enum RemindBoxParam
  132. {
  133. ELECTRICITY,
  134. CALIBRATION,
  135. CLOSE,
  136. VOLUME
  137. }
  138. }