12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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<TransitionGameAction>(data);
- }
- private TransitionGameAction Duplicate(GameActionsController controller = null)
- {
- TransitionGameAction action = new TransitionGameAction(controller == null ? this.controller : controller);
- action.controller = controller;
- action.actionType = actionType;
- return action;
- }
- }
- }
|