RankItem.cs 2.6 KB

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