uGUIKaraokeSelect.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. public class uGUIKaraokeSelect : MonoBehaviour
  7. {
  8. private uGUIKaraokeSelect.uGUIItemListViewer UIListViewer
  9. {
  10. get
  11. {
  12. if (!this.m_UIListViewer)
  13. {
  14. this.m_UIListViewer = this.m_UIListViewerObject.GetOrAddComponent<uGUIKaraokeSelect.uGUIItemListViewer>();
  15. }
  16. return this.m_UIListViewer;
  17. }
  18. }
  19. private void Start()
  20. {
  21. this.m_UIListViewerObject.gameObject.AddComponent<uGUIKaraokeSelect.uGUIItemListViewer>();
  22. this.HideListViewer();
  23. this.SetButtonActive(this.m_ButtonOK, false);
  24. this.SetButtonActive(this.m_ButtonCANCEL, false);
  25. this.SetButtonActive(this.m_ButtonStart, true);
  26. this.SetButtonActive(this.m_ButtonEnd, true);
  27. this.SetButtonInteractable(this.m_ButtonOK, false);
  28. this.SetButtonInteractable(this.m_ButtonCANCEL, false);
  29. this.SetButtonInteractable(this.m_ButtonStart, true);
  30. this.SetButtonInteractable(this.m_ButtonEnd, true);
  31. KaraokeDataManager.MusicData[] musicDataArray = this.GetMusicDataArray();
  32. string arg = string.Empty;
  33. if (musicDataArray.Length > 0)
  34. {
  35. arg = musicDataArray[0].strThumbnailName;
  36. this.m_SelectingMusicDataID = musicDataArray[0].ID;
  37. }
  38. this.m_ButtonSelectMusic.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", arg));
  39. KaraokeDataManager.BackgroundData backgroundData = this.GetBackgroundData(this.GetNowBackgroundDataIndex());
  40. this.m_ButtonSelectBG.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", backgroundData.strThumbnailName));
  41. if (SceneVRCommunication.Instance && !SceneVRCommunication.Instance.KaraokeMode)
  42. {
  43. this.m_ButtonSelectBG.interactable = false;
  44. }
  45. if (this.GetFoodDataArray().Length <= 0)
  46. {
  47. this.m_ButtonSelectFood.interactable = false;
  48. }
  49. }
  50. public void OpenListSelectMusic(bool isOn)
  51. {
  52. uGUIKaraokeSelect.<OpenListSelectMusic>c__AnonStorey0 <OpenListSelectMusic>c__AnonStorey = new uGUIKaraokeSelect.<OpenListSelectMusic>c__AnonStorey0();
  53. <OpenListSelectMusic>c__AnonStorey.$this = this;
  54. this.SetButtonActive(this.m_ButtonOK, true);
  55. this.SetButtonActive(this.m_ButtonCANCEL, true);
  56. this.SetButtonActive(this.m_ButtonStart, false);
  57. this.SetButtonActive(this.m_ButtonEnd, false);
  58. this.SetButtonInteractable(this.m_ButtonOK, true);
  59. this.SetButtonInteractable(this.m_ButtonCANCEL, true);
  60. this.ShowListViewer();
  61. <OpenListSelectMusic>c__AnonStorey.musicArray = this.GetMusicDataArray();
  62. this.m_BeforeSelectedGameObject = null;
  63. this.UIListViewer.Show(<OpenListSelectMusic>c__AnonStorey.musicArray.Length, delegate(int index, GameObject item)
  64. {
  65. Toggle component = item.GetComponent<Toggle>();
  66. uGUIKaraokeSelect.uGUIItemListButton itemNumber = item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>();
  67. itemNumber.number = <OpenListSelectMusic>c__AnonStorey.musicArray[index].ID;
  68. if (<OpenListSelectMusic>c__AnonStorey.$this.m_SelectingMusicDataID == itemNumber.number)
  69. {
  70. component.isOn = true;
  71. }
  72. component.image.sprite = <OpenListSelectMusic>c__AnonStorey.$this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", <OpenListSelectMusic>c__AnonStorey.musicArray[index].strThumbnailName));
  73. component.onValueChanged.AddListener(delegate(bool value)
  74. {
  75. if (!value)
  76. {
  77. return;
  78. }
  79. int number = itemNumber.number;
  80. if (<OpenListSelectMusic>c__AnonStorey.IsAlreadySelected(item))
  81. {
  82. <OpenListSelectMusic>c__AnonStorey.ButtonEventSetMusic(number);
  83. }
  84. });
  85. });
  86. this.m_ButtonOK.onClick.RemoveAllListeners();
  87. this.m_ButtonOK.onClick.AddListener(delegate()
  88. {
  89. int indexMusic = <OpenListSelectMusic>c__AnonStorey.$this.m_SelectingMusicDataID;
  90. if (<OpenListSelectMusic>c__AnonStorey.$this.m_BeforeSelectedGameObject)
  91. {
  92. indexMusic = <OpenListSelectMusic>c__AnonStorey.$this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
  93. }
  94. <OpenListSelectMusic>c__AnonStorey.$this.ButtonEventSetMusic(indexMusic);
  95. });
  96. this.m_ButtonCANCEL.onClick.RemoveAllListeners();
  97. this.m_ButtonCANCEL.onClick.AddListener(delegate()
  98. {
  99. <OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonOK, false);
  100. <OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonCANCEL, false);
  101. <OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonStart, true);
  102. <OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonEnd, true);
  103. <OpenListSelectMusic>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonStart, <OpenListSelectMusic>c__AnonStorey.$this.IsSelectingMusicDataExist());
  104. <OpenListSelectMusic>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonEnd, true);
  105. <OpenListSelectMusic>c__AnonStorey.$this.HideListViewer();
  106. });
  107. }
  108. public void OpenListSelectBG(bool isOn)
  109. {
  110. uGUIKaraokeSelect.<OpenListSelectBG>c__AnonStorey2 <OpenListSelectBG>c__AnonStorey = new uGUIKaraokeSelect.<OpenListSelectBG>c__AnonStorey2();
  111. <OpenListSelectBG>c__AnonStorey.$this = this;
  112. this.SetButtonActive(this.m_ButtonOK, true);
  113. this.SetButtonActive(this.m_ButtonCANCEL, true);
  114. this.SetButtonActive(this.m_ButtonStart, false);
  115. this.SetButtonActive(this.m_ButtonEnd, false);
  116. this.SetButtonInteractable(this.m_ButtonOK, true);
  117. this.SetButtonInteractable(this.m_ButtonCANCEL, true);
  118. this.ShowListViewer();
  119. <OpenListSelectBG>c__AnonStorey.backgroundArray = this.GetBackgroundDataArray();
  120. this.m_BeforeSelectedGameObject = null;
  121. this.UIListViewer.Show(<OpenListSelectBG>c__AnonStorey.backgroundArray.Length, delegate(int index, GameObject item)
  122. {
  123. Toggle component = item.GetComponent<Toggle>();
  124. item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>().number = index;
  125. if (<OpenListSelectBG>c__AnonStorey.$this.GetNowSelectingBackgroundDataIndex() == index)
  126. {
  127. component.isOn = true;
  128. }
  129. component.image.sprite = <OpenListSelectBG>c__AnonStorey.$this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", <OpenListSelectBG>c__AnonStorey.backgroundArray[index].strThumbnailName));
  130. component.onValueChanged.AddListener(delegate(bool value)
  131. {
  132. if (!value)
  133. {
  134. return;
  135. }
  136. <OpenListSelectBG>c__AnonStorey.SetButtonInteractable(<OpenListSelectBG>c__AnonStorey.m_ButtonOK, true);
  137. if (<OpenListSelectBG>c__AnonStorey.IsAlreadySelected(item))
  138. {
  139. <OpenListSelectBG>c__AnonStorey.ButtonEventSetBG(index);
  140. }
  141. });
  142. });
  143. this.m_ButtonOK.onClick.RemoveAllListeners();
  144. this.m_ButtonOK.onClick.AddListener(delegate()
  145. {
  146. int indexBG = <OpenListSelectBG>c__AnonStorey.$this.GetNowSelectingBackgroundDataIndex();
  147. if (<OpenListSelectBG>c__AnonStorey.$this.m_BeforeSelectedGameObject)
  148. {
  149. indexBG = <OpenListSelectBG>c__AnonStorey.$this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
  150. }
  151. <OpenListSelectBG>c__AnonStorey.$this.ButtonEventSetBG(indexBG);
  152. });
  153. this.m_ButtonCANCEL.onClick.RemoveAllListeners();
  154. this.m_ButtonCANCEL.onClick.AddListener(delegate()
  155. {
  156. <OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonOK, false);
  157. <OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonCANCEL, false);
  158. <OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonStart, true);
  159. <OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonEnd, true);
  160. <OpenListSelectBG>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonStart, <OpenListSelectBG>c__AnonStorey.$this.IsSelectingMusicDataExist());
  161. <OpenListSelectBG>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonEnd, true);
  162. <OpenListSelectBG>c__AnonStorey.$this.HideListViewer();
  163. });
  164. }
  165. public void OpenListSelectFood(bool isOn)
  166. {
  167. uGUIKaraokeSelect.<OpenListSelectFood>c__AnonStorey4 <OpenListSelectFood>c__AnonStorey = new uGUIKaraokeSelect.<OpenListSelectFood>c__AnonStorey4();
  168. <OpenListSelectFood>c__AnonStorey.$this = this;
  169. if (!isOn)
  170. {
  171. return;
  172. }
  173. if (this.IsMaidAddCallFlag())
  174. {
  175. this.OnEventMaidAddCalled();
  176. return;
  177. }
  178. this.SetButtonActive(this.m_ButtonOK, true);
  179. this.SetButtonActive(this.m_ButtonCANCEL, true);
  180. this.SetButtonActive(this.m_ButtonStart, false);
  181. this.SetButtonActive(this.m_ButtonEnd, false);
  182. this.SetButtonInteractable(this.m_ButtonOK, true);
  183. this.SetButtonInteractable(this.m_ButtonCANCEL, true);
  184. this.ShowListViewer();
  185. <OpenListSelectFood>c__AnonStorey.foodArray = this.GetFoodDataArray();
  186. this.m_BeforeSelectedGameObject = null;
  187. this.UIListViewer.Show(<OpenListSelectFood>c__AnonStorey.foodArray.Length, delegate(int index, GameObject item)
  188. {
  189. Toggle component = item.GetComponent<Toggle>();
  190. item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>().number = index;
  191. if (<OpenListSelectFood>c__AnonStorey.$this.m_SelectingFoodDataIndex == index)
  192. {
  193. component.isOn = true;
  194. }
  195. component.image.sprite = <OpenListSelectFood>c__AnonStorey.$this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", <OpenListSelectFood>c__AnonStorey.foodArray[index].strThumbnailName));
  196. component.onValueChanged.AddListener(delegate(bool value)
  197. {
  198. if (!value)
  199. {
  200. return;
  201. }
  202. <OpenListSelectFood>c__AnonStorey.SetButtonInteractable(<OpenListSelectFood>c__AnonStorey.m_ButtonOK, true);
  203. if (<OpenListSelectFood>c__AnonStorey.IsAlreadySelected(item))
  204. {
  205. <OpenListSelectFood>c__AnonStorey.ButtonEventSetFood(index);
  206. }
  207. });
  208. });
  209. this.m_ButtonOK.onClick.RemoveAllListeners();
  210. this.m_ButtonOK.onClick.AddListener(delegate()
  211. {
  212. int indexFood = <OpenListSelectFood>c__AnonStorey.$this.m_SelectingFoodDataIndex;
  213. if (<OpenListSelectFood>c__AnonStorey.$this.m_BeforeSelectedGameObject)
  214. {
  215. indexFood = <OpenListSelectFood>c__AnonStorey.$this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
  216. }
  217. <OpenListSelectFood>c__AnonStorey.$this.ButtonEventSetFood(indexFood);
  218. });
  219. this.m_ButtonCANCEL.onClick.RemoveAllListeners();
  220. this.m_ButtonCANCEL.onClick.AddListener(delegate()
  221. {
  222. <OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonOK, false);
  223. <OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonCANCEL, false);
  224. <OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonStart, true);
  225. <OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonEnd, true);
  226. <OpenListSelectFood>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonStart, <OpenListSelectFood>c__AnonStorey.$this.IsSelectingMusicDataExist());
  227. <OpenListSelectFood>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonEnd, true);
  228. <OpenListSelectFood>c__AnonStorey.$this.HideListViewer();
  229. });
  230. }
  231. private void ButtonEventSetMusic(int indexMusic)
  232. {
  233. this.m_SelectingMusicDataID = indexMusic;
  234. this.SetButtonActive(this.m_ButtonOK, false);
  235. this.SetButtonActive(this.m_ButtonCANCEL, false);
  236. this.SetButtonActive(this.m_ButtonStart, true);
  237. this.SetButtonActive(this.m_ButtonEnd, true);
  238. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  239. this.SetButtonInteractable(this.m_ButtonEnd, true);
  240. this.HideListViewer();
  241. this.m_ButtonSelectMusic.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetMusicData(indexMusic).strThumbnailName));
  242. }
  243. private void ButtonEventSetBG(int indexBG)
  244. {
  245. this.SetBG(indexBG);
  246. Debug.Log(string.Format("[Karaoke]背景が選択された\n選択した背景インデックス:{0}", indexBG));
  247. this.SetButtonActive(this.m_ButtonOK, false);
  248. this.SetButtonActive(this.m_ButtonCANCEL, false);
  249. this.SetButtonActive(this.m_ButtonStart, true);
  250. this.SetButtonActive(this.m_ButtonEnd, true);
  251. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  252. this.SetButtonInteractable(this.m_ButtonEnd, true);
  253. this.HideListViewer();
  254. this.m_ButtonSelectBG.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetBackgroundData(indexBG).strThumbnailName));
  255. }
  256. private void ButtonEventSetFood(int indexFood)
  257. {
  258. this.m_SelectingFoodDataIndex = indexFood;
  259. Debug.Log(string.Format("[Karaoke]飲食物が選択された\n選択した飲食物インデックス:{0}", indexFood));
  260. this.SetButtonActive(this.m_ButtonOK, false);
  261. this.SetButtonActive(this.m_ButtonCANCEL, false);
  262. this.SetButtonActive(this.m_ButtonStart, true);
  263. this.SetButtonActive(this.m_ButtonEnd, true);
  264. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  265. this.SetButtonInteractable(this.m_ButtonEnd, true);
  266. this.HideListViewer();
  267. this.StartFood(indexFood);
  268. this.m_ButtonSelectFood.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetFoodData(indexFood).strThumbnailName));
  269. this.UpdateOrderButtonImage();
  270. }
  271. private void ShowListViewer()
  272. {
  273. if (!this.m_ParentUIListViewer.gameObject.activeSelf)
  274. {
  275. UICanvasFade component = this.m_ParentUIListViewer.GetComponent<UICanvasFade>();
  276. component.FadeIn(component.fadeTime, component.isTimeScaling, null);
  277. }
  278. this.UpdateOrderButtonImage();
  279. }
  280. private void HideListViewer()
  281. {
  282. if (this.m_ParentUIListViewer.gameObject.activeSelf)
  283. {
  284. UICanvasFade component = this.m_ParentUIListViewer.GetComponent<UICanvasFade>();
  285. component.FadeOut(component.fadeTime, component.isTimeScaling, delegate()
  286. {
  287. this.m_ParentUIListViewer.gameObject.SetActive(false);
  288. });
  289. }
  290. this.UpdateOrderButtonImage();
  291. }
  292. private void UpdateOrderButtonImage()
  293. {
  294. if (this.IsMaidAddCallFlag())
  295. {
  296. this.m_ButtonSelectFood.image.sprite = this.GetResource<Sprite>("SceneVRCommunication/Tablet/Karaoke/Sprite/kp_event");
  297. Debug.Log("[カラオケ]\u3000メイド二人目呼び出しのフラグがtrue");
  298. }
  299. else
  300. {
  301. Debug.Log("[カラオケ]\u3000メイド二人目はまだ呼ばれていない。");
  302. }
  303. }
  304. private bool IsAlreadySelected(GameObject selectableObject)
  305. {
  306. GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
  307. bool result = this.m_BeforeSelectedGameObject == selectableObject;
  308. this.m_BeforeSelectedGameObject = currentSelectedGameObject;
  309. return result;
  310. }
  311. private void SetButtonActive(Button button, bool active)
  312. {
  313. if (button.gameObject.activeSelf != active)
  314. {
  315. button.gameObject.SetActive(active);
  316. }
  317. }
  318. private void SetButtonInteractable(Button button, bool interactable)
  319. {
  320. if (button.interactable != interactable)
  321. {
  322. button.interactable = interactable;
  323. }
  324. }
  325. private bool IsSelectingMusicDataExist()
  326. {
  327. Debug.Log(string.Format("[Karaoke]選択している楽曲インデックス:{0}", this.m_SelectingMusicDataID));
  328. return this.m_Manager.IsExistMusicData(this.m_SelectingMusicDataID);
  329. }
  330. private T GetResource<T>(string path) where T : UnityEngine.Object
  331. {
  332. if (string.IsNullOrEmpty(path))
  333. {
  334. Debug.LogWarning("[Karaoke]リソースのパスが空です");
  335. return (T)((object)null);
  336. }
  337. T t = Resources.Load<T>(path);
  338. if (!t)
  339. {
  340. Debug.LogWarning(string.Format("[Karaoke]リソースの取得に失敗しました\nパス:「{0}」", path));
  341. }
  342. return t;
  343. }
  344. private bool IsMaidAddCallFlag()
  345. {
  346. int tmpGenericFlag = GameMain.Instance.CMSystem.GetTmpGenericFlag("カラオケメイド追加");
  347. return tmpGenericFlag == 1;
  348. }
  349. private void OnEventMaidAddCalled()
  350. {
  351. string file_name = "karaoke_comevent_main.ks";
  352. GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(file_name, string.Empty);
  353. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  354. }
  355. private KaraokeDataManager.MusicData[] GetMusicDataArray()
  356. {
  357. return this.m_Manager.GetMusicDataArray(true);
  358. }
  359. private KaraokeDataManager.FoodData[] GetFoodDataArray()
  360. {
  361. KaraokeDataManager.FoodData[] foodDataArray = this.m_Manager.GetFoodDataArray(true);
  362. List<KaraokeDataManager.FoodData> list = new List<KaraokeDataManager.FoodData>();
  363. foreach (KaraokeDataManager.FoodData foodData in foodDataArray)
  364. {
  365. if (foodData.ID != KaraokeDataManager.FoodData.ID_BUTTON_MAID_ADDITIONAL || KaraokeDataManager.IsEnablePersonalKaraoke003(GameMain.Instance.CharacterMgr.GetMaid(0)))
  366. {
  367. list.Add(foodData);
  368. }
  369. }
  370. return list.ToArray();
  371. }
  372. private KaraokeDataManager.BackgroundData[] GetBackgroundDataArray()
  373. {
  374. return this.m_Manager.GetBackgroundDataArray(true);
  375. }
  376. private KaraokeDataManager.MusicData GetMusicData(int musicID)
  377. {
  378. return this.m_Manager.GetMusicData(musicID);
  379. }
  380. private KaraokeDataManager.FoodData GetFoodData(int foodID)
  381. {
  382. return this.GetFoodDataArray()[foodID];
  383. }
  384. private KaraokeDataManager.BackgroundData GetBackgroundData(int backgroundID)
  385. {
  386. return this.GetBackgroundDataArray()[backgroundID];
  387. }
  388. private int GetNowBackgroundDataIndex()
  389. {
  390. return this.m_Manager.GetNowBGIndex();
  391. }
  392. private int GetNowSelectingBackgroundDataIndex()
  393. {
  394. return this.m_Manager.GetNowSelectingBGIndex();
  395. }
  396. public void StartKaraoke()
  397. {
  398. this.m_Manager.StartKaraoke(this.m_SelectingMusicDataID);
  399. }
  400. public void EndKaraoke()
  401. {
  402. this.m_Manager.ButtonExit();
  403. }
  404. private void StartFood(int index)
  405. {
  406. this.m_Manager.SetFoodData(this.GetFoodDataArray()[index].ID);
  407. }
  408. private void SetBG(int index)
  409. {
  410. this.m_Manager.SetBGIndex(index);
  411. }
  412. [SerializeField]
  413. private KaraokeDataManager m_Manager;
  414. [SerializeField]
  415. private Button m_ButtonOK;
  416. [SerializeField]
  417. private Button m_ButtonCANCEL;
  418. [SerializeField]
  419. private Button m_ButtonStart;
  420. [SerializeField]
  421. private Button m_ButtonEnd;
  422. [SerializeField]
  423. private Toggle m_ButtonSelectMusic;
  424. [SerializeField]
  425. private Toggle m_ButtonSelectBG;
  426. [SerializeField]
  427. private Toggle m_ButtonSelectFood;
  428. [SerializeField]
  429. private RectTransform m_ParentUIListViewer;
  430. [SerializeField]
  431. private RectTransform m_UIListViewerObject;
  432. private uGUIKaraokeSelect.uGUIItemListViewer m_UIListViewer;
  433. [Space(16f)]
  434. [SerializeField]
  435. private RectTransform m_ImageLines;
  436. private GameObject m_BeforeSelectedGameObject;
  437. private int m_SelectingMusicDataID;
  438. private int m_SelectingFoodDataIndex;
  439. private const string ThumbnailPath = "SceneVRCommunication/Tablet/Karaoke/Sprite/";
  440. private class uGUIItemListViewer : MonoBehaviour
  441. {
  442. public GameObject showArea
  443. {
  444. get
  445. {
  446. return this.m_ShowArea;
  447. }
  448. set
  449. {
  450. this.m_ShowArea = value;
  451. }
  452. }
  453. public GameObject tempItem
  454. {
  455. get
  456. {
  457. return this.m_TempItem;
  458. }
  459. set
  460. {
  461. this.m_TempItem = value;
  462. }
  463. }
  464. public List<GameObject> itemList
  465. {
  466. get
  467. {
  468. return this.m_ItemList;
  469. }
  470. }
  471. public void Show(GameObject showArea, int itemCount, GameObject tempItem = null, Action<int, GameObject> eventItemSetting = null)
  472. {
  473. if (showArea)
  474. {
  475. this.m_ShowArea = showArea;
  476. }
  477. else if (!this.m_ShowArea)
  478. {
  479. this.FindShowArea();
  480. }
  481. if (!this.m_ShowArea)
  482. {
  483. return;
  484. }
  485. if (tempItem)
  486. {
  487. this.m_TempItem = tempItem;
  488. }
  489. else if (!this.m_TempItem)
  490. {
  491. this.FindItemTemplate();
  492. }
  493. if (!this.m_ShowArea || !this.m_TempItem)
  494. {
  495. return;
  496. }
  497. if (!this.m_ShowArea.activeSelf)
  498. {
  499. this.m_ShowArea.SetActive(true);
  500. }
  501. if (this.m_TempItem.activeSelf)
  502. {
  503. this.m_TempItem.SetActive(false);
  504. }
  505. this.Clear();
  506. Transform transform = this.m_ShowArea.transform;
  507. for (int i = 0; i < itemCount; i++)
  508. {
  509. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_TempItem);
  510. gameObject.SetActive(true);
  511. gameObject.transform.SetParent(transform, false);
  512. if (eventItemSetting != null)
  513. {
  514. eventItemSetting(i, gameObject);
  515. }
  516. this.m_ItemList.Add(gameObject);
  517. }
  518. }
  519. public void Show(int itemCount, Action<int, GameObject> eventItemSetting = null)
  520. {
  521. this.Show(this.m_ShowArea, itemCount, this.m_TempItem, eventItemSetting);
  522. }
  523. public void Clear()
  524. {
  525. if (!this.m_ShowArea)
  526. {
  527. return;
  528. }
  529. if (this.m_ItemList == null)
  530. {
  531. return;
  532. }
  533. for (int i = 0; i < this.m_ItemList.Count; i++)
  534. {
  535. UnityEngine.Object.Destroy(this.m_ItemList[i]);
  536. }
  537. }
  538. private void FindItemTemplate()
  539. {
  540. if (!this.m_ShowArea)
  541. {
  542. return;
  543. }
  544. if (this.m_ShowArea.transform.childCount <= 0)
  545. {
  546. return;
  547. }
  548. Transform transform = this.FindChildDeep(this.m_ShowArea.transform, "Temp Item", true);
  549. if (!transform)
  550. {
  551. transform = this.m_ShowArea.transform.GetChild(0);
  552. }
  553. this.m_TempItem = transform.gameObject;
  554. }
  555. private void FindShowArea()
  556. {
  557. Transform transform = base.transform.parent;
  558. if (!transform)
  559. {
  560. transform = base.transform;
  561. }
  562. string text = "Content";
  563. Transform transform2 = this.FindChildDeep(transform, text, true);
  564. if (!transform2)
  565. {
  566. Debug.LogError(string.Format("[Karaoke.uGUIItemListViewer]項目を並べるエリアが見つかりませんでした\n検索名:{0}", text));
  567. return;
  568. }
  569. this.m_ShowArea = transform2.gameObject;
  570. }
  571. private Transform FindChildDeep(Component self, string name, bool includeInactive = false)
  572. {
  573. Transform[] componentsInChildren = self.GetComponentsInChildren<Transform>(includeInactive);
  574. for (int i = 0; i < componentsInChildren.Length; i++)
  575. {
  576. if (componentsInChildren[i].name == name)
  577. {
  578. return componentsInChildren[i];
  579. }
  580. }
  581. return null;
  582. }
  583. private GameObject m_ShowArea;
  584. private GameObject m_TempItem;
  585. private List<GameObject> m_ItemList = new List<GameObject>();
  586. }
  587. private class uGUIItemListButton : MonoBehaviour
  588. {
  589. public int number = -1;
  590. }
  591. }