Example #1
0
 private void Update()
 {
     if (_player != null && (DateTime.Now - _LastEncounter).TotalSeconds > _timeDelay)
     {
         _player.ChangeHp(-_damage);
         _LastEncounter = DateTime.Now;
     }
 }
Example #2
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - _LastEncounter).TotalSeconds < 0.1f)
        {
            return;
        }

        _LastEncounter = DateTime.Now;

        _player = info.GetComponent <Player_controller>();
        if (_player != null)
        {
            _player.ChangeHp(-_damage);
        }
    }