public void PickUpItem() { LevelManager.instance.keyPicked(); Debug.Log("KeyPicked"); //if player is thirsty, apply thirstToRemove to thirstPoints if (FPSPlayerComponent.thirstPoints > 0.0f && FPSPlayerComponent.usePlayerThirst) { if (FPSPlayerComponent.thirstPoints - thirstToRemove > 0.0) { FPSPlayerComponent.UpdateThirst(-thirstToRemove); } else { FPSPlayerComponent.UpdateThirst(-FPSPlayerComponent.thirstPoints); } //restore player health by healthToRestore amount if (FPSPlayerComponent.hitPoints + healthToRestore < FPSPlayerComponent.maximumHitPoints) { FPSPlayerComponent.HealPlayer(healthToRestore); } else { FPSPlayerComponent.HealPlayer(FPSPlayerComponent.maximumHitPoints - FPSPlayerComponent.hitPoints); } //play pickup sound if (pickupSound) { PlayAudioAtPos.PlayClipAt(pickupSound, myTransform.position, 0.75f); } if (removeOnUse) { FreePooledObjects(); //remove this drink pickup Object.Destroy(gameObject); } } else { //if player not thirsty, just play beep sound if (fullSound) { PlayAudioAtPos.PlayClipAt(fullSound, myTransform.position, 0.75f); } } }
void PickUpItem(GameObject user) { FPSPlayerComponent = user.GetComponent <FPSPlayer>(); if (FPSPlayerComponent.hitPoints < FPSPlayerComponent.maximumHitPoints) { //heal player FPSPlayerComponent.HealPlayer(healthToAdd); if (pickupSound) { PlayAudioAtPos.PlayClipAt(pickupSound, myTransform.position, 0.75f); } if (removeOnUse) { FreePooledObjects(); //remove this pickup Object.Destroy(gameObject); } } else { //player is already at max health, just play beep sound effect if (fullSound) { PlayAudioAtPos.PlayClipAt(fullSound, myTransform.position, 0.75f); } } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("BlockMagnet")) // checks for the player Block magnet in order to be picked up. { FPSPlayerComponent = other.transform.parent.GetComponent <FPSPlayer> (); if (FPSPlayerComponent.hitPoints < FPSPlayerComponent.maximumHitPoints) { //heal player FPSPlayerComponent.HealPlayer(healthToAdd); if (pickupSound) { PlayAudioAtPos.PlayClipAt(pickupSound, myTransform.position, 0.75f); } if (removeOnUse) { FreePooledObjects(); //remove this pickup Object.Destroy(gameObject); } } else { //player is already at max health, just play beep sound effect if (fullSound) { PlayAudioAtPos.PlayClipAt(fullSound, myTransform.position, 0.75f); } } } }
public void PickUpItem() { //if player is hungry, apply hungerToRemove to hungerPoints if (FPSPlayerComponent.hungerPoints > 0.0f && FPSPlayerComponent.usePlayerHunger) { if (FPSPlayerComponent.hungerPoints - hungerToRemove > 0.0) { FPSPlayerComponent.UpdateHunger(-hungerToRemove); } else { FPSPlayerComponent.UpdateHunger(-FPSPlayerComponent.hungerPoints); } //restore player health by healthToRestore amount if (FPSPlayerComponent.hitPoints + healthToRestore < FPSPlayerComponent.maximumHitPoints) { FPSPlayerComponent.HealPlayer(healthToRestore); } else { FPSPlayerComponent.HealPlayer(FPSPlayerComponent.maximumHitPoints - FPSPlayerComponent.hitPoints); } //play pickup sound if (pickupSound) { PlayAudioAtPos.PlayClipAt(pickupSound, myTransform.position, 0.75f); } if (removeOnUse) { FreePooledObjects(); //remove this food pickup Object.Destroy(gameObject); } } else { //if player is not hungry, just play beep sound if (fullSound) { PlayAudioAtPos.PlayClipAt(fullSound, myTransform.position, 0.75f); } } }