Exemplo n.º 1
0
        private async void Delay(int delay, bool isExplosion)
        {
            await Task.Delay(delay);

            if (!gameObject.activeInHierarchy)
            {
                return;
            }

            if (isExplosion)// взорвём объект, если можно
            {
                _lastExplosion.Detonation();
            }
            else
            {
                _lastRb.AddForce(transform.forward * Damage, ForceMode.Impulse);
            }
        }
Exemplo n.º 2
0
    protected virtual void FindNearestObjects()//поиск ближайших объектов и подрыв их
    {
        _objectDown.Explosives.Remove(this);
        FoundObjects = _objectDown.GetNearestObject(transform.position, Raduis, RaduisExplosion);
        for (int i = 0; i < FoundObjects.Count; i++)
        {
            if (FoundBlock = FoundObjects[i] as BaseBlock)
            {
                FoundBlock.Destroy(Power);
            }
            else if (FoundExplosiveObject = FoundObjects[i] as ExplosiveObject)
            {
                FoundExplosiveObject.Detonation();
            }
        }

        if (Vector3.Distance(transform.position, _player.transform.position) < Raduis * 3)
        {
            _player.AddExplosionForce(10, transform.position, Raduis * 3, 0, ForceMode.Impulse);
        }

        Destroy(gameObject);
    }