void OnCollisionEnter2D(Collision2D col) { var bullet = col.gameObject.GetComponent <Bullet>(); if (bullet && bullet.Team != team) { tankHealth.TakeDamage(bullet.attack); HandleHpChange?.Invoke(this, tankHealth.GetCurrentHealth()); if (tankHealth.GetCurrentHealth() <= 0) { Destroy(this.gameObject); } } }
void Awake() { tankInput = new PlayerControlInput(); tankEngine = new TankEngine(tankInput, this.transform, property); tankHeadRotate = new TankHeadRotate(tankInput, tankHead, property); tankFire = new TankFire(tankInput, tankShootPoint, property, fireAnimator, team); tankHealth = new TankHealth(property); HandleHpChange?.Invoke(this, tankHealth.GetCurrentHealth()); }
private void OnCollisionEnter2D(Collision2D col) { var bullet = col.gameObject.GetComponent <Bullet>(); if (bullet && bullet.Team != Team) { tankHealth.TakeDamage(bullet.attack); EnemyHpChange?.Invoke(this, tankHealth.GetCurrentHealth()); } }