void FireEMP() { if (empCount > 0) { empCount--; SoundManagerScript.Instance.StopAllCoroutines(); SoundManagerScript.Instance.StartCoroutine(SoundManagerScript.Instance.BGMFadeVolume(0f, 0.1f, 0f)); SoundManagerScript.Instance.PlaySFX(AudioClipID.SFX_EMP); PlayerManagerScript.instance.EMPCount.text = "X : " + empCount.ToString(); for (int i = 0; i < 3; i++) { GameObject newemp = Instantiate(empGO, transform.position, Quaternion.identity) as GameObject; BoomParticleScript empScript = newemp.GetComponent <BoomParticleScript>(); if (empScript != null) { empScript.emp = true; empScript.ExpandBoom(4f - i - 0.5f, 0f, 0f, 4f / (i + 1)); empScript.GetComponent <SpriteRenderer>().color = Color.cyan; } } SoundManagerScript.Instance.StartCoroutine(SoundManagerScript.Instance.BGMFadeVolume(0.1f, 1f, 2f)); } }
public IEnumerator HitEMP() { for (int i = 0; i < 5; i++) { yield return(new WaitForSeconds(0.5f * i)); float randX = Random.Range(transform.position.x - rend.bounds.extents.x, transform.position.x + rend.bounds.extents.x); float randY = Random.Range(transform.position.y - rend.bounds.extents.y, transform.position.y + rend.bounds.extents.y); Vector3 vect = new Vector3(randX, randY, 0f); GameObject go = Instantiate(boomParticle, vect, Quaternion.identity); go.transform.parent = transform; BoomParticleScript goScript = go.GetComponent <BoomParticleScript>(); goScript.GetComponent <SpriteRenderer>().color = Color.cyan; goScript.ExpandBoom(0.2f, 0f, 0f, 2.5f); goScript.coll.enabled = false; } }
public void TakeDamage(float damage) { flashTime = 0.25f; if (!damageFlash) { damageFlash = true; } if ((health - damage) < 0f) { float temp = health - damage; health = 0f; WaveManagerScript.instance.liveEnemyHealth -= (damage - Mathf.Abs(temp)); } else { WaveManagerScript.instance.liveEnemyHealth -= damage; health -= damage; } if (health <= 0f) { WaveManagerScript.instance.liveEnemyList.Remove(this); GameObject go = Instantiate(boomParticle, transform.position, Quaternion.identity); BoomParticleScript goScript = go.GetComponent <BoomParticleScript>(); goScript.GetComponent <SpriteRenderer>().color = Color.red; goScript.ExpandBoom(0.75f, 0f, 0f, 2.5f); goScript.coll.enabled = false; Destroy(gameObject); SoundManagerScript.Instance.PlaySFX(AudioClipID.SFX_DEATH); } }