PlaySoundFailureEventArgs.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 PlaySoundFailureEventArgs : GameEventArgs
  16. {
  17. /// <summary>
  18. /// 播放声音失败事件编号。
  19. /// </summary>
  20. public static readonly int EventId = typeof(PlaySoundFailureEventArgs).GetHashCode();
  21. /// <summary>
  22. /// 初始化播放声音失败事件的新实例。
  23. /// </summary>
  24. public PlaySoundFailureEventArgs()
  25. {
  26. SerialId = 0;
  27. SoundAssetName = null;
  28. SoundGroupName = null;
  29. PlaySoundParams = null;
  30. BindingEntity = null;
  31. ErrorCode = 0;
  32. ErrorMessage = null;
  33. UserData = null;
  34. }
  35. /// <summary>
  36. /// 获取播放声音失败事件编号。
  37. /// </summary>
  38. public override int Id
  39. {
  40. get
  41. {
  42. return EventId;
  43. }
  44. }
  45. /// <summary>
  46. /// 获取声音的序列编号。
  47. /// </summary>
  48. public int SerialId
  49. {
  50. get;
  51. private set;
  52. }
  53. /// <summary>
  54. /// 获取声音资源名称。
  55. /// </summary>
  56. public string SoundAssetName
  57. {
  58. get;
  59. private set;
  60. }
  61. /// <summary>
  62. /// 获取声音组名称。
  63. /// </summary>
  64. public string SoundGroupName
  65. {
  66. get;
  67. private set;
  68. }
  69. /// <summary>
  70. /// 获取播放声音参数。
  71. /// </summary>
  72. public PlaySoundParams PlaySoundParams
  73. {
  74. get;
  75. private set;
  76. }
  77. /// <summary>
  78. /// 获取声音绑定的实体。
  79. /// </summary>
  80. public Entity BindingEntity
  81. {
  82. get;
  83. private set;
  84. }
  85. /// <summary>
  86. /// 获取错误码。
  87. /// </summary>
  88. public PlaySoundErrorCode ErrorCode
  89. {
  90. get;
  91. private set;
  92. }
  93. /// <summary>
  94. /// 获取错误信息。
  95. /// </summary>
  96. public string ErrorMessage
  97. {
  98. get;
  99. private set;
  100. }
  101. /// <summary>
  102. /// 获取用户自定义数据。
  103. /// </summary>
  104. public object UserData
  105. {
  106. get;
  107. private set;
  108. }
  109. /// <summary>
  110. /// 创建播放声音失败事件。
  111. /// </summary>
  112. /// <param name="e">内部事件。</param>
  113. /// <returns>创建的播放声音失败事件。</returns>
  114. public static PlaySoundFailureEventArgs Create(GameFramework.Sound.PlaySoundFailureEventArgs e)
  115. {
  116. PlaySoundInfo playSoundInfo = (PlaySoundInfo)e.UserData;
  117. PlaySoundFailureEventArgs playSoundFailureEventArgs = ReferencePool.Acquire<PlaySoundFailureEventArgs>();
  118. playSoundFailureEventArgs.SerialId = e.SerialId;
  119. playSoundFailureEventArgs.SoundAssetName = e.SoundAssetName;
  120. playSoundFailureEventArgs.SoundGroupName = e.SoundGroupName;
  121. playSoundFailureEventArgs.PlaySoundParams = e.PlaySoundParams;
  122. playSoundFailureEventArgs.BindingEntity = playSoundInfo.BindingEntity;
  123. playSoundFailureEventArgs.ErrorCode = e.ErrorCode;
  124. playSoundFailureEventArgs.ErrorMessage = e.ErrorMessage;
  125. playSoundFailureEventArgs.UserData = playSoundInfo.UserData;
  126. ReferencePool.Release(playSoundInfo);
  127. return playSoundFailureEventArgs;
  128. }
  129. /// <summary>
  130. /// 清理播放声音失败事件。
  131. /// </summary>
  132. public override void Clear()
  133. {
  134. SerialId = 0;
  135. SoundAssetName = null;
  136. SoundGroupName = null;
  137. PlaySoundParams = null;
  138. BindingEntity = null;
  139. ErrorCode = 0;
  140. ErrorMessage = null;
  141. UserData = null;
  142. }
  143. }
  144. }