RankItem.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using Random = UnityEngine.Random;
  7. public class Ranktem : Regist
  8. {
  9. public Text Tit;
  10. public Text VisitLab;
  11. public Text PraiseLab;
  12. public Text ContentLab;
  13. public Image TitBK;
  14. public Button VisitBtn;
  15. public int Rank;
  16. public int Praise;
  17. public string SerialNumber;
  18. public override bool InitAtOnce()
  19. {
  20. if (base.InitAtOnce())
  21. {
  22. return true;
  23. }
  24. Dictionary<string, Transform> childDic = new Dictionary<string, Transform>();
  25. Auxiliary.CompileDic(transform, childDic);
  26. Tit = childDic["Tit"].GetComponent<Text>();
  27. TitBK = childDic["TitBK"].GetComponent<Image>();
  28. VisitLab = childDic["VisitLab"].GetComponent<Text>();
  29. PraiseLab = childDic["PraiseLab"].GetComponent<Text>();
  30. VisitBtn = childDic["VisitBtn"].GetComponent<Button>();
  31. ContentLab = childDic["ContentLab"].GetComponent<Text>();
  32. VisitLab.text = ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text;
  33. VisitBtn.onClick.AddListener(Visit);
  34. Manager.OnLevelChange += () =>
  35. {
  36. VisitLab.text = ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text;
  37. };
  38. return false;
  39. }
  40. public void Visit()
  41. {
  42. SocialManager.CloseRankPanel();
  43. SocialManager.RecordRankPanel();
  44. VisitManager.Visit(ArchiveSource.SerialNumber, SerialNumber);
  45. }
  46. public void Reset(string rank, string praise, string serialNumber)
  47. {
  48. Rank = int.Parse(rank);
  49. Praise = int.Parse(praise);
  50. SerialNumber = serialNumber;
  51. Tit.text = rank;
  52. PraiseLab.text = praise;
  53. ContentLab.text = "******" + serialNumber.Substring(serialNumber.Length - 4);
  54. if (Rank == 1)
  55. {
  56. TitBK.color = Lib.FirstRank;
  57. }
  58. else if (Rank == 2)
  59. {
  60. TitBK.color = Lib.SecondRank;
  61. }
  62. else if (Rank == 3)
  63. {
  64. TitBK.color = Lib.ThirdRank;
  65. }
  66. else
  67. {
  68. TitBK.color = Lib.NormalRank;
  69. }
  70. if (SerialNumber == HttpManager.SerialNumber)
  71. {
  72. VisitBtn.SetActive(false);
  73. }
  74. }
  75. }