private void OnTriggerEnter2D(Collider2D collision) { Boss01Controller boss01 = collision.gameObject.GetComponent <Boss01Controller>(); if (boss01 != null) { boss01.ChangeHealth(-Atk); } EnemyController slime = collision.gameObject.GetComponent <EnemyController>(); if (slime != null) { slime.ChangeHealth(-Atk); } Boss02Controller boss02 = collision.gameObject.GetComponent <Boss02Controller>(); if (boss02 != null) { boss02.ChangeHealth(-Atk); } BossBody bossBody = collision.gameObject.GetComponent <BossBody>(); if (bossBody != null) { bossBody.ChangeHealth(-Atk); } Boss03Controller boss03 = collision.gameObject.GetComponent <Boss03Controller>(); if (boss03 != null) { boss03.ChangeHealth(-Atk); } }
void Launch() { //Tao projectile GameObject projectileObject1 = Instantiate(projectilePrefab, rigidbody2d.position + Vector2.left * 1.5f + Vector2.up * 1f, Quaternion.identity); GameObject projectileObject2 = Instantiate(projectilePrefab, rigidbody2d.position + Vector2.left * 0f + Vector2.up * 0f, Quaternion.identity); GameObject projectileObject3 = Instantiate(projectilePrefab, rigidbody2d.position + Vector2.right * 1.5f + Vector2.up * 1f, Quaternion.identity); Boss03Controller projectile1 = projectileObject1.GetComponent <Boss03Controller>(); Boss03Controller projectile2 = projectileObject2.GetComponent <Boss03Controller>(); Boss03Controller projectile3 = projectileObject3.GetComponent <Boss03Controller>(); //Vector2 direction1 = new Vector2(-1f, 0.5f); //Vector2 direction2 = new Vector2(-0.6f, 0.5f); //Vector2 direction3 = new Vector2(1f, 0.5f); projectile1.SetChild((int)(maxHealth * 0.7f)); projectile2.SetChild((int)(maxHealth * 0.7f)); projectile3.SetChild((int)(maxHealth * 0.7f)); //animator.SetTrigger("Launch"); }