PlaySoundUpdateEventArgs.cs 4.1 KB

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