private void TakeHit() { GameObject xp = Instantiate(expolsion, transform.position, Quaternion.identity); xp.transform.localScale = new Vector2(2, 2); HitByEnemy.Invoke(); gameSceneController.ScoreUpdateOnKill -= GameSceneController_ScoreUpdateOnKill; Destroy(gameObject); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag.ToLower().StartsWith("powerup")) { PowerUpCollected(collision.gameObject.GetComponent <PowerUp>().PowerUpType); Destroy(collision.gameObject); } else { Destroy(collision.gameObject); Destroy(gameObject); HitByEnemy?.Invoke(); } }
private void TakeHit() { GameObject xp = Instantiate(expolsion, transform.position, Quaternion.identity); xp.transform.localScale = new Vector2(2, 2); // THE USE OF A ACTION INVOKED if (HitByEnemy != null) { HitByEnemy.Invoke(); } // For this particular event unsubscription you have to check if the last Projectile // isn't null... // if (lastProjectile != null) // { // lastProjectile.ProjectileOutOfBounds -= EnableProjectile; // } gameSceneController.ScoreUpdateOnKill -= GameSceneController_ScoreUpdatedOnKill; Destroy(gameObject); }
public static void CallHitByEnemy() { HitByEnemy?.Invoke(); }