示例#1
0
    public void Explode()
    {
        if (_isExploding)
        {
            return;
        }

        _isExploding = true;

        SoundManager.Instance.PlaySound("BombExplode");

        OnExplosion?.Invoke(this);

        Destroy(gameObject);
    }
示例#2
0
    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);
    }
示例#3
0
    private void Update()
    {
        if (_currentTimer > 0)
        {
            _currentTimer -= Time.deltaTime;

            if (_dangerLevel < 2 && _currentTimer < 1f)
            {
                _dangerLevel = 2;
                OnWillExplodeSoon?.Invoke(this);
            }

            if (_currentTimer <= 0)
            {
                Explode();
            }
        }
    }