PlaySoundSuccessEventArgs.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework;
  8. using GameFramework.Event;
  9. using GameFramework.Sound;
  10. namespace UnityGameFramework.Runtime
  11. {
  12. /// <summary>
  13. /// 播放声音成功事件。
  14. /// </summary>
  15. public sealed class PlaySoundSuccessEventArgs : GameEventArgs
  16. {
  17. /// <summary>
  18. /// 播放声音成功事件编号。
  19. /// </summary>
  20. public static readonly int EventId = typeof(PlaySoundSuccessEventArgs).GetHashCode();
  21. /// <summary>
  22. /// 初始化播放声音成功事件的新实例。
  23. /// </summary>
  24. public PlaySoundSuccessEventArgs()
  25. {
  26. SerialId = 0;
  27. SoundAssetName = null;
  28. SoundAgent = null;
  29. Duration = 0f;
  30. BindingEntity = null;
  31. UserData = null;
  32. }
  33. /// <summary>
  34. /// 获取播放声音成功事件编号。
  35. /// </summary>
  36. public override int Id
  37. {
  38. get
  39. {
  40. return EventId;
  41. }
  42. }
  43. /// <summary>
  44. /// 获取声音的序列编号。
  45. /// </summary>
  46. public int SerialId
  47. {
  48. get;
  49. private set;
  50. }
  51. /// <summary>
  52. /// 获取声音资源名称。
  53. /// </summary>
  54. public string SoundAssetName
  55. {
  56. get;
  57. private set;
  58. }
  59. /// <summary>
  60. /// 获取用于播放的声音代理。
  61. /// </summary>
  62. public ISoundAgent SoundAgent
  63. {
  64. get;
  65. private set;
  66. }
  67. /// <summary>
  68. /// 获取加载持续时间。
  69. /// </summary>
  70. public float Duration
  71. {
  72. get;
  73. private set;
  74. }
  75. /// <summary>
  76. /// 获取声音绑定的实体。
  77. /// </summary>
  78. public Entity BindingEntity
  79. {
  80. get;
  81. private set;
  82. }
  83. /// <summary>
  84. /// 获取用户自定义数据。
  85. /// </summary>
  86. public object UserData
  87. {
  88. get;
  89. private set;
  90. }
  91. /// <summary>
  92. /// 创建播放声音成功事件。
  93. /// </summary>
  94. /// <param name="e">内部事件。</param>
  95. /// <returns>创建的播放声音成功事件。</returns>
  96. public static PlaySoundSuccessEventArgs Create(GameFramework.Sound.PlaySoundSuccessEventArgs e)
  97. {
  98. PlaySoundInfo playSoundInfo = (PlaySoundInfo)e.UserData;
  99. PlaySoundSuccessEventArgs playSoundSuccessEventArgs = ReferencePool.Acquire<PlaySoundSuccessEventArgs>();
  100. playSoundSuccessEventArgs.SerialId = e.SerialId;
  101. playSoundSuccessEventArgs.SoundAssetName = e.SoundAssetName;
  102. playSoundSuccessEventArgs.SoundAgent = e.SoundAgent;
  103. playSoundSuccessEventArgs.Duration = e.Duration;
  104. playSoundSuccessEventArgs.BindingEntity = playSoundInfo.BindingEntity;
  105. playSoundSuccessEventArgs.UserData = playSoundInfo.UserData;
  106. ReferencePool.Release(playSoundInfo);
  107. return playSoundSuccessEventArgs;
  108. }
  109. /// <summary>
  110. /// 清理播放声音成功事件。
  111. /// </summary>
  112. public override void Clear()
  113. {
  114. SerialId = 0;
  115. SoundAssetName = null;
  116. SoundAgent = null;
  117. Duration = 0f;
  118. BindingEntity = null;
  119. UserData = null;
  120. }
  121. }
  122. }