Пример #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"))
        {
            spawnSticky = false;

            IEnemy enemyHit = _collider.gameObject.GetComponent <IEnemy>();
            if (enemyHit != null)
            {
                enemyHit.DamageHit(GetBulletDamage());
                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"))
        {
            spawnSticky = false;

            Player player = _collider.gameObject.GetComponent <Player>();
            if (player != null)
            {
                player.GetHealthController().DamageHit(GetBulletDamage());
            }
            else
            {
                IEnemy enemyHit = _collider.gameObject.GetComponent <IEnemy>();
                if (enemyHit != null)
                {
                    player = enemyHit.gameObject.GetComponentInParent <Player>();
                    enemyHit.GetToleranceCtrl().AddTolerance(GetBulletDamage());
                }
            }

            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)
            {
                spawnSticky = false;
                _target.Activate();
            }
            else
            {
                return(false);
            }
        }

        return(base.OnBulletCollision(_collider));
    }
Пример #3
0
  protected override bool OnBulletCollision(Collider _collider)
  {
      if (ownerObject != null && ownerObject.tag == "Player" && _collider.gameObject.layer == LayerMask.NameToLayer("Enemy"))
      {
          _collider.gameObject.GetComponent <IEnemy>().DamageHit(GetBulletDamage());
      }

      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
          {
              _collider.gameObject.GetComponent <IEnemy>().GetToleranceCtrl().AddTolerance(damage);
          }

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

      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));
  }