123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System.Collections;
- using System.Linq;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using KairoEngine.Core;
- namespace KairoEngine.Core.GameActions
- {
- [System.Serializable, HideReferenceObjectPicker]
- public class WaitGameAction : GameActionBase
- {
- #region DefaultVariables
- public override string name { get => $"Wait {time}s"; }
- public override GameActionsController controller {
- get => _controller;
- set
- {
- _controller = value;
- typeName = "WaitGameAction";
- }
- }
- public override string GetTypeName() => "WaitGameAction";
- public override string GetActionName() => "Core/Wait";
- #endregion
- #region ActionVariables
- [IconFoldoutGroup("@name", "Assets/Plugins/KairoEngine/Core/Editor/Icons/WaitGameActionIcon.png")] public float time = 1f;
- private float elapsedTime = 0f;
- #endregion
- public WaitGameAction(GameActionsController controller) : base(controller)
- {
- this.controller = controller;
- className = this.GetType().AssemblyQualifiedName;
- }
- #region Flow
- public override void Start()
- {
- elapsedTime = 0f;
- _done = false;
- _started = true;
- }
- public override void Update()
- {
- elapsedTime += Time.deltaTime;
- if(elapsedTime > time) _done = true;
- }
- public override void Restart()
- {
- _done = false;
- _started = false;
- elapsedTime = 0;
- }
- #endregion
- #region Utilities
- private WaitGameAction Duplicate(GameActionsController controller = null)
- {
- WaitGameAction action = new WaitGameAction(controller == null ? this.controller : controller);
- action.controller = controller;
- action.time = time;
- return action;
- }
- #endregion
- #region Serialization
- public static WaitGameAction JSONToWaitGameAction(string data)
- {
- return JsonUtility.FromJson<WaitGameAction>(data);
- }
- #endregion
- }
- }
|