RankItem.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 Title = "Title";
  10. public static string TitleBK = "TitleBK";
  11. public static string VisitText = "VisitText";
  12. public static string PraiseText = "PraiseText";
  13. public static string VisitBtn = "VisitBtn";
  14. public static string ContentText = "ContentText";
  15. }
  16. public class Ranktem : Regist
  17. {
  18. public Text Title;
  19. public Text VisitText;
  20. public Text PraiseText;
  21. public Text ContentText;
  22. public Image TitleBK;
  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. Title = childDic[RanktemLabel.Title].GetComponent<Text>();
  36. TitleBK = childDic[RanktemLabel.TitleBK].GetComponent<Image>();
  37. VisitText = childDic[RanktemLabel.VisitText].GetComponent<Text>();
  38. PraiseText = childDic[RanktemLabel.PraiseText].GetComponent<Text>();
  39. VisitBtn = childDic[RanktemLabel.VisitBtn].GetComponent<Button>();
  40. ContentText = childDic[RanktemLabel.ContentText].GetComponent<Text>();
  41. VisitText.text = ResourceManager.Get<Text>(CanvasLabel.C_CostLab).text;
  42. VisitBtn.onClick.AddListener(Visit);
  43. Manager.OnLevelChange += (level) =>
  44. {
  45. VisitText.text = ResourceManager.Get<Text>(CanvasLabel.C_CostLab).text;
  46. };
  47. return false;
  48. }
  49. public void Visit()
  50. {
  51. SocialManager.CloseRankPanel();
  52. SocialManager.RecordRankPanel();
  53. VisitManager.Visit(ConfigSource.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. Title.text = rank;
  61. PraiseText.text = praise;
  62. ContentText.text = "******" + serialNumber.Substring(serialNumber.Length - 4);
  63. if (Rank == 1)
  64. {
  65. TitleBK.color = Lib.FirstRank;
  66. }
  67. else if (Rank == 2)
  68. {
  69. TitleBK.color = Lib.SecondRank;
  70. }
  71. else if (Rank == 3)
  72. {
  73. TitleBK.color = Lib.ThirdRank;
  74. }
  75. else
  76. {
  77. TitleBK.color = Lib.NormalRank;
  78. }
  79. if (SerialNumber == HttpManager.SerialNumber)
  80. {
  81. VisitBtn.SetActive(false);
  82. }
  83. }
  84. }