RankItemComp.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Api;
  5. using UI.Hall;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. public class RankItemComp : MonoBehaviour
  9. {
  10. public GameObject icon1;
  11. public GameObject icon2;
  12. public GameObject icon3;
  13. public Text NumberText;
  14. public Text NameText;
  15. public Text PlayerIdText;
  16. public Image Avatar;
  17. public Text ScoreText;
  18. private Action<int> _inviteClick;
  19. private PlayerInfo _player;
  20. private int _no;
  21. public void init(Action<int> OnInviteClick, PlayerInfo dataPlayer,int no)
  22. {
  23. _inviteClick = OnInviteClick;
  24. _player = dataPlayer;
  25. _no = no;
  26. Debug.Log(""+_no);
  27. refreshUI();
  28. }
  29. private void refreshUI()
  30. {
  31. icon1.SetActive(_no==1);
  32. icon2.SetActive(_no==2);
  33. icon3.SetActive(_no==3);
  34. NameText.text = _player.name;
  35. PlayerIdText.text = "ID:"+_player.id + "";
  36. ScoreText.text = "" + _player.score;
  37. NumberText.text = "" + _no;
  38. AvatarUtil.DisplayAvatar(Avatar, _player.avatar);
  39. }
  40. public void A__ClickInvite()
  41. {
  42. _inviteClick.Invoke(_player.id);
  43. }
  44. }