Ejemplo n.º 1
0
        private void OnTriggerExit2D(Collider2D collider)
        {
            if (!enabled || collider.gameObject.layer != (int)PhysLayers.ENEMIES)
            {
                return;
            }

            IHitResponder hit = collider.gameObject.GetComponentInSelfChildOrParent <IHitResponder>();

            if (hit == null)
            {
                return;
            }

            foreach (ColliderInfo info in _hitReponders)
            {
                if (info.Responder != hit)
                {
                    continue;
                }

                info.Touching = false;
                break;
            }
        }
Ejemplo n.º 2
0
        private void OnTriggerEnter2D(Collider2D collider)
        {
            if (!enabled || collider.gameObject.layer != (int)PhysLayers.ENEMIES)
            {
                return;
            }

            IHitResponder hit = collider.gameObject.GetComponentInSelfChildOrParent <IHitResponder>();

            ColliderInfo colInfo = _hitReponders.FirstOrDefault(info => info.Responder == hit);

            if (colInfo == null)
            {
                colInfo = new ColliderInfo
                {
                    Responder = hit,
                    Cooldown  = 0
                };

                _hitReponders.Add(colInfo);
            }

            colInfo.Touching = true;
        }