StoryCheckPoint.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. [RequireComponent(typeof(BoxCollider2D))]
  5. [ExecuteInEditMode]
  6. public class StoryCheckPoint : BaseBehaviour
  7. {
  8. private bool IsFirstTime
  9. {
  10. get
  11. {
  12. return RoundStorage.Get(LevelManager.SceneName + base.name, true);
  13. }
  14. set
  15. {
  16. RoundStorage.Set(LevelManager.SceneName + base.name, this._repeatable || value);
  17. }
  18. }
  19. public void OnTriggerEnter2D(Collider2D collision)
  20. {
  21. if (this._isPlaying || !collision.CompareTag("Player") || !this.IsFirstTime)
  22. {
  23. return;
  24. }
  25. R.Audio.PlayVoiceOverArray(this._voiceOverList.ToArray(), this._eachTime, delegate
  26. {
  27. this._isPlaying = false;
  28. }, this._delay);
  29. this._isPlaying = true;
  30. this.IsFirstTime = false;
  31. }
  32. [SerializeField]
  33. [Header("可重复触发")]
  34. private bool _repeatable;
  35. [SerializeField]
  36. [Header("播放台词延迟时间")]
  37. private float _delay;
  38. private bool _isPlaying;
  39. [SerializeField]
  40. [Header("旁白列表")]
  41. private List<string> _voiceOverList = new List<string>();
  42. [Header("每两句之间间隔时间")]
  43. [SerializeField]
  44. private float _eachTime = 0.5f;
  45. }