StopSoundtrackGameAction.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System.Collections;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Sirenix.OdinInspector;
  6. using KairoEngine.Core;
  7. using KairoEngine.Core.GameActions;
  8. namespace KairoEngine.SoundtrackSystem.GameActions
  9. {
  10. [System.Serializable, HideReferenceObjectPicker]
  11. public class StopSoundtrackGameAction : GameActionBase
  12. {
  13. public override string name
  14. {
  15. get
  16. {
  17. return $"Stop Soundtrack";
  18. }
  19. }
  20. public override GameActionsController controller {
  21. get => _controller;
  22. set
  23. {
  24. _controller = value;
  25. typeName = "StopSoundtrackGameAction";
  26. className = this.GetType().AssemblyQualifiedName;
  27. }
  28. }
  29. public override string GetTypeName() => "StopSoundtrackGameAction";
  30. public override string GetActionName() => "Soundtrack/Stop Soundtrack";
  31. [FoldoutGroup("@name")]
  32. public float fadeOutTime = 1f;
  33. public StopSoundtrackGameAction(GameActionsController controller) : base(controller)
  34. {
  35. this.controller = controller;
  36. className = this.GetType().AssemblyQualifiedName;
  37. }
  38. public override void Start()
  39. {
  40. SoundtrackManager.FadeOutSoundtrack(fadeOutTime);
  41. _done = true;
  42. _started = true;
  43. }
  44. public override void Update() { }
  45. public override void Restart()
  46. {
  47. _done = false;
  48. _started = false;
  49. }
  50. public static StopSoundtrackGameAction JSONToStopSoundtrackGameAction(string data)
  51. {
  52. return JsonUtility.FromJson<StopSoundtrackGameAction>(data);
  53. }
  54. private StopSoundtrackGameAction Duplicate(GameActionsController controller = null)
  55. {
  56. StopSoundtrackGameAction action = new StopSoundtrackGameAction(controller == null ? this.controller : controller);
  57. action.controller = controller;
  58. action.fadeOutTime = fadeOutTime;
  59. return action;
  60. }
  61. }
  62. }