private void DestroyBox() { player.AmmoCounter(0); myCollider.enabled = false; sr.enabled = false; Destroy(this.gameObject); }
private void OnTriggerEnter(Collider other) { { if (other.GetComponent <UnityStandardAssets.Characters.FirstPerson.RigidbodyFirstPersonController>()) { //player = other.GetComponent<PlayerAnimations>(); if (isBig) { if (player.ARAmmo < player.maxar) { player.ARAmmo = player.maxar; DestroyBox(); } if (player.MGAmmo < player.maxmg) { player.MGAmmo = player.maxmg; DestroyBox(); } if (player.shotgunAmmo < player.maxsg) { player.shotgunAmmo = player.maxsg; DestroyBox(); } if (player.pistolAmmo < player.maxpistol) { player.pistolAmmo = player.maxpistol; DestroyBox(); } } else { if (player.wpnNum == 0) { if (player.pistolAmmo < player.maxpistol) { player.AmmoCounter(-player.maxpistol + player.pistolAmmo); DestroyBox(); } } if (player.wpnNum == 1) { if (player.ARAmmo < player.maxar) { player.AmmoCounter(-player.maxar + player.ARAmmo); DestroyBox(); } } if (player.wpnNum == 3) { if (player.shotgunAmmo < player.maxsg) { player.AmmoCounter(-player.maxsg + player.shotgunAmmo); DestroyBox(); } } if (player.wpnNum == 2) { if (player.MGAmmo < player.maxmg) { player.AmmoCounter(-player.maxmg + player.MGAmmo); DestroyBox(); } } } } } }