using System.Collections; using System.Linq; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Core; using KairoEngine.Core.GameActions; namespace KairoEngine.UI.GameActions { [System.Serializable, HideReferenceObjectPicker] public class TransitionGameAction : GameActionBase { public enum ActionType { FadeIn, FadeOut } public override string name { get { if(actionType == ActionType.FadeIn) return "Fade In"; else if(actionType == ActionType.FadeOut) return "Fade Out"; else return "Transition"; } } public override GameActionsController controller { get => _controller; set { _controller = value; typeName = "TransitionGameAction"; className = this.GetType().AssemblyQualifiedName; } } public override string GetTypeName() => "TransitionGameAction"; public override string GetActionName() => "UI/Transition"; [FoldoutGroup("@name")] public ActionType actionType = ActionType.FadeIn; [FoldoutGroup("@name")] public float fadeTime = 0.7f; public TransitionGameAction(GameActionsController controller) : base(controller) { this.controller = controller; className = this.GetType().AssemblyQualifiedName; } public override void Start() { if (actionType == ActionType.FadeIn) TransitionController.FadeIn(fadeTime); else if (actionType == ActionType.FadeOut) TransitionController.FadeOut(fadeTime); _done = true; _started = true; } public override void Update() { } public override void Restart() { _done = false; _started = false; } public static TransitionGameAction JSONToTransitionGameAction(string data) { return JsonUtility.FromJson(data); } private TransitionGameAction Duplicate(GameActionsController controller = null) { TransitionGameAction action = new TransitionGameAction(controller == null ? this.controller : controller); action.controller = controller; action.actionType = actionType; return action; } } }