示例#1
0
        /// <summary>
        /// Register a new gesture with self. If a_bOVerride is true, then any previous gesture with the same ID
        /// will be replaced by this new gesture. If false, then this gesture will be added alongside any existing gestures
        /// with the same ID.
        /// </summary>
        /// <param name="a_Gesture"></param>
        /// <param name="a_bOverride"></param>
        public void AddGesture(IGesture a_Gesture, bool a_bOverride = true)
        {
            string gestureKey = a_Gesture.GetGestureId() + "/" + a_Gesture.GetInstanceId();

            if (!m_Gestures.ContainsKey(gestureKey))
            {
                if (a_Gesture.OnStart())
                {
                    Dictionary <string, object> register = new Dictionary <string, object>();
                    register["event"]      = "add_gesture_proxy";
                    register["gestureId"]  = a_Gesture.GetGestureId();
                    register["instanceId"] = a_Gesture.GetInstanceId();
                    register["override"]   = a_bOverride;

                    TopicClient.Instance.Publish("gesture-manager", Json.Serialize(register));
                    m_Gestures[gestureKey]  = a_Gesture;
                    m_Overrides[gestureKey] = a_bOverride;

                    Log.Status("GestureManager", "Gesture {0} added.", gestureKey);
                }
            }
        }