private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "PlayerProjectile") { Projectile missile = collision.gameObject.GetComponent <Projectile>(); player = GameObject.FindWithTag("Player"); ReceiveDamage(player.GetComponent <Movement>().damage); missile.Hit(); } else if (collision.gameObject.tag == "PlasmaBull") { PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ReceiveDamage(player.damage); missile.Hit(); } else if (collision.gameObject.tag == "FlatBull") { FlatBull missile = collision.gameObject.GetComponent <FlatBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ReceiveDamage(player.damage); missile.Hit(); } else if (collision.gameObject.tag == "DefensiveBull") { DefensiveBull missile = collision.gameObject.GetComponent <DefensiveBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); Destroy(); missile.Hit(); } else if (collision.gameObject.tag == "RocketBull") { RocketBull missile = collision.gameObject.GetComponent <RocketBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ReceiveDamage(player.damage); missile.Hit(); } else if (collision.gameObject.tag == "LaserBull") { LaserBull missile = collision.gameObject.GetComponent <LaserBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); Destroy(); } else if (collision.gameObject.tag == "Player") { ReceiveDamage(health); } else if (collision.gameObject.tag == "SpecialMove") { ReceiveDamage(health); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "PlayerProjectile") { Projectile missile = collision.gameObject.GetComponent <Projectile>(); healthSlider.value -= missile.GetDamage(); hitPoints -= missile.GetDamage(); missile.Hit(); } else if (collision.gameObject.tag == "PlasmaBull") { PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>(); healthSlider.value -= missile.GetDamage(); hitPoints -= missile.GetDamage(); missile.Hit(); } else if (collision.gameObject.tag == "FlatBull") { FlatBull missile = collision.gameObject.GetComponent <FlatBull>(); healthSlider.value -= missile.GetDamage(); hitPoints -= missile.GetDamage(); missile.Hit(); } else if (collision.gameObject.tag == "RocketBull") { RocketBull missile = collision.gameObject.GetComponent <RocketBull>(); healthSlider.value -= missile.GetDamage(); hitPoints -= missile.GetDamage(); missile.Hit(); } else if (collision.gameObject.tag == "LaserBull") { LaserBull missile = collision.gameObject.GetComponent <LaserBull>(); healthSlider.value -= missile.GetDamage(); hitPoints -= missile.GetDamage(); Destroy(missile); } else if (collision.gameObject.tag == "SpecialMove") { healthSlider.value -= specialAttackDmg; hitPoints -= specialAttackDmg; dealDamage = true; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "PlayerProjectile") { Projectile missile = collision.gameObject.GetComponent <Projectile>(); ReceiveDamage(player.GetComponent <Movement>().damage); missile.Hit(); } else if (collision.gameObject.tag == "PlasmaBull") { PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ReceiveDamage(player.damage); missile.Hit(); } else if (collision.gameObject.tag == "FlatBull") { FlatBull missile = collision.gameObject.GetComponent <FlatBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ReceiveDamage(player.damage); missile.Hit(); } else if (collision.gameObject.tag == "DefensiveBull") { DefensiveBull missile = collision.gameObject.GetComponent <DefensiveBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); Destroy(); missile.Hit(); } else if (collision.gameObject.tag == "LaserBull") { LaserBull missile = collision.gameObject.GetComponent <LaserBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); Destroy(); } else if (collision.gameObject.tag == "RocketBull") { RocketBull missile = collision.gameObject.GetComponent <RocketBull>(); Movement player = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>(); ReceiveDamage(player.damage); missile.Hit(); } else if (collision.gameObject.tag == "Player") { ReceiveDamage(health); } else if (collision.gameObject.tag == "SpecialMove") { ReceiveDamage(health); } if (health <= 0) { FindObjectOfType <Movement>().IncreasePoints(pointsDropped); Slider test = GameObject.FindGameObjectWithTag("ChargeBar").GetComponent <Slider>(); test.value += chargeBarValue; explosionPooler.GetPooledObject(transform.position, transform.rotation); Destroy(); if (Random.Range(1f, 100f) <= 20f) { Vector3 position = transform.position + new Vector3(0f, -0.8f); Instantiate(Drop1, position, transform.rotation); } if (Random.Range(1f, 100f) > 95f) { Vector3 position = transform.position + new Vector3(0f, -0.8f); Instantiate(TripleShot, position, TripleShot.transform.rotation); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "EnemyProjectile") { Projectile missile = collision.gameObject.GetComponent <Projectile>(); PlasmaBull missile2 = collision.gameObject.GetComponent <PlasmaBull>(); health -= missile.GetDamage(); healthbar.value -= missile.GetDamage(); missile.Hit(); health -= missile2.GetDamage(); healthbar.value -= missile2.GetDamage(); missile2.Hit(); } else if (collision.gameObject.tag == "Boss") { health -= 300; healthbar.value -= 300; } else if (collision.gameObject.tag == "Enemy") { health -= 70; healthbar.value -= 70; IncreasePoints(collision.gameObject.GetComponent <EnemyBehaviour>().pointsDropped); } else if (collision.gameObject.tag == "Enemy2") { Enemy2Behaviour enemy = collision.gameObject.GetComponent <Enemy2Behaviour>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <Enemy2Behaviour>().pointsDropped); } else if (collision.gameObject.tag == "Enemy3") { collision.gameObject.GetComponent <EnemyBehaviour3>(); health = 0; healthbar.value = 0; } else if (collision.gameObject.tag == "Enemy4") { EnemyBehaviour4 enemy = collision.gameObject.GetComponent <EnemyBehaviour4>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <EnemyBehaviour4>().pointsDropped); } else if (collision.gameObject.tag == "Eenemy") { Eenemy enemy = collision.gameObject.GetComponent <Eenemy>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <Eenemy>().pointsDropped); } else if (collision.gameObject.tag == "Eenemy2") { Eenemy2 enemy = collision.gameObject.GetComponent <Eenemy2>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <Eenemy2>().pointsDropped); } else if (collision.gameObject.tag == "Eenemy3") { Eenemy3 enemy = collision.gameObject.GetComponent <Eenemy3>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <Eenemy3>().pointsDropped); } else if (collision.gameObject.tag == "Eenemy4") { Eenemy4 enemy = collision.gameObject.GetComponent <Eenemy4>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <Eenemy4>().pointsDropped); } else if (collision.gameObject.tag == "Eenemy5") { Eenemy5 enemy = collision.gameObject.GetComponent <Eenemy5>(); health = 0; healthbar.value = 0; IncreasePoints(collision.gameObject.GetComponent <Eenemy5>().pointsDropped); } else if (collision.gameObject.tag == "HealthUp") { health += 50; healthbar.value += 50; if (health > maxHealth) { health = maxHealth; } Destroy(collision.gameObject); } else if (collision.gameObject.tag == "TripleShot") { x3Activated = true; rocketActivated = false; x3Timer = 0; Destroy(collision.gameObject); } else if (collision.gameObject.tag == "Drop2") { rocketActivated = true; x3Activated = false; rocketTimer = 0; Destroy(collision.gameObject); } if (collision.gameObject.tag == "Drop3") { if (defenceActivated) { Destroy(collision.gameObject); } else { defenceActivated = true; defenceSpawn = true; defenceTimer = 0; Destroy(collision.gameObject); } } else if (collision.gameObject.tag == "Drop4") { flatactivated = true; x3Activated = false; flattimer = 0; Destroy(collision.gameObject); } else if (collision.gameObject.tag == "BombBull") { health = 0; healthbar.value = 0; collision.gameObject.GetComponent <BombBull>().Destroy(); } else if (collision.gameObject.tag == "PowerUp") { if (points >= 1000) { GameObject pwup = collision.gameObject; healthbar.maxValue *= pwup.GetComponent <Powerup>().Health; maxHealth *= pwup.GetComponent <Powerup>().Health; secondsPerShot *= pwup.GetComponent <Powerup>().FiringRate; damage *= pwup.GetComponent <Powerup>().Damage; //FindObjectOfType<Shop>().DestroyPowerUps(); //pwup.GetComponent<Powerup>().Hit(); IncreasePoints(-1000); pwup.GetComponent <Powerup>().Hit(); } } if (health <= 0) { Destroy(gameObject); isDead = true; } }