OnStartGameActionTrigger.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. namespace KairoEngine.Core.GameActions
  8. {
  9. [System.Serializable, HideReferenceObjectPicker]
  10. public class OnStartGameActionTrigger : GameActionTriggerBase
  11. {
  12. public override string name
  13. {
  14. get
  15. {
  16. return $"On Start";
  17. }
  18. }
  19. public override GameActionTriggersController controller {
  20. get => _controller;
  21. set
  22. {
  23. _controller = value;
  24. typeName = "OnStartGameActionTrigger";
  25. }
  26. }
  27. public override string GetTypeName() => "OnStartGameActionTrigger";
  28. public override string GetTriggerName() => "On Start";
  29. [FoldoutGroup("@name")]
  30. public float delay = 0;
  31. private float _counter = 0;
  32. public override void OnEnable()
  33. {
  34. _counter = 0f;
  35. }
  36. public override void Update()
  37. {
  38. _counter += Time.deltaTime;
  39. if(_counter > delay) controller.TriggerActions();
  40. }
  41. public override void OnDisable() { }
  42. public static OnStartGameActionTrigger JSONToOnStartGameActionTrigger(string data)
  43. {
  44. return JsonUtility.FromJson<OnStartGameActionTrigger>(data);
  45. }
  46. private OnStartGameActionTrigger Duplicate()
  47. {
  48. OnStartGameActionTrigger trigger = new OnStartGameActionTrigger();
  49. trigger.controller = controller;
  50. return trigger;
  51. }
  52. }
  53. }