private void updateCancelled(List <int> points)
        {
            var cancelledCount = points.Count;

            for (var i = 0; i < cancelledCount; i++)
            {
                var        id = points[i];
                TouchPoint touch;
                if (!idToTouch.TryGetValue(id, out touch))
                {
#if TOUCHSCRIPT_DEBUG
                    Debug.LogWarning("TouchScript > Id [" + id +
                                     "] was in CANCELLED list but no touch with such id found.");
#endif
                    continue;
                }
                idToTouch.Remove(id);
                touches.Remove(touch);
                if (touch.Layer != null)
                {
                    touch.Layer.INTERNAL_CancelTouch(touch);
                }

#if TOUCHSCRIPT_DEBUG
                removeDebugFigureForTouch(touch);
#endif

                if (touchCancelledInvoker != null)
                {
                    touchCancelledInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(touch));
                }
                touchPointPool.Release(touch);
            }
        }
Exemple #2
0
        private void updateCancelled(List <int> points)
        {
            var cancelledCount = points.Count;
            var list           = touchListPool.Get();

            for (var i = 0; i < cancelledCount; i++)
            {
                var id    = points[i];
                var touch = idToTouch[id];
                idToTouch.Remove(id);
                touches.Remove(touch);
                list.Add(touch);
                if (touch.Layer != null)
                {
                    touch.Layer.INTERNAL_CancelTouch(touch);
                }

#if DEBUG
                removeDebugFigureForTouch(touch);
#endif
            }

            if (touchesCancelledInvoker != null)
            {
                touchesCancelledInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(list));
            }

            for (var i = 0; i < cancelledCount; i++)
            {
                touchPointPool.Release(list[i] as TouchPoint);
            }
            touchListPool.Release(list);
        }
        private void updateBegan(List <TouchPoint> points)
        {
            var count = points.Count;

            for (var i = 0; i < count; i++)
            {
                var touch = points[i];
                touches.Add(touch);
                idToTouch.Add(touch.Id, touch);

                for (var j = 0; j < layerCount; j++)
                {
                    var touchLayer = layers[j];
                    if (touchLayer == null)
                    {
                        continue;
                    }
                    if (touchLayer.INTERNAL_BeginTouch(touch))
                    {
                        break;
                    }
                }

#if TOUCHSCRIPT_DEBUG
                addDebugFigureForTouch(touch);
#endif

                if (touchBeganInvoker != null)
                {
                    touchBeganInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(touch));
                }
            }
        }
Exemple #4
0
        private void updateUpdated(List <int> points)
        {
            var updatedCount = points.Count;
            var list         = touchListPool.Get();
            // Need to loop through all touches to reset those which did not move
            var count = touches.Count;

            for (var i = 0; i < count; i++)
            {
                touches[i].INTERNAL_ResetPosition();
            }
            for (var i = 0; i < updatedCount; i++)
            {
                var id    = points[i];
                var touch = idToTouch[id];
                list.Add(touch);
                if (touch.Layer != null)
                {
                    touch.Layer.INTERNAL_UpdateTouch(touch);
                }

#if DEBUG
                addDebugFigureForTouch(touch);
#endif
            }

            if (touchesMovedInvoker != null)
            {
                touchesMovedInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(list));
            }
            touchListPool.Release(list);
        }
Exemple #5
0
        private void updateEnded(List <int> points)
        {
            var endedCount = points.Count;
            var list       = touchPointListPool.Get();

            for (var i = 0; i < endedCount; i++)
            {
                var        id = points[i];
                TouchPoint touch;
                if (!idToTouch.TryGetValue(id, out touch))
                {
#if TOUCHSCRIPT_DEBUG
                    Debug.LogWarning("TouchScript > Id [" + id + "] was in ENDED list but no touch with such id found.");
#endif
                    continue;
                }
                idToTouch.Remove(id);
                touches.Remove(touch);
                list.Add(touch);
                if (touch.Layer != null)
                {
                    touch.Layer.INTERNAL_EndTouch(touch);
                }

#if TOUCHSCRIPT_DEBUG
                removeDebugFigureForTouch(touch);
#endif
            }

            if (touchesEndedInvoker != null)
            {
                touchesEndedInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(list));
            }

            for (var i = 0; i < endedCount; i++)
            {
                touchPointPool.Release(list[i]);
            }
            touchPointListPool.Release(list);
        }
