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();
    }
Beispiel #2
0
 private void Update()
 {
     if (transform.position.z < 0)
     {
         GrenadeExplosion explosion = Instantiate(explosionPrefab, transform.position + Vector3.forward * 2, Quaternion.identity);
         explosion.startingStrength = strength;
         Destroy(gameObject);
     }
 }
Beispiel #3
0
 public void BlowUp()
 {
     //We can have this instantiate the explosion
     grenadeExplosionCopy                   = Instantiate(grenadeExplosion, transform.position, Quaternion.identity) as GameObject;
     explosionScript                        = grenadeExplosionCopy.GetComponent <GrenadeExplosion>();
     explosionScript.teamCount              = teamCount;
     explosionScript.grenadeDamage          = grenadeDamage;
     explosionScript.range                  = range;
     explosionScript.mySprite.color         = mySprite.color;
     explosionScript.myParticles.startColor = mySprite.color;
     Destroy(this.gameObject);
 }