コード例 #1
0
ファイル: KeyEventManager.cs プロジェクト: kidaak/unity-sdk
        /// <summary>
        /// Register a key event.
        /// </summary>
        /// <param name="key">The KeyCode of the key.</param>
        /// <param name="modifiers">KeyCode modifiers</param>
        /// <param name="eventType">The event to send.</param>
        /// <returns>True is returned on success.</returns>
        public bool RegisterKeyEvent(KeyCode key, KeyModifiers modifiers, Constants.Event eventType)
        {
            int code = ((int)key) | (((int)modifiers) << MODIFIER_SHIFT_BITS);

            m_KeyEvents[code] = eventType;
            return(true);
        }
コード例 #2
0
        public TestEvent(Constants.Event eventType, Constants.Phase phase, Constants.SubPhase subphase, string notes)
        {
            this.EventType    = eventType;
            this.Phase        = phase;
            this.SubPhase     = subphase;
            this.Notes        = notes;
            this.Time         = DateTime.Now;
            this.X            = -1;
            this.Y            = -1;
            this.Alt          = false;
            this.Ctrl         = false;
            this.Shift        = false;
            this.TargetString = string.Empty;
            switch (this.SubPhase)
            {
            case Constants.SubPhase.FreePractice:
                this.subphaseRepetitionNumber = Session.Instance.TimesInFreePractice;
                break;

            case Constants.SubPhase.ForcedPractice:
                this.subphaseRepetitionNumber = Session.Instance.TimesInForcedPractice;
                break;

            case Constants.SubPhase.Verify:
                this.subphaseRepetitionNumber = Session.Instance.TimesInVerify;
                break;

            default:
                this.subphaseRepetitionNumber = 0;
                break;
            }
        }
コード例 #3
0
ファイル: TouchEventManager.cs プロジェクト: kidaak/unity-sdk
        /// <summary>
        /// Register tap event to given callback
        /// </summary>
        /// <param name="gameObjectToTouch">Game object to tap on</param>
        /// <param name="callback">Callback to call after tapped on object (or outside of the object)</param>
        /// <param name="SortingLayer">Sorting layer to determine the corresponding tap object</param>
        /// <param name="isTapInside">Whether to tap on object or outside the object</param>
        /// <param name="layerMask">Layer mask to tap. Default is the gameObjectToTouch's layer</param>
        /// <returns></returns>
        public bool RegisterTapEvent(GameObject gameObjectToTouch, Constants.Event callback, int SortingLayer = 0, bool isTapInside = true, LayerMask layerMask = default(LayerMask))
        {
            Collider[] colliderList = gameObjectToTouch.GetComponentsInChildren <Collider>();

            if (colliderList != null)
            {
                foreach (Collider itemCollider in colliderList)
                {
                    int layerMaskAsKey = (layerMask != default(LayerMask))? layerMask.value : (1 << gameObjectToTouch.layer);

                    if (m_TapEvents.ContainsKey(layerMaskAsKey))
                    {
                        m_TapEvents[layerMaskAsKey].Add(new TouchEventData(itemCollider, callback, SortingLayer, isTapInside));
                    }
                    else
                    {
                        m_TapEvents[layerMaskAsKey] = new List <TouchEventData>()
                        {
                            new TouchEventData(itemCollider, callback, SortingLayer, isTapInside)
                        };
                    }
                }
            }
            else
            {
                Log.Warning("TouchEventManager", "There is no collider of given gameobjectToTouch");
            }


            return(true);
        }
コード例 #4
0
 /// <summary>
 /// Register an event receiver with this EventManager.
 /// </summary>
 /// <param name="eventType">Event type defined in Constants</param>
 /// <param name="callback">The event receiver function.</param>
 public void RegisterEventReceiver(Constants.Event eventType, OnReceiveEvent callback)
 {
     if (m_EventTypeName.Count == 0)
     {
         InitializeEventTypeNames();
     }
     RegisterEventReceiver(m_EventTypeName[eventType], callback);
 }
コード例 #5
0
ファイル: TouchEventManager.cs プロジェクト: kidaak/unity-sdk
 /// <summary>
 /// Touch event constructor for Tap Event registration.
 /// </summary>
 /// <param name="collider">Collider of the object to tap</param>
 /// <param name="callback">Callback for Tap Event. After tapped, callback will be invoked</param>
 /// <param name="sortingLayer">Sorting level in order to sort the event listeners</param>
 /// <param name="isInside">Whether the tap is inside the object or not</param>
 public TouchEventData(Collider collider, Constants.Event callback, int sortingLayer, bool isInside)
 {
     m_Collider         = collider;
     m_ColliderList     = null;
     m_tapEventCallback = callback;
     m_SortingLayer     = sortingLayer;
     m_isInside         = isInside;
 }
コード例 #6
0
ファイル: TouchEventManager.cs プロジェクト: kidaak/unity-sdk
        /// <summary>
        /// Unregister Drag Event to given call back with given parameters
        /// </summary>
        /// <param name="gameObjectToDrag">GameObject to drag</param>
        /// <param name="callback">Callback to invoke while the object is dragging</param>
        /// <param name="numberOfFinger">Number of fingers working on dragging</param>
        /// <param name="SortingLayer">Sorting layer to determine the corresponding drag event listener</param>
        /// <param name="isDragInside">Not Applicable</param>
        /// <returns>Success result about unregistration</returns>
        public bool UnregisterDragEvent(GameObject gameObjectToDrag, Constants.Event callback, int numberOfFinger = 1, int SortingLayer = 0, bool isDragInside = true)
        {
            bool success = false;

            if (m_DragEvents.ContainsKey(numberOfFinger))
            {
                success = m_DragEvents[numberOfFinger].Remove(new TouchEventData(gameObjectToDrag, callback, SortingLayer, isDragInside));
            }

            return(success);
        }
