Пример #1
0
    protected override bool OnBulletCollision(Collider _collider)
    {
        if (ownerObject != null && ownerObject.tag == "Player" && _collider.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            IEnemy enemyHit = _collider.gameObject.GetComponent <IEnemy>();
            if (enemyHit != null)
            {
                enemyHit.StunHit();
                enemyHit.ApplyKnockback(shotDirection.Value, enemyKnockbackForce);
                EnemyBase enemyBase = (enemyHit as EnemyBase);
                if (enemyBase != null && enemyBase.OnEnemyHit != null)
                {
                    enemyBase.OnEnemyHit();
                }
            }
        }
        else if (ownerObject != null && ownerObject.tag == "Player" && _collider.gameObject.layer == LayerMask.NameToLayer("Buttons"))
        {
            IButton _target = _collider.gameObject.GetComponent <IButton>();
            if (_target.GetTriggerType() == ButtonTriggerType.Shot)
            {
                _target.Activate();
            }
            else
            {
                return(false);
            }
        }

        return(base.OnBulletCollision(_collider));
    }
Пример #2
0
    protected override bool OnBulletCollision(Collider _collider)
    {
        if (ownerObject != null && ownerObject.tag == "Player" && _collider.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            IEnemy enemyHit = _collider.gameObject.GetComponent <IEnemy>();
            if (enemyHit != null)
            {
                enemyHit.DamageHit(GetBulletDamage());
                enemyHit.ApplyKnockback(shotDirection.Value, enemyKnockbackForce);
                EnemyBase enemyBase = (enemyHit as EnemyBase);
                if (enemyBase != null && enemyBase.OnEnemyHit != null)
                {
                    enemyBase.OnEnemyHit();
                }
            }
        }

        else if (ownerObject != null && ownerObject.tag != "Player" && _collider.gameObject.layer == LayerMask.NameToLayer("Player"))
        {
            Player player = _collider.gameObject.GetComponent <Player>();
            if (player != null)
            {
                player.GetHealthController().DamageHit(damage);
            }
            else
            {
                IEnemy enemyHit = _collider.gameObject.GetComponent <IEnemy>();
                if (enemyHit != null)
                {
                    player = enemyHit.gameObject.GetComponentInParent <Player>();
                    enemyHit.GetToleranceCtrl().AddTolerance(damage);
                }
            }

            if (player.OnPlayerHit != null)
            {
                player.OnPlayerHit();
            }
        }

        else if (ownerObject != null && ownerObject.tag == "Player" && _collider.gameObject.layer == LayerMask.NameToLayer("Buttons"))
        {
            IButton _target = _collider.gameObject.GetComponent <IButton>();
            if (_target.GetTriggerType() == ButtonTriggerType.Shot)
            {
                _target.Activate();
            }
            else
            {
                return(false);
            }
        }

        return(base.OnBulletCollision(_collider));
    }