Exemplo n.º 1
0
 public void TakeDamage(int damage, bool allegiance)
 {
     if (allegiance == true && _player == false || allegiance == false && _player == true)
     { //checks if the bullet came from player or not to prevent friendly fire
         if (_shielded == false && _crate == false)
         {
             _hp -= damage;
             _partNumber--;
             TakeParts();
             CheckHealth();
             if (_civil == false && _player == false)
             {
                 if (_hp < _life / _divisionOfHP4Run)
                 {
                     _carEn.StartFleeing(); // makes enemy wanting to try to hide himself from you
                 }
             }
         }
         else if (_crate == true)
         {
             _shell.SetActive(false);
             _expl.Play();
             Destroy(_thisAI, _timeToDestroy);
         }
     }
 }