StoryLabel.cs 922 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. [RequireComponent(typeof(BoxCollider2D))]
  5. public class StoryLabel : BaseBehaviour
  6. {
  7. private bool HasShown
  8. {
  9. get
  10. {
  11. return RoundStorage.Get("StoryLabel" + LevelManager.SceneName, false);
  12. }
  13. set
  14. {
  15. RoundStorage.Set("StoryLabel" + LevelManager.SceneName, value);
  16. }
  17. }
  18. private void Start()
  19. {
  20. this._text = ScriptLocalization.Get("Story/" + this._storyStringKey);
  21. }
  22. private void OnTriggerEnter2D(Collider2D collision)
  23. {
  24. if (!collision.CompareTag("Player"))
  25. {
  26. return;
  27. }
  28. if (this.HasShown)
  29. {
  30. return;
  31. }
  32. R.Ui.Toast.Show(this._text, this._normalSize, this._duration * 2f + 1f, false);
  33. this.HasShown = true;
  34. }
  35. [SerializeField]
  36. private string _storyStringKey;
  37. [SerializeField]
  38. private int _normalSize = 40;
  39. [SerializeField]
  40. private float _duration = 1f;
  41. private string _text;
  42. }