BacklogCtrl.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class BacklogCtrl : MonoBehaviour
  6. {
  7. public void CreateBacklog(List<BacklogCtrl.BacklogUnit> dicBacklog, UnityEngine.Object backlogPrefab)
  8. {
  9. this.ClearExistBacklog();
  10. if (dicBacklog != null)
  11. {
  12. foreach (BacklogCtrl.BacklogUnit backlogUnit in dicBacklog)
  13. {
  14. GameObject gameObject = UnityEngine.Object.Instantiate(backlogPrefab) as GameObject;
  15. GameObject childObject = UTY.GetChildObject(gameObject, "Voice", false);
  16. UIButton component = childObject.GetComponent<UIButton>();
  17. if (backlogUnit.m_voiceId != string.Empty)
  18. {
  19. childObject.SetActive(true);
  20. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.ClickVoiceButton));
  21. component.name = backlogUnit.m_voiceId;
  22. if (!string.IsNullOrEmpty(component.name))
  23. {
  24. UIButton uibutton = component;
  25. uibutton.name = uibutton.name + "|" + backlogUnit.m_voicePitch;
  26. }
  27. }
  28. else
  29. {
  30. childObject.SetActive(false);
  31. }
  32. gameObject.transform.parent = base.transform;
  33. gameObject.transform.localScale = Vector3.one;
  34. gameObject.transform.localPosition = Vector3.zero;
  35. gameObject.transform.rotation = Quaternion.identity;
  36. SubtitleDisplayManager component2 = gameObject.GetComponent<SubtitleDisplayManager>();
  37. component2.charaNameText = backlogUnit.m_speakerName;
  38. component2.originalText = backlogUnit.m_msg;
  39. component2.subtitlesText = backlogUnit.m_subtitlemsg;
  40. }
  41. }
  42. if (SubtitleDisplayManager.configDisplayType == SubtitleDisplayManager.DisplayType.OriginalAndSubtitle)
  43. {
  44. base.GetComponent<UIGrid>().cellHeight = 240f;
  45. }
  46. else
  47. {
  48. base.GetComponent<UIGrid>().cellHeight = 182f;
  49. }
  50. base.GetComponent<UIGrid>().Reposition();
  51. }
  52. private void ClearExistBacklog()
  53. {
  54. IEnumerator enumerator = base.transform.GetEnumerator();
  55. try
  56. {
  57. while (enumerator.MoveNext())
  58. {
  59. object obj = enumerator.Current;
  60. Transform transform = (Transform)obj;
  61. UnityEngine.Object.Destroy(transform.gameObject);
  62. }
  63. }
  64. finally
  65. {
  66. IDisposable disposable;
  67. if ((disposable = (enumerator as IDisposable)) != null)
  68. {
  69. disposable.Dispose();
  70. }
  71. }
  72. }
  73. private void ClickVoiceButton()
  74. {
  75. string name = UIButton.current.name;
  76. if (!string.IsNullOrEmpty(name))
  77. {
  78. string[] array = name.Split(new char[]
  79. {
  80. '|'
  81. });
  82. GameMain.Instance.SoundMgr.VoiceStopAll();
  83. GameMain.Instance.SoundMgr.PlayDummyVoice(array[0], 0f, false, false, int.Parse(array[1]));
  84. }
  85. Debug.Log(string.Format("ボイスボタン ボイスID={0}がクリックされました。", name));
  86. }
  87. public class BacklogUnit
  88. {
  89. public string m_speakerName { get; set; }
  90. public string m_msg { get; set; }
  91. public string m_subtitlemsg { get; set; }
  92. public string m_voiceId { get; set; }
  93. public int m_voicePitch { get; set; }
  94. public override string ToString()
  95. {
  96. return string.Format("BacklogUnit=[m_speakerName={1}, m_msg={2}, m_voiceId={3}]", this.m_speakerName, this.m_msg, this.m_voiceId);
  97. }
  98. }
  99. }