Beispiel #1
0
        static public bool TryParseInt(SignalArgs args, out int value)
        {
            int result = 0;

            switch (args.Type)
            {
            case SignalTypes.FLOAT:
                result = System.Convert.ToInt32(Mathf.RoundToInt(((SignalFloatArgs)args).Value));
                value  = result;
                return(true);

            case SignalTypes.STRING:
                result = 0;
                if (int.TryParse(((SignalStringArgs)args).Value, out result))
                {
                    value = result;
                    return(true);
                }
                else
                {
                    Debug.LogWarning("Cannot convert " + ((SignalStringArgs)args).Value + " to int");
                }
                break;

            default:
                Debug.LogWarning("Cannot convert signal of type " + args.ToString() + " to int");
                break;
            }

            value = result;

            return(false);
        }
Beispiel #2
0
        static public bool TryParseFloat(SignalArgs args, out float value)
        {
            float result = 0;

            switch (args.Type)
            {
            case SignalTypes.FLOAT:
                result = ((SignalFloatArgs)args).Value;
                value  = result;
                return(true);

            case SignalTypes.STRING:
                result = 0;
                if (float.TryParse(((SignalStringArgs)args).Value, out result))
                {
                    value = result;
                    return(true);
                }
                else
                {
                    Debug.LogWarning("Cannot convert " + ((SignalStringArgs)args).Value + "to float");
                }
                break;

            default:
                Debug.LogWarning("Cannot convert signal of type " + args.ToString() + " to float");
                break;
            }

            value = result;

            return(false);
        }
Beispiel #3
0
        static public bool TryParseString(SignalArgs args, out string value)
        {
            string result = "";

            switch (args.Type)
            {
            case SignalTypes.FLOAT:
                value = ((SignalFloatArgs)args).Value.ToString();
                return(true);

            case SignalTypes.STRING:
                value = ((SignalStringArgs)args).Value;
                return(true);

            default:
                Debug.LogWarning("Cannot convert signal of type " + args.ToString() + " to string");
                break;
            }

            value = result;

            return(false);
        }
Beispiel #4
0
 public override string ToString()
 {
     return(Args.ToString());
 }