process TODO.md step4

This commit is contained in:
SepComet
2026-03-28 15:50:44 +08:00
parent 4a152e765b
commit f0064e2ae5
22 changed files with 850 additions and 62 deletions
+23 -2
View File
@@ -14,7 +14,12 @@ public class PlayerUI : MonoBehaviour
_canvas = this.transform.GetComponent<Canvas>();
_mainCamera = Camera.main;
this._master = master;
this._text.text = _master.PlayerId;
RefreshText();
}
public void SyncAuthoritativeState(ClientAuthoritativePlayerStateSnapshot snapshot)
{
RefreshText(snapshot);
}
private void FixedUpdate()
@@ -41,4 +46,20 @@ public class PlayerUI : MonoBehaviour
{
_isVisible = false;
}
}
private void RefreshText(ClientAuthoritativePlayerStateSnapshot snapshot = null)
{
if (_text == null || _master == null)
{
return;
}
if (snapshot == null)
{
_text.text = _master.PlayerId;
return;
}
_text.text = $"{_master.PlayerId}\nHP:{snapshot.Hp} Tick:{snapshot.Tick}";
}
}