Advertisement
SizilStank

Untitled

Oct 10th, 2022
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | Gaming | 0 0
  1.  private void OnTriggerEnter2D(Collider2D collision)
  2.     {
  3.        
  4.         if (collision.CompareTag("EnemyA") || collision.CompareTag("EnemyLaser"))
  5.         {    
  6.             if (_isShieldActive == false)
  7.             {
  8.                 Damage();
  9.             }
  10.  
  11.             if (_isShieldActive == true)
  12.             {
  13.                 _countTimesHit.Add(_intToAdd++);
  14.  
  15.  
  16.                 if (_isShieldActive == true && _countTimesHit.Count == 1)
  17.                 {
  18.                     _shieldSpriteRenderer.color = Color.red;
  19.                 }
  20.                 else if (_isShieldActive == true && _countTimesHit.Count == 2)
  21.                 {
  22.                     _shieldSpriteRenderer.color = Color.black;
  23.                 }
  24.                 else
  25.                 {
  26.                     _shieldSpriteRenderer.color = Color.white;
  27.                     _isShieldActive = false;
  28.                     _shieldPrefab.SetActive(false);
  29.                     _countTimesHit.Clear();
  30.                     _audioSource.Stop(); _audioSource.loop = false;
  31.                     _audioSource.clip = _shieldOnPlayerActive;
  32.                     _audioSource.PlayOneShot(_shieldIsOver, 3);
  33.                    // return;
  34.                 }
  35.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement