void OnParticleCollision(GameObject other) { //Physics2D.IgnoreLayerCollision(8, 8); damage = (Idamageable <float>)other.gameObject.GetComponent(typeof(Idamageable <float>)); damageBit = Mathf.Ceil(Random.Range(6f, 13f)); if (other.gameObject.tag == "Enemy Box" || other.gameObject.tag == "Boss") { damage.takeDamage(damageBit, .7f, 3); //Debug.Log(damageBit); //Destroy(other.gameObject); //subtract miniscule amounts of health here } }
//initialize the interface variables to call the damage function and apply the damage each bullet has void OnCollisionEnter2D(Collision2D coll) { damage = (Idamageable <float>)coll.gameObject.GetComponent(typeof(Idamageable <float>)); playerHit = (Idamageable <int>)coll.gameObject.GetComponent(typeof(Idamageable <int>)); if (this.tag == "Normal Bullet" || this.tag == "Spread Bullet") { if (coll.collider.gameObject.tag == "Enemy Box" || coll.collider.gameObject.tag == "Boss") { hitEnemy = true; if (this.tag == "Normal Bullet") { damage.takeDamage(damageNorm, damageMultiplier, 1); } else if (this.tag == "Spread Bullet") { damage.takeDamage(damageSpread, damageMultiplier, 2); } //Destroy(coll.gameObject); Destroy(this.gameObject); } } else if (coll.collider.gameObject.tag == "Player" && counter != 0) { if (this.tag == "Enemy Bullet" || this.tag == "Boss bullet") { playerHit.takeDamage(enemyDamage); if (this.tag == "Boss bullet") { spawner.GetComponent <BossAI>().regenHealth(healthRegen); GameObject temp2; temp2 = Instantiate(particles, transform.position, transform.rotation) as GameObject; Destroy(temp2, 3.0f); } } counter--; //Destroy(this.gameObject); } }
void OnTriggerStay2D(Collider2D other) { damage = (Idamageable <float>)other.gameObject.GetComponent(typeof(Idamageable <float>)); timer += Time.deltaTime; if (other.gameObject.tag == "Enemy Box" || other.gameObject.tag == "Boss") { if (timer > waitBefore) { hitEnemy = true; damage.takeDamage(damageLightning); timer = 0f; waitBefore = 4f; } } }