12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class PlayerManager : MonoBehaviour
- {
- public int id;
- public string username;
- public float health;
- public float maxHealth;
- public MeshRenderer model;
-
- public void Initialize(int _id, string _username)
- {
- id = _id;
- username = _username;
- health = maxHealth;
- }
-
- public void SetHealth(float _health)
- {
- health = _health;
-
- if (health <= 0f)
- {
- Die();
- }
- }
-
- public void Die()
- {
- model.enabled = false;
- }
-
- public void Respawn()
- {
- model.enabled = true;
- SetHealth(maxHealth);
- }
- }
|