LightIndicator.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public enum LightIndicatorState
  15. {
  16. WHITE,
  17. WHITE_HIGHLIGHTED,
  18. RED,
  19. RED_HIGHLIGHTED,
  20. ORANGE,
  21. ORANGE_HIGHLIGHTED,
  22. YELLOW,
  23. YELLOW_HIGHLIGHTED,
  24. GREEN,
  25. GREEN_HIGHLIGHTED,
  26. BLUE,
  27. BLUE_HIGHLIGHTED,
  28. BLACK,
  29. BLACK_HIGHLIGHTED
  30. }
  31. //================================================================================
  32. //
  33. //================================================================================
  34. public class LightIndicator : MonoBehaviour
  35. {
  36. //================================================================================
  37. //
  38. //================================================================================
  39. [SerializeField] private GameObject m_WhiteNormal;
  40. [SerializeField] private GameObject m_WhiteHighlighted;
  41. [SerializeField] private GameObject m_RedNormal;
  42. [SerializeField] private GameObject m_RedHighlighted;
  43. [SerializeField] private GameObject m_OrangeNormal;
  44. [SerializeField] private GameObject m_OrangeHighlighted;
  45. [SerializeField] private GameObject m_YellowNormal;
  46. [SerializeField] private GameObject m_YellowHighlighted;
  47. [SerializeField] private GameObject m_GreenNormal;
  48. [SerializeField] private GameObject m_GreenHighlighted;
  49. [SerializeField] private GameObject m_BlueNormal;
  50. [SerializeField] private GameObject m_BlueHighlighted;
  51. [SerializeField] private GameObject m_BlackNormal;
  52. [SerializeField] private GameObject m_BlackHighlighted;
  53. private LightIndicatorState m_CurrentState;
  54. private bool m_Highlighted;
  55. //================================================================================
  56. //
  57. //================================================================================
  58. void Start()
  59. {
  60. m_Highlighted = false;
  61. m_WhiteNormal.SetActive(true);
  62. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_WhiteHighlighted);
  63. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_RedNormal);
  64. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_RedHighlighted);
  65. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_OrangeNormal);
  66. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_OrangeHighlighted);
  67. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_YellowNormal);
  68. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_YellowHighlighted);
  69. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_GreenNormal);
  70. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_GreenHighlighted);
  71. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_BlueNormal);
  72. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_BlueHighlighted);
  73. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_BlackNormal);
  74. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_BlackHighlighted);
  75. }
  76. //================================================================================
  77. //
  78. //================================================================================
  79. public void SetState(LightIndicatorState state)
  80. {
  81. m_CurrentState = state;
  82. switch(state)
  83. {
  84. case LightIndicatorState.WHITE:
  85. m_WhiteNormal.SetActive(true);
  86. m_WhiteHighlighted.SetActive(false);
  87. m_RedNormal.SetActive(false);
  88. m_RedHighlighted.SetActive(false);
  89. m_OrangeNormal.SetActive(false);
  90. m_OrangeHighlighted.SetActive(false);
  91. m_YellowNormal.SetActive(false);
  92. m_YellowHighlighted.SetActive(false);
  93. m_GreenNormal.SetActive(false);
  94. m_GreenHighlighted.SetActive(false);
  95. m_BlueNormal.SetActive(false);
  96. m_BlueHighlighted.SetActive(false);
  97. m_BlackNormal.SetActive(false);
  98. m_BlackHighlighted.SetActive(false);
  99. break;
  100. case LightIndicatorState.WHITE_HIGHLIGHTED:
  101. m_WhiteNormal.SetActive(false);
  102. m_WhiteHighlighted.SetActive(true);
  103. m_RedNormal.SetActive(false);
  104. m_RedHighlighted.SetActive(false);
  105. m_OrangeNormal.SetActive(false);
  106. m_OrangeHighlighted.SetActive(false);
  107. m_YellowNormal.SetActive(false);
  108. m_YellowHighlighted.SetActive(false);
  109. m_GreenNormal.SetActive(false);
  110. m_GreenHighlighted.SetActive(false);
  111. m_BlueNormal.SetActive(false);
  112. m_BlueHighlighted.SetActive(false);
  113. m_BlackNormal.SetActive(false);
  114. m_BlackHighlighted.SetActive(false);
  115. break;
  116. case LightIndicatorState.RED:
  117. m_WhiteNormal.SetActive(false);
  118. m_WhiteHighlighted.SetActive(false);
  119. m_RedNormal.SetActive(true);
  120. m_RedHighlighted.SetActive(false);
  121. m_OrangeNormal.SetActive(false);
  122. m_OrangeHighlighted.SetActive(false);
  123. m_YellowNormal.SetActive(false);
  124. m_YellowHighlighted.SetActive(false);
  125. m_GreenNormal.SetActive(false);
  126. m_GreenHighlighted.SetActive(false);
  127. m_BlueNormal.SetActive(false);
  128. m_BlueHighlighted.SetActive(false);
  129. m_BlackNormal.SetActive(false);
  130. m_BlackHighlighted.SetActive(false);
  131. break;
  132. case LightIndicatorState.RED_HIGHLIGHTED:
  133. m_WhiteNormal.SetActive(false);
  134. m_WhiteHighlighted.SetActive(false);
  135. m_RedNormal.SetActive(false);
  136. m_RedHighlighted.SetActive(true);
  137. m_OrangeNormal.SetActive(false);
  138. m_OrangeHighlighted.SetActive(false);
  139. m_YellowNormal.SetActive(false);
  140. m_YellowHighlighted.SetActive(false);
  141. m_GreenNormal.SetActive(false);
  142. m_GreenHighlighted.SetActive(false);
  143. m_BlueNormal.SetActive(false);
  144. m_BlueHighlighted.SetActive(false);
  145. m_BlackNormal.SetActive(false);
  146. m_BlackHighlighted.SetActive(false);
  147. break;
  148. case LightIndicatorState.ORANGE:
  149. m_WhiteNormal.SetActive(false);
  150. m_WhiteHighlighted.SetActive(false);
  151. m_RedNormal.SetActive(false);
  152. m_RedHighlighted.SetActive(false);
  153. m_OrangeNormal.SetActive(true);
  154. m_OrangeHighlighted.SetActive(false);
  155. m_YellowNormal.SetActive(false);
  156. m_YellowHighlighted.SetActive(false);
  157. m_GreenNormal.SetActive(false);
  158. m_GreenHighlighted.SetActive(false);
  159. m_BlueNormal.SetActive(false);
  160. m_BlueHighlighted.SetActive(false);
  161. m_BlackNormal.SetActive(false);
  162. m_BlackHighlighted.SetActive(false);
  163. break;
  164. case LightIndicatorState.ORANGE_HIGHLIGHTED:
  165. m_WhiteNormal.SetActive(false);
  166. m_WhiteHighlighted.SetActive(false);
  167. m_RedNormal.SetActive(false);
  168. m_RedHighlighted.SetActive(false);
  169. m_OrangeNormal.SetActive(false);
  170. m_OrangeHighlighted.SetActive(true);
  171. m_YellowNormal.SetActive(false);
  172. m_YellowHighlighted.SetActive(false);
  173. m_GreenNormal.SetActive(false);
  174. m_GreenHighlighted.SetActive(false);
  175. m_BlueNormal.SetActive(false);
  176. m_BlueHighlighted.SetActive(false);
  177. m_BlackNormal.SetActive(false);
  178. m_BlackHighlighted.SetActive(false);
  179. break;
  180. case LightIndicatorState.YELLOW:
  181. m_WhiteNormal.SetActive(false);
  182. m_WhiteHighlighted.SetActive(false);
  183. m_RedNormal.SetActive(false);
  184. m_RedHighlighted.SetActive(false);
  185. m_OrangeNormal.SetActive(false);
  186. m_OrangeHighlighted.SetActive(false);
  187. m_YellowNormal.SetActive(true);
  188. m_YellowHighlighted.SetActive(false);
  189. m_GreenNormal.SetActive(false);
  190. m_GreenHighlighted.SetActive(false);
  191. m_BlueNormal.SetActive(false);
  192. m_BlueHighlighted.SetActive(false);
  193. m_BlackNormal.SetActive(false);
  194. m_BlackHighlighted.SetActive(false);
  195. break;
  196. case LightIndicatorState.YELLOW_HIGHLIGHTED:
  197. m_WhiteNormal.SetActive(false);
  198. m_WhiteHighlighted.SetActive(false);
  199. m_RedNormal.SetActive(false);
  200. m_RedHighlighted.SetActive(false);
  201. m_OrangeNormal.SetActive(false);
  202. m_OrangeHighlighted.SetActive(false);
  203. m_YellowNormal.SetActive(false);
  204. m_YellowHighlighted.SetActive(true);
  205. m_GreenNormal.SetActive(false);
  206. m_GreenHighlighted.SetActive(false);
  207. m_BlueNormal.SetActive(false);
  208. m_BlueHighlighted.SetActive(false);
  209. m_BlackNormal.SetActive(false);
  210. m_BlackHighlighted.SetActive(false);
  211. break;
  212. case LightIndicatorState.GREEN:
  213. m_WhiteNormal.SetActive(false);
  214. m_WhiteHighlighted.SetActive(false);
  215. m_RedNormal.SetActive(false);
  216. m_RedHighlighted.SetActive(false);
  217. m_OrangeNormal.SetActive(false);
  218. m_OrangeHighlighted.SetActive(false);
  219. m_YellowNormal.SetActive(false);
  220. m_YellowHighlighted.SetActive(false);
  221. m_GreenNormal.SetActive(true);
  222. m_GreenHighlighted.SetActive(false);
  223. m_BlueNormal.SetActive(false);
  224. m_BlueHighlighted.SetActive(false);
  225. m_BlackNormal.SetActive(false);
  226. m_BlackHighlighted.SetActive(false);
  227. break;
  228. case LightIndicatorState.GREEN_HIGHLIGHTED:
  229. m_WhiteNormal.SetActive(false);
  230. m_WhiteHighlighted.SetActive(false);
  231. m_RedNormal.SetActive(false);
  232. m_RedHighlighted.SetActive(false);
  233. m_OrangeNormal.SetActive(false);
  234. m_OrangeHighlighted.SetActive(false);
  235. m_YellowNormal.SetActive(false);
  236. m_YellowHighlighted.SetActive(false);
  237. m_GreenNormal.SetActive(false);
  238. m_GreenHighlighted.SetActive(true);
  239. m_BlueNormal.SetActive(false);
  240. m_BlueHighlighted.SetActive(false);
  241. m_BlackNormal.SetActive(false);
  242. m_BlackHighlighted.SetActive(false);
  243. break;
  244. case LightIndicatorState.BLUE:
  245. m_WhiteNormal.SetActive(false);
  246. m_WhiteHighlighted.SetActive(false);
  247. m_RedNormal.SetActive(false);
  248. m_RedHighlighted.SetActive(false);
  249. m_OrangeNormal.SetActive(false);
  250. m_OrangeHighlighted.SetActive(false);
  251. m_YellowNormal.SetActive(false);
  252. m_YellowHighlighted.SetActive(false);
  253. m_GreenNormal.SetActive(false);
  254. m_GreenHighlighted.SetActive(false);
  255. m_BlueNormal.SetActive(true);
  256. m_BlueHighlighted.SetActive(false);
  257. m_BlackNormal.SetActive(false);
  258. m_BlackHighlighted.SetActive(false);
  259. break;
  260. case LightIndicatorState.BLUE_HIGHLIGHTED:
  261. m_WhiteNormal.SetActive(false);
  262. m_WhiteHighlighted.SetActive(false);
  263. m_RedNormal.SetActive(false);
  264. m_RedHighlighted.SetActive(false);
  265. m_OrangeNormal.SetActive(false);
  266. m_OrangeHighlighted.SetActive(false);
  267. m_YellowNormal.SetActive(false);
  268. m_YellowHighlighted.SetActive(false);
  269. m_GreenNormal.SetActive(false);
  270. m_GreenHighlighted.SetActive(false);
  271. m_BlueNormal.SetActive(false);
  272. m_BlueHighlighted.SetActive(true);
  273. m_BlackNormal.SetActive(false);
  274. m_BlackHighlighted.SetActive(false);
  275. break;
  276. case LightIndicatorState.BLACK:
  277. m_WhiteNormal.SetActive(false);
  278. m_WhiteHighlighted.SetActive(false);
  279. m_RedNormal.SetActive(false);
  280. m_RedHighlighted.SetActive(false);
  281. m_OrangeNormal.SetActive(false);
  282. m_OrangeHighlighted.SetActive(false);
  283. m_YellowNormal.SetActive(false);
  284. m_YellowHighlighted.SetActive(false);
  285. m_GreenNormal.SetActive(false);
  286. m_GreenHighlighted.SetActive(false);
  287. m_BlueNormal.SetActive(false);
  288. m_BlueHighlighted.SetActive(false);
  289. m_BlackNormal.SetActive(true);
  290. m_BlackHighlighted.SetActive(false);
  291. break;
  292. case LightIndicatorState.BLACK_HIGHLIGHTED:
  293. m_WhiteNormal.SetActive(false);
  294. m_WhiteHighlighted.SetActive(false);
  295. m_RedNormal.SetActive(false);
  296. m_RedHighlighted.SetActive(false);
  297. m_OrangeNormal.SetActive(false);
  298. m_OrangeHighlighted.SetActive(false);
  299. m_YellowNormal.SetActive(false);
  300. m_YellowHighlighted.SetActive(false);
  301. m_GreenNormal.SetActive(false);
  302. m_GreenHighlighted.SetActive(false);
  303. m_BlueNormal.SetActive(false);
  304. m_BlueHighlighted.SetActive(false);
  305. m_BlackNormal.SetActive(false);
  306. m_BlackHighlighted.SetActive(true);
  307. break;
  308. }
  309. }
  310. //================================================================================
  311. //
  312. //================================================================================
  313. public void Highlight()
  314. {
  315. if (!m_Highlighted)
  316. {
  317. m_CurrentState = (LightIndicatorState)(m_CurrentState + 1);
  318. SetState(m_CurrentState);
  319. m_Highlighted = true;
  320. }
  321. }
  322. //================================================================================
  323. //
  324. //================================================================================
  325. public void DisableHighlight()
  326. {
  327. if (m_Highlighted)
  328. {
  329. m_Highlighted = false;
  330. m_CurrentState = (LightIndicatorState)(m_CurrentState - 1);
  331. SetState(m_CurrentState);
  332. }
  333. }
  334. } // public class LightIndicator : MonoBehaviour
  335. } // namespace ReaderRabbit