Browse Source

Added StopSoundtrack GameAction

James Peret 2 years ago
parent
commit
75a6a5d660

+ 75 - 0
Runtime/GameActions/StopSoundtrackGameAction.cs

@@ -0,0 +1,75 @@
+using System.Collections;
+using System.Linq;
+using System.Collections.Generic;
+using UnityEngine;
+using Sirenix.OdinInspector;
+using KairoEngine.Core;
+using KairoEngine.Core.GameActions;
+
+namespace KairoEngine.SoundtrackSystem.GameActions
+{
+
+    [System.Serializable, HideReferenceObjectPicker]
+    public class StopSoundtrackGameAction : GameActionBase
+    {
+        public override string name 
+        { 
+            get
+            {
+                return $"Stop Soundtrack";
+            }
+        }
+
+        public override GameActionsController controller { 
+            get => _controller; 
+            set 
+            {
+                _controller = value;
+                typeName = "StopSoundtrackGameAction";
+                className =  this.GetType().AssemblyQualifiedName;
+            }
+        }
+        public override string GetTypeName() => "StopSoundtrackGameAction";
+        public override string GetActionName() => "Soundtrack/Stop Soundtrack";
+
+        [FoldoutGroup("@name")] 
+        public float fadeOutTime = 1f;
+    
+
+        public StopSoundtrackGameAction(GameActionsController controller) : base(controller)
+        {
+            this.controller = controller;
+            className =  this.GetType().AssemblyQualifiedName;
+        }
+
+        public override void Start()
+        {
+            SoundtrackManager.FadeOutSoundtrack(fadeOutTime);
+            _done = true;
+            _started = true;
+        }
+
+        public override void Update() { }
+
+        public override void Restart()
+        {
+            _done = false;
+            _started = false;
+        }
+
+        public static StopSoundtrackGameAction JSONToStopSoundtrackGameAction(string data)
+        {
+            return JsonUtility.FromJson<StopSoundtrackGameAction>(data);
+        }
+
+        private StopSoundtrackGameAction Duplicate(GameActionsController controller = null)
+        {
+            StopSoundtrackGameAction action = new StopSoundtrackGameAction(controller == null ? this.controller : controller);
+            action.controller = controller;
+            action.fadeOutTime = fadeOutTime;
+            return action;
+        }
+
+    }
+}
+

+ 11 - 0
Runtime/GameActions/StopSoundtrackGameAction.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1a35ec6c519a4984fb42b1edcf16ce8c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: