-
billc27 authorede062535d
RestoreHealthOrbs.cs 850 B
using Nightmare;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RestoreHealthOrbs : Orbs
{
PlayerHealth playerHealth;
Slider healthSlider;
public override void Start()
{
playerHealth = GameObject.Find("Player").GetComponent<PlayerHealth>();
healthSlider = GameObject.Find("HealthSlider").GetComponent<Slider>();
// Destroy object after 5 seconds
Destroy(gameObject, 5f);
}
public override void ApplyOrbEffect()
{
playerHealth.currentHealth += 20;
if (playerHealth.currentHealth > 100)
{
playerHealth.currentHealth = 100;
}
// Set Health Slider
healthSlider.value = playerHealth.currentHealth;
// Destroy the orb
Destroy(gameObject);
}
}