hungersoundhandler.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. class HungerSoundHandlerBase extends SoundHandlerBase
  2. {
  3. override void Init()
  4. {
  5. m_Id = eSoundHandlers.HUNGER;
  6. }
  7. }
  8. //---------------------------
  9. // Client
  10. //---------------------------
  11. class HungerSoundHandlerClient extends HungerSoundHandlerBase
  12. {
  13. const float SOUND_INTERVALS_LIGHT_MIN = 10;
  14. const float SOUND_INTERVALS_LIGHT_MAX = 30;
  15. float m_SoundTime;
  16. EffectSound m_Sound;
  17. override void Update()
  18. {
  19. if ( m_Player.GetMixedSoundStates() & eMixedSoundStates.HUNGRY )
  20. {
  21. ProcessSound();
  22. }
  23. }
  24. void ProcessSound()
  25. {
  26. if ( GetGame().GetTime() > m_SoundTime)
  27. {
  28. float offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_LIGHT_MIN, SOUND_INTERVALS_LIGHT_MAX) * 1000;
  29. m_SoundTime = GetGame().GetTime() + offset_time;
  30. PlaySound();
  31. }
  32. }
  33. void PlaySound()
  34. {
  35. m_Sound = SEffectManager.PlaySoundOnObject("hungry_uni_Voice_Char_SoundSet", m_Player);
  36. if( m_Sound )
  37. {
  38. m_Sound.SetAutodestroy(true);
  39. }
  40. else
  41. {
  42. Debug.LogError("Missing sounset");
  43. }
  44. }
  45. }
  46. //---------------------------
  47. // Server
  48. //---------------------------
  49. class HungerSoundHandlerServer extends HungerSoundHandlerBase
  50. {
  51. }