Advertisement
VenaSean

Simple Health Manager Script (C#)

Oct 29th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class HealthManager : MonoBehaviour {
  5.  
  6.     [Header("Look at these")]
  7.     //These are the stats that change
  8.     public float CurrHealth;
  9.     public int Damage;
  10.     public int DamagePS;
  11.  
  12.     [Header("These are set")]
  13.     //These stats never change
  14.     public int MaxHealth = 100;
  15.     public int MinHealth = 0;
  16.  
  17.     // Use this for initialization
  18.     void Start () {
  19.         CurrHealth = MaxHealth;
  20.         Damage = 0;
  21.         DamagePS = 0;
  22.     }
  23.    
  24.     // Update is called once per frame
  25.     void Update () {
  26.         if (Damage >= 1) {
  27.             CurrHealth -= Damage;
  28.             Damage = 0;
  29.         }
  30.         if (CurrHealth <= 0) {
  31.             Debug.Log ("Game Over!");
  32.             return;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement