init
This commit is contained in:
commit
a8c6025cd3
158 changed files with 86052 additions and 0 deletions
29
Assets/Scripts/PlayerHealth.cs
Normal file
29
Assets/Scripts/PlayerHealth.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerHealth : MonoBehaviour{
|
||||
|
||||
public Image health;
|
||||
public float hp, maxHp = 12f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
hp = maxHp;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
|
||||
}
|
||||
|
||||
public void TakeDamage(float amount){
|
||||
hp = Mathf.Clamp(hp - amount, 0f, maxHp);
|
||||
health.transform.localScale = new Vector2(hp / maxHp / 100, 0.00927f);
|
||||
}
|
||||
public void AddHealth(float amount){
|
||||
hp = Mathf.Clamp(hp + amount, 0f, maxHp);
|
||||
health.transform.localScale = new Vector2(hp / maxHp / 100, 0.00927f);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue