예제 #1
0
        protected override void Colliding(Collider2D collider)
        {
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            // if the object we're colliding with is part of our ignore list, we do nothing and exit
            if (_ignoredGameObjects.Contains(collider.gameObject))
            {
                return;
            }

            // if what we're colliding with isn't part of the target layers, we do nothing and exit
            if (!MMLayers.LayerInLayerMask(collider.gameObject.layer, TargetLayerMask))
            {
                return;
            }

            /*if (Time.time - _knockbackTimer < InvincibilityDuration)
             * {
             *  return;
             * }
             * else
             * {
             *  _knockbackTimer = Time.time;
             * }*/


            _lucyHealth = collider.gameObject.GetComponentNoAlloc <LucyHealth>();


            // if what we're colliding with is damageable
            if (_lucyHealth != null)
            {
                if (_lucyHealth._ultraSuitAcquired == false)
                {
                    if (_lucyHealth.CurrentHealth > 0)
                    {
                        OnCollideWithDamageable(_lucyHealth);
                    }
                }
            }

            // if what we're colliding with can't be damaged
            else
            {
                OnCollideWithNonDamageable();
            }

            //Make it so the flamethrower doesn't work in water
            _lucyFlamethrower = collider.gameObject.GetComponentNoAlloc <LucyFlamethrower>();

            if (_lucyFlamethrower != null)
            {
                _lucyFlamethrower.AbilityPermitted = false;
            }
        }
예제 #2
0
        protected override void Colliding(GameObject collider)
        {
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            // if the object we're colliding with is part of our ignore list, we do nothing and exit
            if (_ignoredGameObjects.Contains(collider))
            {
                return;
            }

            // if what we're colliding with isn't part of the target layers, we do nothing and exit
            if (!MMLayers.LayerInLayerMask(collider.layer, TargetLayerMask))
            {
                return;
            }

            // if we're on our first frame, we don't apply damage
            if (Time.time == 0f)
            {
                return;
            }

            // we get the character and apply all the status effects in the list
            _character = collider.gameObject.MMGetComponentNoAlloc <Character>();
            if (_character != null)
            {
                foreach (var statusEffect in StatusEffects)
                {
                    StatusEffectEvent.Trigger(statusEffect, _character, StatusEffectEventTypes.Apply);
                }
            }

            _colliderHealth = collider.gameObject.MMGetComponentNoAlloc <Health>();

            // if what we're colliding with is damageable
            if (_colliderHealth != null)
            {
                if (_colliderHealth.CurrentHealth > 0)
                {
                    OnCollideWithDamageable(_colliderHealth);
                }
            }

            // if what we're colliding with can't be damaged
            else
            {
                OnCollideWithNonDamageable();
            }
        }
예제 #3
0
        protected virtual void Colliding(Collider2D collider)
        {
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            // if the object we're colliding with is part of our ignore list, we do nothing and exit
            if (_ignoredGameObjects.Contains(collider.gameObject))
            {
                return;
            }

            // if what we're colliding with isn't part of the target layers, we do nothing and exit
            if (!MMLayers.LayerInLayerMask(collider.gameObject.layer, TargetLayerMask))
            {
                return;
            }

            /*if (Time.time - _knockbackTimer < InvincibilityDuration)
             * {
             *      return;
             * }
             * else
             * {
             *      _knockbackTimer = Time.time;
             * }*/

            _colliderHealth = collider.gameObject.GetComponentNoAlloc <Health>();

            // if what we're colliding with is damageable
            if (_colliderHealth != null)
            {
                if (_colliderHealth.CurrentHealth > 0)
                {
                    OnCollideWithDamageable(_colliderHealth);
                }
            }

            // if what we're colliding with can't be damaged
            else
            {
                OnCollideWithNonDamageable();
            }
        }
예제 #4
0
/*
 * void Update()
 * {
 *      FindClosestEnemy();
 * }
 */

    void OnTriggerEnter2D(Collider2D collider)
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }

        // if what we're colliding with isn't part of the target layers, we do nothing and exit
        if (!MMLayers.LayerInLayerMask(collider.gameObject.layer, TargetLayerMask))
        {
            return;
        }

        //Debug.Log("This object: " + this.gameObject.name + " collided with: "+ collider.gameObject.name + "in layer: " + collider.gameObject.layer);
        DeathFeedbacks?.PlayFeedbacks();
//Destroy(gameObject);
        gameObject.SetActive(false); //trying this to prevent destroy access errors - seems to work!
    }
예제 #5
0
        protected override void Colliding(Collider2D collider)
        {
            base.Colliding(collider);
            if (!isActiveAndEnabled ||
                _ignoredGameObjects.Contains(collider.gameObject) ||
                !MMLayers.LayerInLayerMask(collider.gameObject.layer, TargetLayerMask) ||
                !FreezeOnTouch)
            {
                return;
            }
            var collidingCharacter = collider.gameObject.MMGetComponentNoAlloc <Character>();

            if (collidingCharacter == null)
            {
                return;
            }
            collidingCharacter.StartCoroutine(FreezeCharacter(collidingCharacter));
        }
예제 #6
0
        /// <summary>
        /// When colliding, we apply damage
        /// </summary>
        /// <param name="collider"></param>
        protected virtual void Colliding(GameObject collider)
        {
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            // if the object we're colliding with is part of our ignore list, we do nothing and exit
            if (_ignoredGameObjects.Contains(collider))
            {
                return;
            }

            // if what we're colliding with isn't part of the target layers, we do nothing and exit
            if (!MMLayers.LayerInLayerMask(collider.layer, TargetLayerMask))
            {
                return;
            }

            // if we're on our first frame, we don't apply damage
            if (Time.time == 0f)
            {
                return;
            }

            _collisionPoint = this.transform.position;
            _colliderHealth = collider.gameObject.MMGetComponentNoAlloc <Health>();

            // if what we're colliding with is damageable
            if (_colliderHealth != null)
            {
                if (_colliderHealth.CurrentHealth > 0)
                {
                    OnCollideWithDamageable(_colliderHealth);
                }
            }

            // if what we're colliding with can't be damaged
            else
            {
                OnCollideWithNonDamageable();
            }
        }
예제 #7
0
        protected virtual void Colliding(Collider2D collider)
        {
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            // if the object we're colliding with is part of our ignore list, we do nothing and exit
            if (_ignoredGameObjects.Contains(collider.gameObject))
            {
                return;
            }

            // if what we're colliding with isn't part of the target layers, we do nothing and exit
            if (!MMLayers.LayerInLayerMask(collider.gameObject.layer, TargetLayerMask))
            {
                return;
            }

            _collidingCollider = collider;
            _colliderHealth    = collider.gameObject.MMGetComponentNoAlloc <Health>();

            OnHit?.Invoke();

            // if what we're colliding with is damageable
            if (_colliderHealth != null)
            {
                if (_colliderHealth.CurrentHealth > 0)
                {
                    OnCollideWithDamageable(_colliderHealth);
                }
            }
            // if what we're colliding with can't be damaged
            else
            {
                OnCollideWithNonDamageable();
            }
        }
예제 #8
0
        /// <summary>
        /// When colliding, we kill our collider if it's a Health equipped object
        /// </summary>
        /// <param name="collider"></param>
        protected virtual void Colliding(GameObject collider)
        {
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            // if what we're colliding with isn't part of the target layers, we do nothing and exit
            if (!MMLayers.LayerInLayerMask(collider.layer, TargetLayerMask))
            {
                return;
            }

            _colliderHealth = collider.gameObject.MMGetComponentNoAlloc <Health>();

            // if what we're colliding with is damageable
            if (_colliderHealth != null)
            {
                if (_colliderHealth.CurrentHealth > 0)
                {
                    _colliderHealth.Kill();
                }
            }
        }