StatTemplate.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using Sirenix.OdinInspector;
  7. namespace KairoEngine.Stats
  8. {
  9. public enum StatValueType
  10. {
  11. Value,
  12. Equation
  13. }
  14. [HideMonoScript]
  15. [CreateAssetMenu(fileName = "Stat", menuName = "KairoEngine/Stat", order = 6)]
  16. public class StatTemplate : ScriptableObject
  17. {
  18. public string title = "Stat Name";
  19. public string description = "";
  20. [Header("Current Value")]
  21. [LabelText("Type")] public StatValueType currentValueType = StatValueType.Value;
  22. [LabelText("Equation"), ShowIf("@currentValueType == StatValueType.Equation")] public string currentValueEquation;
  23. [Header("Initial Value")]
  24. [LabelText("Type"), HideIf("@currentValueType == StatValueType.Equation")] public StatValueType initialValueType = StatValueType.Value;
  25. [LabelText("Value"), ShowIf("@initialValueType == StatValueType.Value && currentValueType != StatValueType.Equation")] public int initialValue = 100;
  26. [LabelText("Equation"), ShowIf("@initialValueType == StatValueType.Equation && currentValueType != StatValueType.Equation")] public string initialValueEquation;
  27. [Header("Minimum Value")]
  28. [LabelText("Type")] public StatValueType minValueType = StatValueType.Value;
  29. [LabelText("Value"), ShowIf("@minValueType == StatValueType.Value")] public int minValue = 0;
  30. [LabelText("Equation"), ShowIf("@minValueType == StatValueType.Equation")] public string minValueEquation;
  31. [Header("Maximum Value")]
  32. [LabelText("Type")] public StatValueType maxValueType = StatValueType.Value;
  33. [LabelText("Value"), ShowIf("@maxValueType == StatValueType.Value")] public int maxValue = 100;
  34. [LabelText("Equation"), ShowIf("@maxValueType == StatValueType.Equation")] public string maxValueEquation;
  35. public StatTemplate Setup(string title, string desc, int init, int min, int max, string valueEq="", string initEq="", string minEq="", string maxEq="")
  36. {
  37. this.title = title;
  38. this.description = desc;
  39. initialValue = init;
  40. minValue = min;
  41. maxValue = max;
  42. currentValueType = StatValueType.Value;
  43. initialValueType = StatValueType.Value;
  44. minValueType = StatValueType.Value;
  45. maxValueType = StatValueType.Value;
  46. if(valueEq != "")
  47. {
  48. currentValueEquation = valueEq;
  49. currentValueType = StatValueType.Equation;
  50. }
  51. else if(initEq != "")
  52. {
  53. initialValueEquation = initEq;
  54. initialValueType = StatValueType.Equation;
  55. }
  56. if(minEq != "")
  57. {
  58. minValueEquation = minEq;
  59. minValueType = StatValueType.Equation;
  60. }
  61. if(maxEq != "")
  62. {
  63. maxValueEquation = maxEq;
  64. maxValueType = StatValueType.Equation;
  65. }
  66. return this;
  67. }
  68. }
  69. }