BacklogCtrl.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. UILabel component2 = UTY.GetChildObject(gameObject, "SpeakerName", false).GetComponent<UILabel>();
  45. component2.text = backlogUnit.m_speakerName;
  46. UILabel component3 = UTY.GetChildObject(gameObject, "Message", false).GetComponent<UILabel>();
  47. component3.text = backlogUnit.m_msg;
  48. }
  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]), (AudioSourceMgr.Type)Enum.Parse(typeof(AudioSourceMgr.Type), array[2]));
  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 AudioSourceMgr.Type m_voiceType { get; set; }
  95. public override string ToString()
  96. {
  97. return string.Format("BacklogUnit=[m_speakerName={1}, m_msg={2}, m_voiceId={3}]", this.m_speakerName, this.m_msg, this.m_voiceId);
  98. }
  99. }
  100. }