コード例 #1
0
    public void explode()
    {
        if (hasExploded)
        {
            return;
        }
        hasExploded = true;
        Am.am.oneshot(Am.am.M.GrenadeExplosion);
        ExplosionPosition = this.transform.position;
        GrenadeExplosion.Play(true);
        Astronaut.TheAstronaut.addCamShake(1f * (1f / (1f + ((Astronaut.TheAstronaut.transform.position - ExplosionPosition).magnitude / 8f))), .5f, 1f, .5f, 1f);
        MyRigidbody.bodyType = RigidbodyType2D.Kinematic;

        Collider2D[] cols = Physics2D.OverlapCircleAll(this.transform.position, BLASTRADIUS, LayerMask.GetMask(new string[] { "Enemy", "Boss" }));

        foreach (Collider2D col in cols)
        {
            GenericEnemy ge = col.gameObject.GetComponent <GenericEnemy>();
            if (ge != null)
            {
                OnGrenadeHit(col);
                continue;
            }
            BossGolem bo = col.gameObject.GetComponent <BossGolem>();

            if (bo != null)
            {
                OnGrenadeHit(col);
                continue;
            }
        }
        Live = false;
        Remove();
    }