public void Explode() { if (_isExploding) { return; } _isExploding = true; SoundManager.Instance.PlaySound("BombExplode"); OnExplosion?.Invoke(this); Destroy(gameObject); }
private void ShootBomb() { var bomb = Instantiate(BombPrefab, BombSpawn.position, BombSpawn.rotation); var bombComponent = bomb.GetComponent <Bomb>(); var bombRigidbody2d = bomb.GetComponent <Rigidbody2D>(); var totalForce = BombForceMultiplier * BombForce * BombAngleVector; var torque = BombForce * BombTorqueMultiplier; bombComponent.Team = Team; bombRigidbody2d.AddForce(totalForce); bombRigidbody2d.AddTorque(torque); ShootBombEvent.Invoke(bombComponent); }
private void Update() { if (_currentTimer > 0) { _currentTimer -= Time.deltaTime; if (_dangerLevel < 2 && _currentTimer < 1f) { _dangerLevel = 2; OnWillExplodeSoon?.Invoke(this); } if (_currentTimer <= 0) { Explode(); } } }