private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Ammo") { switch (ID) { case 0: { destroy(); break; } case 1: { if (collision.GetComponent <AmmoScript>().canTakeExtraLife == true) { collision.GetComponent <AmmoScript>().takeExtraLife(); _activated = true; } break; } case 2: { MakeDamageRight(); GetComponent <Animation>().Play(); _activated = true; break; } case 3: { MakeDamageUp(); GetComponent <Animation>().Play(); _activated = true; break; } case 4: { MakeDamageUp(); MakeDamageRight(); GetComponent <Animation>().Play(); _activated = true; break; } case 5: { destroy(); break; } case 6: { Physics2D.IgnoreLayerCollision(8, 11); Physics2D.IgnoreLayerCollision(11, 12); Physics2D.IgnoreLayerCollision(11, 11); AmmoScript ammo = collision.GetComponent <AmmoScript>(); Vector2 dir = ammo.getDirect(); float speed = ammo.getSpeed(); ammo.ChangeDirect(); Vector2 position = ammo.gameObject.transform.position; GameObject additiveammo = Instantiate(additiveAmmo, position, Quaternion.identity, canvas.transform); additiveammo.GetComponent <AmmoScript>().setParram(dir, speed, _ammoId); additiveammo.GetComponent <AmmoScript>().gameManager = _gameManager; _ammoId++; _gameManager.AddAmmo(additiveammo); _activated = true; break; } case 7: { Vector2 dir; int a; a = Random.Range(0, 11); int b; b = Random.Range(1, 5); if (a >= 6) { dir = Vector2.up + Vector2.right * b; } else { dir = Vector2.up + Vector2.left * b; } collision.GetComponent <AmmoScript>().ChangeDirect(dir.normalized); _activated = true; break; } } } }