Пример #1
0
    void UpdateGameInputs()
    {
        foreach (Input_Profile.InputElement ip in profile.inputs)
        {
            InputElement ie = InputElement.GetInList(ref gameinputs, ip.name);
            Vector2      v = Vector2.zero; bool b = false; int t = 0;
            foreach (KEY k in ip.keys)
            {
                if (!rawInputs.ContainsKey(k))
                {
                    continue;
                }

                v = v.magnitude < rawInputs[k].vectorValue.magnitude ? rawInputs[k].vectorValue : v;
                b = b ? true : rawInputs[k].boolValue;
                t = t < rawInputs[k].tapCount ? rawInputs[k].tapCount : t;

                if (debug)
                {
                    print(ie.name + "    binded with :    " + k + "    state :    " + ie.boolValue);
                }
            }
            ie.Set(b);
            ie.Set(v);
            ie.tapCount = t;
        }

        /*
         * foreach (System.Reflection.FieldInfo field in typeof( Input_Profile ).GetFields())
         * {
         *  if (field.FieldType != typeof( string )) { continue; }
         *
         *  string str = (string)field.GetValue(profile);
         *
         *  if (!rawInputs.ContainsKey( str )) { continue; }
         *
         *  InputElement ie = InputElement.GetInList(ref gameinputs, field.Name);
         *  ie.Set( rawInputs[str].boolValue );
         *  ie.Set( rawInputs[str].vectorValue );
         *
         *  ie.tapCount = rawInputs[str].tapCount;
         *
         *  if (debug) { print( ie.name + "    binded with :    " + str + "    state :    " + ie.boolValue); }
         * }*/
    }