private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.gameObject.tag == "Enemy") { BaseActor enemy = collision.gameObject.GetComponent <BaseActor>(); if (collision.otherCollider == PunchCollider | collision.otherCollider == JumpCollider) { enemy.Hit(Facing); } else if (!IsJumping | JumpCurrentSpeed >= 0) { if (enemy.State != AnimState.HIT & enemy.State != AnimState.DEAD) { Hit(Facing); } } } else if (collision.collider.gameObject.tag == "EnemyProjectile") { if (collision.otherCollider != PunchCollider & collision.otherCollider != JumpCollider) { Hit(Facing); Destroy(collision.collider.gameObject); } } if (collision.gameObject.tag == "PowerUp") { PowerUp powerUp = collision.gameObject.GetComponent <PowerUp>(); gameController.Audio.PlayOneShot(gameController.PowerUp); switch (powerUp.Type) { case PowerUpType.BOMB: ScoreManager.Instance.Bombs++; break; case PowerUpType.HEALTH: if (ScoreManager.Instance.HitPoints < ScoreManager.Instance.MaxHitPoints) { ScoreManager.Instance.HitPoints++; } break; case PowerUpType.SPEED: if (ScoreManager.Instance.WalkSpeed < ScoreManager.Instance.MaxWalkSpeed) { ScoreManager.Instance.WalkSpeed++; } break; } ScoreManager.Instance.Score += powerUp.ScoreValue; Destroy(collision.gameObject); } }