コード例 #1
0
    public override void Death(GameObject Instigator)
    {
        if (isDead)
        {
            return;
        }

        base.Death(Instigator);

        //Shield = 0;

        //Stop execution if we have lives to add
        if (Lives <= 0 && Health <= 0)
        {
            if (FullDeath != null)
            {
                FullDeath();
            }

            return;
        }

        Invulnerable = true;
        Lives--;

        LifeLost();

        //Dealing radial damage to all enemies nearby
        GameplayStatics.DealRadialDamage(DeathDamageRadius, transform.position, 100, EDamageType.ALL, gameObject);

        //Destroying all projectiles
        Collider[] bullets = Physics.OverlapSphere(transform.position, 100.0f);//, 12);
        foreach (Collider bullet in bullets)
        {
            PL_Bullet bulletscript = bullet.gameObject.GetComponent <PL_Bullet>();

            if (bulletscript && bullet.gameObject.tag == "EnemyProjectile")
            {
                bulletscript.SpawnEffects();
                Destroy(bullet.gameObject);
            }
        }

        if (OnLivesAdded != null)
        {
            OnLivesAdded(Lives);
        }

        Invoke("ResetHealth", invulnerableTime);
    }