mirror of
https://github.com/Project-Redacted/project-hampter.git
synced 2025-06-02 08:43:14 +00:00
Update :3
This commit is contained in:
parent
1f50b3f262
commit
6bbd56a5cf
759 changed files with 269694 additions and 37600 deletions
49
Assets/AI/Health.cs
Normal file
49
Assets/AI/Health.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Health : MonoBehaviour
|
||||
{
|
||||
|
||||
public int CurrentHealth;
|
||||
public int MaxHealth;
|
||||
public bool Immune = false;
|
||||
public float ImmuneTime = 2f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CurrentHealth = MaxHealth;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void PlayerHit()
|
||||
{
|
||||
|
||||
if(Immune)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentHealth--;
|
||||
if(CurrentHealth <= 0)
|
||||
{
|
||||
Die();
|
||||
}
|
||||
Immune = true;
|
||||
Invoke("MakeNotImmune", ImmuneTime);
|
||||
}
|
||||
|
||||
public void MakeNotImmune()
|
||||
{
|
||||
Immune = false;
|
||||
}
|
||||
|
||||
public void Die()
|
||||
{
|
||||
SceneManager.LoadScene("TempMainMenu"); // load the next scene
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue