private void OnTriggerEnter2D(Collider2D otherObj) { if (otherObj.name == "Laser(Clone)" || otherObj.name == "Triple Shot(Clone)" || otherObj.name == "Triple Shot") { Player player = otherObj.GetComponentInParent <Player>(); if (player.isPlayer_1 == true) { uiManager.Player_1Score(); } if (player.isPlayer_2 == true) { uiManager.Player_2Score(); } else { uiManager.PlayerScore(); } CreateEnemyDeathExplosion(); soundFX.ExplosionSound(); Destroy(otherObj.gameObject); Destroy(gameObject); } else if (otherObj.name == "Player(Clone)" || otherObj.name == "Player_1(Clone)" || otherObj.name == "Player_2(Clone)") { Player player = otherObj.GetComponent <Player>(); if (player != null) { CheckForPlayerShield(player); } } }
public void TakeDamage() { if (gameManager.isCoOpMode == false) { playerLives--; uiManager.RemainingPlayerLives(playerLives); DamageAnimation(); if (playerLives <= 0) { gameManager.isPlayerDead = true; PlayerDeath(); soundFX.ExplosionSound(); Destroy(gameObject); } } else if (gameManager.isCoOpMode == true) { if (isPlayer_1 == true && isPlayer_2 == false) { playerLives--; uiManager.RemainingPlayer_1Lives(playerLives); DamageAnimation(); if (playerLives <= 0) { gameManager.isPlayer_1Dead = true; PlayerDeath(); soundFX.ExplosionSound(); Destroy(gameObject); } } if (isPlayer_2 == true && isPlayer_1 == false) { playerLives--; uiManager.RemainingPlayer_2Lives(playerLives); DamageAnimation(); if (playerLives <= 0) { gameManager.isPlayer_2Dead = true; PlayerDeath(); soundFX.ExplosionSound(); Destroy(gameObject); } } } }