Exemple #6
0
        private void updateUpdated(List <int> points)
        {
            var updatedCount = points.Count;
            var list         = touchPointListPool.Get();
            // Need to loop through all touches to reset those which did not move
            var count = touches.Count;

            for (var i = 0; i < count; i++)
            {
                touches[i].INTERNAL_ResetPosition();
            }
            for (var i = 0; i < updatedCount; i++)
            {
                var        id = points[i];
                TouchPoint touch;
                if (!idToTouch.TryGetValue(id, out touch))
                {
#if TOUCHSCRIPT_DEBUG
                    Debug.LogWarning("TouchScript > Id [" + id +
                                     "] was in UPDATED list but no touch with such id found.");
#endif
                    continue;
                }
                list.Add(touch);
                if (touch.Layer != null)
                {
                    touch.Layer.INTERNAL_UpdateTouch(touch);
                }

#if TOUCHSCRIPT_DEBUG
                addDebugFigureForTouch(touch);
#endif
            }

            if (touchesMovedInvoker != null)
            {
                touchesMovedInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(list));
            }
            touchPointListPool.Release(list);
        }
Exemple #7
0
        private void updateBegan(List <TouchPoint> points)
        {
            var count      = points.Count;
            var list       = touchListPool.Get();
            var layerCount = layers.Count;

            for (var i = 0; i < count; i++)
            {
                var touch = points[i];
                list.Add(touch);
                touches.Add(touch);
                idToTouch.Add(touch.Id, touch);

                for (var j = 0; j < layerCount; j++)
                {
                    var touchLayer = Layers[j];
                    if (touchLayer == null)
                    {
                        continue;
                    }
                    if (touchLayer.INTERNAL_BeginTouch(touch))
                    {
                        break;
                    }
                }

#if DEBUG
                addDebugFigureForTouch(touch);
#endif
            }

            if (touchesBeganInvoker != null)
            {
                touchesBeganInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(list));
            }
            touchListPool.Release(list);
        }
Exemple #8
0
        private void updateManuallyCancelled(List <CancelledTouch> points)
        {
            var cancelledCount = points.Count;
            var list           = touchListPool.Get();
            var redispatchList = touchListPool.Get();
            var releaseList    = touchListPool.Get();

            for (var i = 0; i < cancelledCount; i++)
            {
                var        data = points[i];
                var        id   = data.Id;
                TouchPoint touch;
                if (!idToTouch.TryGetValue(id, out touch))
                {
                    // might be dead already
                    continue;
                }

                if (data.Redispatch)
                {
                    redispatchList.Add(touch);
                }
                else
                {
                    idToTouch.Remove(id);
                    touches.Remove(touch);
                    releaseList.Add(touch);
#if DEBUG
                    removeDebugFigureForTouch(touch);
#endif
                }

                list.Add(touch);
                if (touch.Layer != null)
                {
                    touch.Layer.INTERNAL_CancelTouch(touch);
                }
            }

            if (touchesCancelledInvoker != null)
            {
                touchesCancelledInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(list));
            }

            touchListPool.Release(list);
            var count = releaseList.Count;
            for (var i = 0; i < count; i++)
            {
                touchPointPool.Release(releaseList[i] as TouchPoint);
            }
            touchListPool.Release(releaseList);

            count = redispatchList.Count;
            if (count > 0)
            {
                var layerCount = layers.Count;
                for (var i = 0; i < count; i++)
                {
                    var touch = redispatchList[i] as TouchPoint;
                    for (var j = 0; j < layerCount; j++)
                    {
                        var touchLayer = Layers[j];
                        if (touchLayer == null)
                        {
                            continue;
                        }
                        if (touchLayer.INTERNAL_BeginTouch(touch))
                        {
                            break;
                        }
                    }
                }
                if (touchesBeganInvoker != null)
                {
                    touchesBeganInvoker.InvokeHandleExceptions(this, TouchEventArgs.GetCachedEventArgs(redispatchList));
                }
            }
            touchListPool.Release(redispatchList);
        }