Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
41
Assets/Scripts/PlayerHealth.cs
Normal file
41
Assets/Scripts/PlayerHealth.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using MLAPI;
|
||||
using MLAPI.NetworkVariable;
|
||||
|
||||
public class PlayerHealth : NetworkBehaviour
|
||||
{
|
||||
public Text healthValue = null;
|
||||
|
||||
NetworkVariableFloat health = new NetworkVariableFloat(new NetworkVariableSettings { WritePermission = NetworkVariablePermission.Everyone }, 100f);
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (IsLocalPlayer)
|
||||
{
|
||||
healthValue.text = health.Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
health.Value -= damage;
|
||||
}
|
||||
|
||||
public void Heal(float amount)
|
||||
{
|
||||
if (health.Value <= 100f)
|
||||
{
|
||||
health.Value += amount;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue