void OnTriggerEnter2D(Collider2D collider) { // Collision with boss KingMosquitoScript boss = collider.gameObject.GetComponent <KingMosquitoScript>(); if (boss != null) { boss.HitByEgg(); } }
void OnTriggerEnter2D(Collider2D collider) { //Debug.Log("hit"); // Collision with enemy EnemyScript enemy = collider.gameObject.GetComponent <EnemyScript>(); if (enemy != null) { // Kill the mosquito enemy MosquitoHealthScript enemyHealth = enemy.GetComponent <MosquitoHealthScript>(); if (enemyHealth != null) { enemyHealth.Damage(attackDamage); } } //collide with ameba AmebaMoveScript ameba = collider.gameObject.GetComponent <AmebaMoveScript>(); if (ameba != null) { Debug.Log("ameba"); switch (ameba.type) { case 1: Debug.Log("Heal Powerup"); GameObject.Find("Scripts").GetComponent <HealthScript>().DamageBody(-amebaHealAmount); break; case 2: Debug.Log("Double Width Powerup"); float powerupWidth = gameObject.transform.localScale.x * widthSizeScale; if (powerupWidth > 15) { powerupWidth = 15.0f; } gameObject.transform.localScale = new Vector3(powerupWidth, gameObject.transform.localScale.y, gameObject.transform.localScale.z); sizePowerupCooldown = sizePowerUpTimeLength; big = true; break; } // play noise AudioSource[] sounds = GetComponents <AudioSource>(); AudioSource deathNoise = sounds[ameba.type - 1]; deathNoise.Play(); Destroy(ameba.gameObject); } //collide with egg EggScript egg = collider.gameObject.GetComponent <EggScript>(); if (egg != null) { Debug.Log("blast off egg"); egg.HitByPlayer(); } // attack phase 2 boss KingMosquitoScript km = collider.gameObject.GetComponent <KingMosquitoScript>(); if (km != null) { km.HitByPlayer(attackDamage); } }