What is the Problem???
My Error Code is
using UnityEngine;
using System.Collections;
public class HealthController : MonoBehaviour {
public float startHealth = 5;
public int startLifePoints = 3;
private float health = 5;
private int lifePoints = 3;
private Animator anim;
private PlayerController playerController;
private bool isDead = false;
private bool isDamageable = true;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
playerController = GetComponent<PlayerController> ();
if (Application.loadedLevel == 0) {
health = startHealth;
lifePoints = startLifePoints;
} else {
health = PlayerPrefs.GetFloat ("Health");
lifePoints = PlayerPrefs.GetInt ("LifePoints");
}
}
void ApplyDamage(float damage) {
health -= damage;
health = Mathf.May (0, health);
if (!isDead) {
if (health == 0) {
isDead = true;
Dying ();
} else {
if (isDamageable) {
Damaging ();
}
}
isDamageable = false;
Invoke ("ResetIsDamagable", 1);
}
}
void ResetIsDamagable() {
isDamageable = true;
}
void Dying() {
anim.SetBool ("Dying", true);
playerController.enabled = false;
lifePoints --;
if (lifePoints <= 0) {
//startgame
Invoke ("StartGame" , 3);
} else {
//Restart Level
Invoke ("RestartLevel", 1);
}
}
void StartGame() {
Application.LoadLevel (0);
}
void RestartLevel() {
health = startHealth;
isDead = false;
anim.SetBool ("Dying", false);
playerController.enabled = true;
if (!playerController.lookingRight) {
playerController.Flip();
}
}
void Damaging() {
anim.SetTrigger ("Damage");
}
void OnDestroy() {
PlayerPrefs.SetFloat ("Health", health);
PlayerPrefs.Setint ("LifePoints", lifePoints);
}
}