123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using UnityEngine;
- using System.Collections;
- public class ConfigValue
- {
- public enum ValueType
- {
- Constant = 0,
- Percentage = 1,
- }
- private static System.Array valueTypeArr = System.Enum.GetValues(typeof(ValueType));
- public static ValueType GetValueTypeByCode(int code)
- {
- return (ValueType)valueTypeArr.GetValue(code);
- }
- private float value;
- private ValueType valueType;
- public ConfigValue(float value, int valueType)
- {
- this.value = value;
- this.valueType = GetValueTypeByCode(valueType);
- }
- public float GetValue(float origin)
- {
- if(valueType == ValueType.Constant)
- {
- return value;
- }
- else if(valueType == ValueType.Percentage)
- {
- return value/100f*origin;
- }
- return 0;
- }
- public ValueType GetValueType()
- {
- return valueType;
- }
- }
|