Example #1
0
 private void Update()
 {
     if (player != null && (DateTime.Now - lastEncounter).TotalSeconds > timeDelay)
     {
         player.TakeTamage(damage);
         lastEncounter = DateTime.Now;
     }
 }
Example #2
0
 private void Update()
 {
     if (_player != null && (DateTime.Now - _lastEncounter).TotalSeconds > _timeDelay)
     {
         _player.TakeTamage(_damage);
         _lastEncounter = DateTime.Now;
     }
 }
Example #3
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - _lastEncounter).TotalSeconds < _timeDelay / 2)
        {
            return;
        }

        _lastEncounter = DateTime.Now;
        _player        = info.GetComponent <Player_controller>();
        if (_player != null)
        {
            _player.TakeTamage(_damage);
        }
    }
Example #4
0
    protected void Strike()
    {
        Collider2D player = Physics2D.OverlapBox(_strikePoint.position, new Vector2(_strikeRange, _strikeRange), 0, _enemies);

        if (player != null)
        {
            Player_controller playerControler = player.GetComponent <Player_controller>();
            int damage = _inRage ? _damage * 2 : _damage;
            if (playerControler != null)
            {
                playerControler.TakeTamage(damage);
            }
        }
    }
Example #5
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - lastEncounter).TotalSeconds < 0.02f)
        {
            return;
        }

        lastEncounter = DateTime.Now;
        player        = info.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeTamage(damage, DamageType.PowerStrike, gameObject.transform);
        }
    }
Example #6
0
    protected virtual void TryToDamage(Collider2D enemy)
    {
        if ((Time.time - _lastDamageTime) < _collisionTimeDelay)
        {
            return;
        }

        Player_controller player = enemy.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeTamage(_collisionDamage, _collisionDamageType, transform);
            _lastDamageTime = Time.time;
        }
    }
    private void OnTriggerEnter2D(Collider2D info)
    {
        if (Time.time - _lastEncounter < 0.2f)
        {
            return;
        }

        _lastEncounter = Time.time;
        Player_controller player = info.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeTamage(_damage);
        }
        Destroy(gameObject);
    }
Example #8
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if (_damaged)
        {
            return;
        }

        Player_controller target = info.GetComponent <Player_controller>();

        if (target != null)
        {
            _damaged = true;
            target.TakeTamage(_damage, DamageType.Projectile, transform);
        }

        Destroy(gameObject);
    }
Example #9
0
    protected virtual void TryToDamage(Collider2D enemy)
    {
        if (enemy == null)
        {
            return;
        }

        if ((Time.time - _lastDamageTime) < _collisionTimeDelay)
        {
            return;
        }

        Player_controller player = enemy.GetComponent <Player_controller>();

        if (player != null && !player.IsDead)
        {
            GetComponent <Animator>().Play("Attack");
            player.TakeTamage(_collisionDamage, _collisionDamageType, transform);
            _lastDamageTime = Time.time;
        }
    }