FashionShowCloseBox.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class FashionShowCloseCell
  5. {
  6. #region Config
  7. public bool Praised;
  8. public Text PraiseText;
  9. public Button PraiseButton;
  10. public Button ShareButton;
  11. public Button DisplayButton;
  12. public Player Player;
  13. public FashionShowData FashionShowData;
  14. #endregion
  15. public FashionShowCloseCell(Text praiseText, Button praiseButton, Button shareButton, Button displayButton)
  16. {
  17. PraiseText = praiseText;
  18. PraiseButton = praiseButton;
  19. ShareButton = shareButton;
  20. DisplayButton = displayButton;
  21. PraiseButton.onClick.AddListener(OnPraiseButtonClick);
  22. ShareButton.onClick.AddListener(OnShareButtonClick);
  23. DisplayButton.onClick.AddListener(OnDisplayButtonClick);
  24. }
  25. public void Init(float scale, FashionShowData data)
  26. {
  27. FashionShowData = data;
  28. Praised = data.Praised;
  29. if (Praised)
  30. {
  31. PraiseButton.image.color = Lib.Pink;
  32. }
  33. else
  34. {
  35. PraiseButton.image.color = Color.white;
  36. }
  37. PraiseText.text = data.PraisedAmount.ToString();
  38. DisplayButton.transform.SetActive(true);
  39. Player = PlayerManager.Instance.GetRawPlayer();
  40. Player.transform.SetParent(DisplayButton.transform);
  41. Player.transform.SetAsFirstSibling();
  42. Player.transform.localPosition = Vector3.zero;
  43. foreach (var closeID in data.CloseIDs)
  44. {
  45. CloseItem closeItem = PlayerManager.CloseItemDictionary[closeID];
  46. closeItem.ChangeDress(Player, false);
  47. }
  48. DelayCall.Call(1, ()=> { Player.DisplayInUI(scale); Player.ResetDepth(); });
  49. }
  50. public void Save()
  51. {
  52. DisplayButton.SetActive(false);
  53. if (Player != null)
  54. {
  55. Player.DisplayInScene();
  56. ResourceManager.Save(Player, true);
  57. }
  58. }
  59. private void OnShareButtonClick()
  60. {
  61. AudioManager.PlayClip(ResourceLabel.BtnClip);
  62. }
  63. private void OnPraiseButtonClick()
  64. {
  65. AudioManager.PlayClip(ResourceLabel.BtnClip);
  66. if (Praised)
  67. {
  68. Praised = false;
  69. PraiseButton.image.color = Color.white;
  70. PraiseText.text = (int.Parse(PraiseText.text) - 1).ToString();
  71. HttpManager.UnpraiseFashionShow(null, null);
  72. }
  73. else
  74. {
  75. Praised = true;
  76. PraiseButton.image.color = Lib.Pink;
  77. PraiseText.text = (int.Parse(PraiseText.text) + 1).ToString();
  78. HttpManager.PraiseFashionShow(null, null);
  79. }
  80. }
  81. private void OnDisplayButtonClick()
  82. {
  83. AudioManager.PlayClip(ResourceLabel.BtnClip);
  84. TweenRoot tween = FashionShowHomePage.HideSidePanel();
  85. bool belongSelf = FashionShowData.RefererNickname == NickNameManager.NickName;
  86. tween.AddEventOnetime(EventType.BackwardFinish, ()=> { FashionShowEditPage.ShowRatePanel(belongSelf, FashionShowData); FashionShowEditPage.LeaveToHomePage = true; });
  87. }
  88. }
  89. public class FashionShowCloseBox : VirtualScrollRectItem
  90. {
  91. #region Config
  92. //StartMark-Used by LabelUtility-Do not remove
  93. private Text A_PraiseText;
  94. private Text B_PraiseText;
  95. private Text C_PraiseText;
  96. private Text D_PraiseText;
  97. private Text E_PraiseText;
  98. private Button A_DisplayBackground;
  99. private Button A_PraiseButton;
  100. private Button A_ShareButton;
  101. private Button B_DisplayBackground;
  102. private Button B_PraiseButton;
  103. private Button B_ShareButton;
  104. private Button C_DisplayBackground;
  105. private Button C_PraiseButton;
  106. private Button C_ShareButton;
  107. private Button D_DisplayBackground;
  108. private Button D_PraiseButton;
  109. private Button D_ShareButton;
  110. private Button E_DisplayBackground;
  111. private Button E_PraiseButton;
  112. private Button E_ShareButton;
  113. //EndMark-Used by LabelUtility-Do not remove
  114. public List<FashionShowCloseCell> Cells = new List<FashionShowCloseCell>();
  115. public List<FashionShowCloseCell> UnusedCells = new List<FashionShowCloseCell>();
  116. #endregion
  117. public override bool Init()
  118. {
  119. if (base.Init()) return true;
  120. //RegistStartMark-Used by LabelUtility-Do not remove
  121. Dictionary<string, Transform> childDictionary = new Dictionary<string, Transform>();
  122. Auxiliary.CompileDic(transform, childDictionary);
  123. A_PraiseText = childDictionary[FashionShowCloseBoxLabel.A_PraiseText].GetComponent<Text>();
  124. B_PraiseText = childDictionary[FashionShowCloseBoxLabel.B_PraiseText].GetComponent<Text>();
  125. C_PraiseText = childDictionary[FashionShowCloseBoxLabel.C_PraiseText].GetComponent<Text>();
  126. D_PraiseText = childDictionary[FashionShowCloseBoxLabel.D_PraiseText].GetComponent<Text>();
  127. E_PraiseText = childDictionary[FashionShowCloseBoxLabel.E_PraiseText].GetComponent<Text>();
  128. A_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.A_DisplayBackground].GetComponent<Button>();
  129. A_PraiseButton = childDictionary[FashionShowCloseBoxLabel.A_PraiseButton].GetComponent<Button>();
  130. A_ShareButton = childDictionary[FashionShowCloseBoxLabel.A_ShareButton].GetComponent<Button>();
  131. B_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.B_DisplayBackground].GetComponent<Button>();
  132. B_PraiseButton = childDictionary[FashionShowCloseBoxLabel.B_PraiseButton].GetComponent<Button>();
  133. B_ShareButton = childDictionary[FashionShowCloseBoxLabel.B_ShareButton].GetComponent<Button>();
  134. C_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.C_DisplayBackground].GetComponent<Button>();
  135. C_PraiseButton = childDictionary[FashionShowCloseBoxLabel.C_PraiseButton].GetComponent<Button>();
  136. C_ShareButton = childDictionary[FashionShowCloseBoxLabel.C_ShareButton].GetComponent<Button>();
  137. D_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.D_DisplayBackground].GetComponent<Button>();
  138. D_PraiseButton = childDictionary[FashionShowCloseBoxLabel.D_PraiseButton].GetComponent<Button>();
  139. D_ShareButton = childDictionary[FashionShowCloseBoxLabel.D_ShareButton].GetComponent<Button>();
  140. E_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.E_DisplayBackground].GetComponent<Button>();
  141. E_PraiseButton = childDictionary[FashionShowCloseBoxLabel.E_PraiseButton].GetComponent<Button>();
  142. E_ShareButton = childDictionary[FashionShowCloseBoxLabel.E_ShareButton].GetComponent<Button>();
  143. //RegistEndMark-Used by LabelUtility-Do not remove
  144. Cells.Add(new FashionShowCloseCell(A_PraiseText, A_PraiseButton, A_ShareButton, A_DisplayBackground));
  145. Cells.Add(new FashionShowCloseCell(B_PraiseText, B_PraiseButton, B_ShareButton, B_DisplayBackground));
  146. Cells.Add(new FashionShowCloseCell(C_PraiseText, C_PraiseButton, C_ShareButton, C_DisplayBackground));
  147. Cells.Add(new FashionShowCloseCell(D_PraiseText, D_PraiseButton, D_ShareButton, D_DisplayBackground));
  148. Cells.Add(new FashionShowCloseCell(E_PraiseText, E_PraiseButton, E_ShareButton, E_DisplayBackground));
  149. reset();
  150. return false;
  151. }
  152. public bool HaveUnusedCell()
  153. {
  154. return UnusedCells.Count > 0;
  155. }
  156. public void SetNextCell(FashionShowData data)
  157. {
  158. float scale = UnusedCells.Count == 5 ? 37.5f : 17.5f;
  159. FashionShowCloseCell cell = UnusedCells.Forward(0, true);
  160. cell.Init(scale, data);
  161. }
  162. public void reset()
  163. {
  164. UnusedCells = new List<FashionShowCloseCell>(Cells);
  165. foreach (var cell in Cells)
  166. {
  167. cell.Save();
  168. }
  169. }
  170. }