Test de communication de paquets entre un client et un serveur
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PlayerManager.cs 715B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerManager : MonoBehaviour
  5. {
  6. public int id;
  7. public string username;
  8. public float health;
  9. public float maxHealth;
  10. public MeshRenderer model;
  11. public void Initialize(int _id, string _username)
  12. {
  13. id = _id;
  14. username = _username;
  15. health = maxHealth;
  16. }
  17. public void SetHealth(float _health)
  18. {
  19. health = _health;
  20. if (health <= 0f)
  21. {
  22. Die();
  23. }
  24. }
  25. public void Die()
  26. {
  27. model.enabled = false;
  28. }
  29. public void Respawn()
  30. {
  31. model.enabled = true;
  32. SetHealth(maxHealth);
  33. }
  34. }