BacklogCtrl.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. string name = uibutton.name;
  26. uibutton.name = string.Concat(new object[]
  27. {
  28. name,
  29. "|",
  30. backlogUnit.m_voicePitch,
  31. "|",
  32. backlogUnit.m_voiceType.ToString()
  33. });
  34. }
  35. }
  36. else
  37. {
  38. childObject.SetActive(false);
  39. }
  40. gameObject.transform.parent = base.transform;
  41. gameObject.transform.localScale = Vector3.one;
  42. gameObject.transform.localPosition = Vector3.zero;
  43. gameObject.transform.rotation = Quaternion.identity;
  44. if (!Product.SPP)
  45. {
  46. UILabel component2 = UTY.GetChildObject(gameObject, "SpeakerName", false).GetComponent<UILabel>();
  47. component2.text = backlogUnit.m_speakerName;
  48. UILabel component3 = UTY.GetChildObject(gameObject, "Message", false).GetComponent<UILabel>();
  49. component3.text = backlogUnit.m_msg;
  50. }
  51. else
  52. {
  53. SubtitleDisplayManager component4 = gameObject.GetComponent<SubtitleDisplayManager>();
  54. component4.charaNameText = backlogUnit.m_speakerNameSet;
  55. component4.originalText = backlogUnit.m_msg;
  56. component4.subtitlesText = backlogUnit.m_subtitlemsg;
  57. }
  58. }
  59. }
  60. if (Product.SPP)
  61. {
  62. if (SubtitleDisplayManager.configDisplayType == SubtitleDisplayManager.DisplayType.OriginalAndSubtitle)
  63. {
  64. base.GetComponent<UIGrid>().cellHeight = 240f;
  65. }
  66. else
  67. {
  68. base.GetComponent<UIGrid>().cellHeight = 182f;
  69. }
  70. }
  71. base.GetComponent<UIGrid>().Reposition();
  72. }
  73. private void ClearExistBacklog()
  74. {
  75. IEnumerator enumerator = base.transform.GetEnumerator();
  76. try
  77. {
  78. while (enumerator.MoveNext())
  79. {
  80. object obj = enumerator.Current;
  81. Transform transform = (Transform)obj;
  82. UnityEngine.Object.Destroy(transform.gameObject);
  83. }
  84. }
  85. finally
  86. {
  87. IDisposable disposable;
  88. if ((disposable = (enumerator as IDisposable)) != null)
  89. {
  90. disposable.Dispose();
  91. }
  92. }
  93. }
  94. private void ClickVoiceButton()
  95. {
  96. string name = UIButton.current.name;
  97. if (!string.IsNullOrEmpty(name))
  98. {
  99. string[] array = name.Split(new char[]
  100. {
  101. '|'
  102. });
  103. GameMain.Instance.SoundMgr.VoiceStopAll();
  104. GameMain.Instance.SoundMgr.PlayDummyVoice(array[0], 0f, false, false, int.Parse(array[1]), (AudioSourceMgr.Type)Enum.Parse(typeof(AudioSourceMgr.Type), array[2]));
  105. }
  106. Debug.Log(string.Format("ボイスボタン ボイスID={0}がクリックされました。", name));
  107. }
  108. public class BacklogUnit
  109. {
  110. public string m_speakerName { get; set; }
  111. public KeyValuePair<string, string> m_speakerNameSet { get; set; }
  112. public string m_msg { get; set; }
  113. public string m_subtitlemsg { get; set; }
  114. public string m_voiceId { get; set; }
  115. public int m_voicePitch { get; set; }
  116. public AudioSourceMgr.Type m_voiceType { get; set; }
  117. public override string ToString()
  118. {
  119. return string.Format("BacklogUnit=[m_speakerName={1}, m_msg={2}, m_voiceId={3}]", this.m_speakerName, this.m_msg, this.m_voiceId);
  120. }
  121. }
  122. }