SupplyAttribute.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. public class SupplyAttribute : BaseBehaviour
  5. {
  6. [HideInInspector]
  7. public bool Opened
  8. {
  9. get
  10. {
  11. return (!this.CanTriggerInNewRound) ? SaveStorage.Get("SupplyBox" + LevelManager.SceneName + base.name, false) : RoundStorage.Get("SupplyBox" + LevelManager.SceneName + base.name, false);
  12. }
  13. set
  14. {
  15. if (this.CanTriggerInNewRound)
  16. {
  17. RoundStorage.Set("SupplyBox" + LevelManager.SceneName + base.name, value);
  18. }
  19. else
  20. {
  21. SaveStorage.Set("SupplyBox" + LevelManager.SceneName + base.name, value);
  22. }
  23. }
  24. }
  25. private void Awake()
  26. {
  27. this.CurrentHp = this.MaxHp;
  28. this._id = "SupplyBox" + LevelManager.SceneName + base.name;
  29. }
  30. private void Update()
  31. {
  32. if (!Application.isPlaying)
  33. {
  34. this.MaxHp = (uint)(Mathf.FloorToInt(this.MaxHp / 4f) * 4);
  35. }
  36. }
  37. [SerializeField]
  38. private string _id;
  39. [Header("在此距离范围内显示宝箱内容")]
  40. [SerializeField]
  41. public float ShowDistance = 5f;
  42. [SerializeField]
  43. [Header("宝箱类型")]
  44. public SupplyAttribute.SupplyBoxType SupplyBox;
  45. [SerializeField]
  46. [Header("获得奖励值")]
  47. public int Bonus;
  48. [SerializeField]
  49. [Header("宝箱最大受攻击次数,只能为4的倍数")]
  50. public uint MaxHp = 4u;
  51. [SerializeField]
  52. [Header("是否可以在新周目重复触发")]
  53. public bool CanTriggerInNewRound;
  54. [HideInInspector]
  55. public uint CurrentHp;
  56. public enum SupplyBoxType
  57. {
  58. Money,
  59. Cheat = 2,
  60. Flash
  61. }
  62. }