Example #1
0
    public virtual void Init(LMBasePortInput _portInput)
    {
        m_solver = new TGExpressionParser();

        m_portInput = _portInput;

        InitInputs(PortData.input);
        InitValues(PortData.value);
    }
    public virtual void Init(LMBasePortInput _portInput)
    {
        m_solver = new TGExpressionParser();

        m_portInput = _portInput;

        PortData = m_portInput.KeyportData;

        deviceType = PortData.type;

        InitInputs(PortData.input);
        InitValues(PortData.value);
    }
Example #3
0
    public static float GetValueFromINI(string key)
    {
        if (string.IsNullOrEmpty(key))
        {
            return(0f);
        }
        else
        {
            if (key.IndexOf('(') >= 0)
            {
                var solver = new TGExpressionParser();

                int start = key.IndexOf('(') + 1;
                int end   = key.IndexOf(')');

                var sliced = key.Substring(start, end - start).Split(',');
                Debug.Log("Sliced string: " + sliced);

                for (int i = 0; i < sliced.Length; i++)
                {
                    string cutkey = sliced[i];
                    Debug.Log("Cut Key: " + cutkey);

                    key = key.Replace(cutkey, TGController.Instance.gameConfig.GetValue(cutkey, 0f).ToString());
                }
                Debug.Log("String Converted: " + key);

                return((float)solver.EvaluateExpression(key).Value);
            }
            else
            {
                float retval = 0f;
                if (float.TryParse(key, out retval))
                {
                    return(retval);
                }
                else
                {
                    return(TGController.Instance.gameConfig.GetValue(key, 0));
                }
            }
        }
    }