void FixedUpdate() { Collider[] cols = Physics.OverlapSphere(tran.position, 2.0f); foreach (Collider col in cols) { if ((1 << col.gameObject.layer & check_layer) > 0) { IntObjBase tmp = col.GetComponent <IntObjBase>(); if (tmp != null) { tmp.Damage(); } if (explosive) { Instantiate(GameControl.inst.expl_part, tran.position, tran.rotation); ExplosiveDamage(col); } if (sound != GameSnd.None) { SoundScript.CreateSound(tran, SoundHandler.GetSnd(sound)); } Destroy(gameObject); return; } } }
public override void Damage() { StopAllCoroutines(); enabled = false; tran.position -= look_pos; GameControl.AddScore(100); SoundScript.CreateSound(tran, SoundHandler.GetSnd(GameSnd.Death)); anims.Play("Death"); StartCoroutine(DelayDestroy()); }
public override void Damage() { //Prevent any movement when playing death animation StopAllCoroutines(); enabled = false; col.enabled = false; rig.velocity = Vector3.zero; GameControl.AddScore(100); SoundScript.CreateSound(tran, SoundHandler.GetSnd(GameSnd.Death)); anims.Play("Death"); StartCoroutine(DelayDestroy()); }
IEnumerator Destroy() { yield return(new WaitForSeconds(1.0f)); Collider[] cols = Physics.OverlapSphere(tran.position, 8.0f); foreach (Collider col in cols) { if ((1 << col.gameObject.layer & CHECK_LAYER) > 0) { IntObjBase tmp = col.GetComponent <IntObjBase>(); if (tmp != null) { tmp.Damage(); } } } Instantiate(GameControl.inst.expl_part, tran.position, tran.rotation); SoundScript.CreateSound(tran, SoundHandler.GetSnd(GameSnd.GrenadeEx)); Destroy(gameObject); }