BacklogCtrl.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. UILabel component2 = UTY.GetChildObject(gameObject, "SpeakerName", false).GetComponent<UILabel>();
  37. component2.text = backlogUnit.m_speakerName;
  38. UILabel component3 = UTY.GetChildObject(gameObject, "Message", false).GetComponent<UILabel>();
  39. component3.text = backlogUnit.m_msg;
  40. }
  41. }
  42. base.GetComponent<UIGrid>().Reposition();
  43. }
  44. private void ClearExistBacklog()
  45. {
  46. IEnumerator enumerator = base.transform.GetEnumerator();
  47. try
  48. {
  49. while (enumerator.MoveNext())
  50. {
  51. object obj = enumerator.Current;
  52. Transform transform = (Transform)obj;
  53. UnityEngine.Object.Destroy(transform.gameObject);
  54. }
  55. }
  56. finally
  57. {
  58. IDisposable disposable;
  59. if ((disposable = (enumerator as IDisposable)) != null)
  60. {
  61. disposable.Dispose();
  62. }
  63. }
  64. }
  65. private void ClickVoiceButton()
  66. {
  67. string name = UIButton.current.name;
  68. if (!string.IsNullOrEmpty(name))
  69. {
  70. string[] array = name.Split(new char[]
  71. {
  72. '|'
  73. });
  74. GameMain.Instance.SoundMgr.VoiceStopAll();
  75. GameMain.Instance.SoundMgr.PlayDummyVoice(array[0], 0f, false, false, int.Parse(array[1]));
  76. }
  77. Debug.Log(string.Format("ボイスボタン ボイスID={0}がクリックされました。", name));
  78. }
  79. public class BacklogUnit
  80. {
  81. public string m_speakerName { get; set; }
  82. public string m_msg { get; set; }
  83. public string m_subtitlemsg { get; set; }
  84. public string m_voiceId { get; set; }
  85. public int m_voicePitch { get; set; }
  86. public override string ToString()
  87. {
  88. return string.Format("BacklogUnit=[m_speakerName={1}, m_msg={2}, m_voiceId={3}]", this.m_speakerName, this.m_msg, this.m_voiceId);
  89. }
  90. }
  91. }