コード例 #7
0
ファイル: TouchEventManager.cs プロジェクト: kidaak/unity-sdk
 /// <summary>
 /// Touch event constructor for Drag Event registration.
 /// </summary>
 /// <param name="gameObject">Gameobject to drag</param>
 /// <param name="callback">Callback for Drag event. After dragging started, callback will be invoked until drag will be finished</param>
 /// <param name="sortingLayer">Sorting level in order to sort the event listeners</param>
 /// <param name="isInside"></param>
 public TouchEventData(GameObject gameObject, Constants.Event callback, int sortingLayer, bool isInside)
 {
     m_GameObject   = gameObject;
     m_ColliderList = null;
     if (gameObject != null)
     {
         m_ColliderList = gameObject.GetComponentsInChildren <Collider>();
     }
     m_dragEventCallback = callback;
     m_SortingLayer      = sortingLayer;
     m_isInside          = isInside;
 }
コード例 #8
0
        /// <summary>
        /// Send an event to all registered receivers.
        /// </summary>
        /// <param name="eventType">Event type defined in Constants</param>
        /// <param name="args">Arguments to send to the event receiver.</param>
        /// <returns>Returns true if a event receiver was found for the event.</returns>
        public bool SendEvent(Constants.Event eventType, params object[] args)
        {
            if (m_EventTypeName.Count == 0)
            {
                InitializeEventTypeNames();
            }

            if (eventType != Constants.Event.NONE)
            {
                return(SendEvent(m_EventTypeName[eventType], args));
            }
            else
            {
                return(false);
            }
        }
コード例 #9
0
ファイル: TouchEventManager.cs プロジェクト: kidaak/unity-sdk
        /// <summary>
        /// Register Drag Event to given call back with given parameters
        /// </summary>
        /// <param name="gameObjectToDrag">GameObject to drag</param>
        /// <param name="callback">Callback to invoke while the object is dragging</param>
        /// <param name="numberOfFinger">Number of fingers working on dragging</param>
        /// <param name="SortingLayer">Sorting layer to determine the corresponding drag event listener</param>
        /// <param name="isDragInside">Not Applicable</param>
        /// <returns>Success result about registration</returns>
        public bool RegisterDragEvent(GameObject gameObjectToDrag, Constants.Event callback, int numberOfFinger = 1, int SortingLayer = 0, bool isDragInside = true)
        {
            if (m_DragEvents.ContainsKey(numberOfFinger))
            {
                m_DragEvents[numberOfFinger].Add(new TouchEventData(gameObjectToDrag, callback, SortingLayer, isDragInside));
            }
            else
            {
                m_DragEvents[numberOfFinger] = new List <TouchEventData>()
                {
                    new TouchEventData(gameObjectToDrag, callback, SortingLayer, isDragInside)
                };
            }

            return(true);
        }
コード例 #10
0
ファイル: TouchEventManager.cs プロジェクト: kidaak/unity-sdk
        /// <summary>
        ///  Unregister tap event to given callback
        /// </summary>
        /// <param name="gameObjectToTouch">Game object to tap on</param>
        /// <param name="callback">Callback to call after tapped on object (or outside of the object)</param>
        /// <param name="SortingLayer">Sorting layer to determine the corresponding tap object</param>
        /// <param name="isTapInside">Whether to tap on object or outside the object</param>
        /// <param name="layerMask">Layer mask to tap. Default is the gameObjectToTouch's layer</param>
        /// <returns></returns>
        public bool UnregisterTapEvent(GameObject gameObjectToTouch, Constants.Event callback, int SortingLayer = 0, bool isTapInside = true, LayerMask layerMask = default(LayerMask))
        {
            bool success = false;

            int layerMaskAsKey = (layerMask != default(LayerMask))? layerMask.value : (1 << gameObjectToTouch.layer);

            if (m_TapEvents.ContainsKey(layerMaskAsKey))
            {
                success = true;
                Collider[] colliderList = gameObjectToTouch.GetComponentsInChildren <Collider>();
                foreach (Collider itemCollider in colliderList)
                {
                    success &= m_TapEvents[layerMaskAsKey].Remove(new TouchEventData(itemCollider, callback, SortingLayer, isTapInside));
                }
            }

            return(success);
        }
コード例 #11
0
ファイル: KeyEventManager.cs プロジェクト: kidaak/unity-sdk
        /// <summary>
        /// Unregister a key event.
        /// </summary>
        /// <param name="key">The KeyCode to unregister.</param>
        /// <param name="modifiers">Additional keys that must be down as well to fire the event.</param>
        /// <param name="eventType">If provided, then the key will be unregistered only the event matches the existing registration.</param>
        /// <returns>True is returned on success.</returns>
        public bool UnregisterKeyEvent(KeyCode key, KeyModifiers modifiers = KeyModifiers.NONE, Constants.Event eventType = Constants.Event.NONE)
        {
            int code = ((int)key) | (((int)modifiers) << MODIFIER_SHIFT_BITS);

            if (eventType != Constants.Event.NONE && m_KeyEvents.ContainsKey(code) && m_KeyEvents[code] == eventType)
            {
                return(m_KeyEvents.Remove(code));
            }

            return(m_KeyEvents.Remove(code));
        }