OnlinePlayerItemComp.cs 896 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using Api;
  3. using UI.Hall;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace UI.Items
  7. {
  8. public class OnlinePlayerItemComp : MonoBehaviour
  9. {
  10. public Text NameText;
  11. public Text PlayerIdText;
  12. public Image Avatar;
  13. public GameObject InviteButton;
  14. private Action<int> _inviteClick;
  15. private PlayerInfo _player;
  16. public void init(Action<int> OnInviteClick, PlayerInfo dataPlayer)
  17. {
  18. _inviteClick = OnInviteClick;
  19. _player = dataPlayer;
  20. refreshUI();
  21. }
  22. private void refreshUI()
  23. {
  24. NameText.text = _player.name;
  25. PlayerIdText.text = "ID:"+_player.id + "";
  26. AvatarUtil.DisplayAvatar(Avatar, _player.avatar);
  27. }
  28. public void A__ClickInvite()
  29. {
  30. _inviteClick.Invoke(_player.id);
  31. }
  32. }
  33. }