FashionShowEditPage.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class FashionShowEditPage : Regist
  7. {
  8. #region Config
  9. //StartMark-Used by LabelUtility-Do not remove
  10. private static Text CoinText;
  11. private static Text DiamondText;
  12. private static Text RecommendTitle;
  13. private static Text PraiseText;
  14. private static Text FashionTitlePlaceHolder;
  15. private static Text FashionContentPlaceHolder;
  16. private static Text CuteTitle;
  17. private static Text CuteValue;
  18. private static Text CuteRateText;
  19. private static Text GraceTitle;
  20. private static Text GraceValue;
  21. private static Text GraceRateText;
  22. private static Text VividTitle;
  23. private static Text VividValue;
  24. private static Text VividRateText;
  25. private static Text SimpleTitle;
  26. private static Text SimpleValue;
  27. private static Text SimpleRateText;
  28. private static Text GloryTitle;
  29. private static Text GloryValue;
  30. private static Text GloryRateText;
  31. private static Text FashionShowClosesTitle;
  32. private static Text CloseTotalCoinText;
  33. private static Text CloseTotalDiamondText;
  34. private static Button Return;
  35. private static Button DisplayEditButton;
  36. private static Button DeleteButton;
  37. private static Button ResetButton;
  38. private static Button SaveButton;
  39. private static Button PraiseButton;
  40. private static Button CommentButton;
  41. private static Button ShareButton;
  42. private static Button FashionTitleEditButton;
  43. private static Button FashionContentEditButton;
  44. private static Button RateButton;
  45. //EndMark-Used by LabelUtility-Do not remove
  46. private static Button SubmitRateButton;
  47. private static Button ResetRateButton;
  48. private static TweenOutline rateButtonAnim;
  49. private static Button DressroomFashionShowButton;
  50. private static Transform GardenFashionShowButtonParent;
  51. private static Text BuyAllButtonText;
  52. private static Button BuyAllButton;
  53. public static Transform Panel;
  54. private static Transform ChangeDressPanel;
  55. private static Transform DisplayBackground;
  56. private static Transform CuteRateBackground;
  57. private static Transform GraceRateBackground;
  58. private static Transform VividRateBackground;
  59. private static Transform SimpleRateBackground;
  60. private static Transform GloryRateBackground;
  61. private static Transform FashionShowCloseGrid;
  62. private static InputField FashionTitleInputField;
  63. private static InputField FashionContentInputField;
  64. private static CustomSlider CuteSlider;
  65. private static CustomSlider GraceSlider;
  66. private static CustomSlider VividSlider;
  67. private static CustomSlider SimpleSlider;
  68. private static CustomSlider GlorySlider;
  69. private static Transform CuteSliderBg;
  70. private static Transform GraceSliderBg;
  71. private static Transform VividSliderBg;
  72. private static Transform SimpleSliderBg;
  73. private static Transform GlorySliderBg;
  74. public static FashionShowCloseCell closeCell;
  75. //private static bool Praised;
  76. private static bool BelongSelf;
  77. private static bool LeaveToRateMode;
  78. public static bool LeaveToHomePage;
  79. public static Player DisplayPlayer;
  80. private static KV<int, double> TotalCoin;
  81. private static KV<int, double> TotalDiamond;
  82. //private static TweenRenderer PlayerTween;
  83. private static GetFashionShowData FashionShowData;
  84. private static List<int> CloseIDs = new List<int>();
  85. //private static List<string> CloseNames = new List<string>();
  86. private static List<FashionShowCloseItem> CloseItems = new List<FashionShowCloseItem>();
  87. #endregion
  88. public override void RegistReference()
  89. {
  90. CoinText = ResourceManager.Get<Text>(CanvasLabel.Pg_CoinText);
  91. DiamondText = ResourceManager.Get<Text>(CanvasLabel.Pg_DiamondText);
  92. RecommendTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_RecommendTitle);
  93. PraiseText = ResourceManager.Get<Text>(CanvasLabel.Pg_PraiseText);
  94. FashionTitlePlaceHolder = ResourceManager.Get<Text>(CanvasLabel.Pg_FashionTitlePlaceHolder);
  95. FashionContentPlaceHolder = ResourceManager.Get<Text>(CanvasLabel.Pg_FashionContentPlaceHolder);
  96. CuteTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_CuteTitle);
  97. CuteValue = ResourceManager.Get<Text>(CanvasLabel.Pg_CuteValue);
  98. CuteRateText = ResourceManager.Get<Text>(CanvasLabel.Pg_CuteRateText);
  99. GraceTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_GraceTitle);
  100. GraceValue = ResourceManager.Get<Text>(CanvasLabel.Pg_GraceValue);
  101. GraceRateText = ResourceManager.Get<Text>(CanvasLabel.Pg_GraceRateText);
  102. VividTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_VividTitle);
  103. VividValue = ResourceManager.Get<Text>(CanvasLabel.Pg_VividValue);
  104. VividRateText = ResourceManager.Get<Text>(CanvasLabel.Pg_VividRateText);
  105. SimpleTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_SimpleTitle);
  106. SimpleValue = ResourceManager.Get<Text>(CanvasLabel.Pg_SimpleValue);
  107. SimpleRateText = ResourceManager.Get<Text>(CanvasLabel.Pg_SimpleRateText);
  108. GloryTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_GloryTitle);
  109. GloryValue = ResourceManager.Get<Text>(CanvasLabel.Pg_GloryValue);
  110. GloryRateText = ResourceManager.Get<Text>(CanvasLabel.Pg_GloryRateText);
  111. FashionShowClosesTitle = ResourceManager.Get<Text>(CanvasLabel.Pg_FashionShowClosesTitle);
  112. CloseTotalCoinText = ResourceManager.Get<Text>(CanvasLabel.Pg_CloseTotalCoinText);
  113. CloseTotalDiamondText = ResourceManager.Get<Text>(CanvasLabel.Pg_CloseTotalDiamondText);
  114. CuteSlider = ResourceManager.Get<CustomSlider>(CanvasLabel.Pg_CuteSlider);
  115. GraceSlider = ResourceManager.Get<CustomSlider>(CanvasLabel.Pg_GraceSlider);
  116. VividSlider = ResourceManager.Get<CustomSlider>(CanvasLabel.Pg_VividSlider);
  117. SimpleSlider = ResourceManager.Get<CustomSlider>(CanvasLabel.Pg_SimpleSlider);
  118. GlorySlider = ResourceManager.Get<CustomSlider>(CanvasLabel.Pg_GlorySlider);
  119. CuteSliderBg = ResourceManager.Get(CanvasLabel.Pg_CuteBackground);
  120. GraceSliderBg = ResourceManager.Get(CanvasLabel.Pg_GraceBackground);
  121. VividSliderBg = ResourceManager.Get(CanvasLabel.Pg_VividBackground);
  122. SimpleSliderBg = ResourceManager.Get(CanvasLabel.Pg_SimpleBackground);
  123. GlorySliderBg = ResourceManager.Get(CanvasLabel.Pg_GloryBackground);
  124. Return = ResourceManager.Get<Button>(CanvasLabel.Pg_Return);
  125. DisplayEditButton = ResourceManager.Get<Button>(CanvasLabel.Pg_DisplayEditButton);
  126. DeleteButton = ResourceManager.Get<Button>(CanvasLabel.Pg_DeleteButton);
  127. ResetButton = ResourceManager.Get<Button>(CanvasLabel.Pg_ResetButton);
  128. SaveButton = ResourceManager.Get<Button>(CanvasLabel.Pg_SaveButton);
  129. PraiseButton = ResourceManager.Get<Button>(CanvasLabel.Pg_PraiseButton);
  130. CommentButton = ResourceManager.Get<Button>(CanvasLabel.Pg_CommentButton);
  131. ShareButton = ResourceManager.Get<Button>(CanvasLabel.Pg_ShareButton);
  132. FashionTitleEditButton = ResourceManager.Get<Button>(CanvasLabel.Pg_FashionTitleEditButton);
  133. FashionContentEditButton = ResourceManager.Get<Button>(CanvasLabel.Pg_FashionContentEditButton);
  134. RateButton = ResourceManager.Get<Button>(CanvasLabel.Pg_RateButton);
  135. SubmitRateButton = ResourceManager.Get<Button>(CanvasLabel.Pg_SubmitRateButton);
  136. ResetRateButton = ResourceManager.Get<Button>(CanvasLabel.Pg_ResetRateButton);
  137. DressroomFashionShowButton = ResourceManager.Get<Button>(CanvasLabel.P_FashionShowButton);
  138. GardenFashionShowButtonParent = ResourceManager.Get(CanvasLabel.C_FashionShowButtonParent);
  139. BuyAllButtonText = ResourceManager.Get<Text>(CanvasLabel.Pg_BuyAllButtonText);
  140. BuyAllButton= ResourceManager.Get<Button>(CanvasLabel.Pg_BuyAllButton);
  141. Panel = ResourceManager.Get(CanvasLabel.Pg_FashionShowEditPanel);
  142. ChangeDressPanel = ResourceManager.Get(CanvasLabel.P_ChangeDressPanel);
  143. DisplayBackground = ResourceManager.Get(CanvasLabel.Pg_DisplayBackground);
  144. CuteRateBackground = ResourceManager.Get(CanvasLabel.Pg_CuteRateBackground);
  145. GraceRateBackground = ResourceManager.Get(CanvasLabel.Pg_GraceRateBackground);
  146. VividRateBackground = ResourceManager.Get(CanvasLabel.Pg_VividRateBackground);
  147. SimpleRateBackground = ResourceManager.Get(CanvasLabel.Pg_SimpleRateBackground);
  148. GloryRateBackground = ResourceManager.Get(CanvasLabel.Pg_GloryRateBackground);
  149. FashionShowCloseGrid = ResourceManager.Get(CanvasLabel.Pg_FashionShowCloseGrid);
  150. FashionTitleInputField = ResourceManager.Get<InputField>(CanvasLabel.Pg_FashionTitleBackground);
  151. FashionContentInputField = ResourceManager.Get<InputField>(CanvasLabel.Pg_FashionContentBackground);
  152. LanguageManager.Add(FashionTitlePlaceHolder, new MulLanStr(LanguageLabel.UI__Pi_TitleTip));
  153. LanguageManager.Add(FashionContentPlaceHolder, new MulLanStr(LanguageLabel.UI__Pi_ContentTip));
  154. LanguageManager.Add(BuyAllButtonText, new MulLanStr(LanguageLabel.UI__Pg_BuyAll));
  155. LanguageManager.Add(CuteTitle, new MulLanStr(LanguageLabel.UI__Pg_Cute));
  156. LanguageManager.Add(GraceTitle, new MulLanStr(LanguageLabel.UI__Pg_Grace));
  157. LanguageManager.Add(SimpleTitle, new MulLanStr(LanguageLabel.UI__Pg_Simple));
  158. LanguageManager.Add(VividTitle, new MulLanStr(LanguageLabel.UI__Pg_Vivid));
  159. LanguageManager.Add(GloryTitle, new MulLanStr(LanguageLabel.UI__Pg_Glory));
  160. LanguageManager.Add(FashionShowClosesTitle, new MulLanStr(LanguageLabel.UI__Pg_CloseGridTitle));
  161. Panel.CreateTweenVec2D(ResourceManager.Get(CanvasLabel.Pg_FashionShowEditPanelPosition).position, 0.5f, false, false, true, Curve.EaseOutQuad);
  162. ChangeDressPanel.CreateTweenCG(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
  163. CuteSlider.onValueChanged.AddListener(OnCuteSliderValueChange);
  164. CuteSlider.onPointerDown += OnCuteSliderSelect;
  165. CuteSlider.onPointerUp += OnCuteSliderDeselect;
  166. GraceSlider.onValueChanged.AddListener(OnGraceSliderValueChange);
  167. GraceSlider.onPointerDown += OnGraceSliderSelect;
  168. GraceSlider.onPointerUp += OnGraceSliderDeselect;
  169. SimpleSlider.onValueChanged.AddListener(OnSimpleSliderValueChange);
  170. SimpleSlider.onPointerDown += OnSimpleSliderSelect;
  171. SimpleSlider.onPointerUp += OnSimpleSliderDeselect;
  172. GlorySlider.onValueChanged.AddListener(OnGlorySliderValueChange);
  173. GlorySlider.onPointerDown += OnGlorySliderSelect;
  174. GlorySlider.onPointerUp += OnGlorySliderDeselect;
  175. VividSlider.onValueChanged.AddListener(OnVividSliderValueChange);
  176. VividSlider.onPointerDown += OnVividSliderSelect;
  177. VividSlider.onPointerUp += OnVividSliderDeselect;
  178. Return.onClick.AddListener(OnReturnButtonClick);
  179. CommentButton.onClick.AddListener(OnCommentButtonClick);
  180. PraiseButton.onClick.AddListener(OnPraiseButtonClick);
  181. ShareButton.onClick.AddListener(OnShareButtonClick);
  182. DisplayEditButton.onClick.AddListener(OnDisplayEditButtonClick);
  183. RateButton.onClick.AddListener(OnRateButtonClick);
  184. SubmitRateButton.onClick.AddListener(OnSubmitRateClick);
  185. ResetRateButton.onClick.AddListener(OnResetRateClick);
  186. SaveButton.onClick.AddListener(OnSaveButtonClick);
  187. ResetButton.onClick.AddListener(OnResetButtonClick);
  188. DeleteButton.onClick.AddListener(OnDeleteButtonClick);
  189. BuyAllButton.onClick.AddListener(OnBuyAllButtonClick);
  190. DressroomFashionShowButton.onClick.AddListener(OnDressroomFashionShowButtonClick);
  191. Manager.OnLevelChange += OnLevelChange;
  192. Manager.OnCoinChange += amt => { CoinText.text = ResourceManager.Get<Text>(CanvasLabel.F_CoinLab).text; };
  193. Manager.OnDiamondChange += amt => { DiamondText.text = ResourceManager.Get<Text>(CanvasLabel.F_DiamondLab).text; };
  194. Outline outline = RateButton.GetComponent<Outline>();
  195. Color originColor = outline.effectColor;
  196. Color destColor = outline.effectColor;
  197. destColor.a = 0;
  198. rateButtonAnim = new TweenOutline(outline, originColor, destColor, 0.5f, true, true, Curve.EaseOutQuad);
  199. rateButtonAnim.OnForwardFinish += () => rateButtonAnim.StartBackward();
  200. rateButtonAnim.OnBackwardFinish += () => rateButtonAnim.StartForward();
  201. rateButtonAnim.StartForward();
  202. rateButtonAnim.Pause();
  203. }
  204. public static void ShowEditPanel(GetFashionShowData data)
  205. {
  206. BelongSelf = true;
  207. FashionShowData = data;
  208. CloseIDs = data.GetCloseIds();
  209. //CloseNames = Player.DressIDToDressName(data.CloseIDs); ;
  210. TransitPanel();
  211. ShowPanel();
  212. EnterEditMode();
  213. }
  214. public static void ShowRatePanel(bool belongSelf, GetFashionShowData data)
  215. {
  216. BelongSelf = belongSelf;
  217. FashionShowData = data;
  218. CloseIDs = data.GetCloseIds();
  219. //CloseNames = Player.DressIDToDressName(data.CloseIDs); ;
  220. Panel.TweenForVec();
  221. ShowPanel();
  222. EnterRateMode();
  223. }
  224. private static void ShowPanel()
  225. {
  226. DisplayPlayer = PlayerManager.Instance.GetRawPlayer();
  227. DisplayPlayer.transform.SetParent(DisplayBackground);
  228. DisplayPlayer.transform.SetSiblingIndex(1);
  229. DisplayPlayer.transform.localPosition = Vector3.zero;
  230. foreach (var closeID in CloseIDs)
  231. {
  232. CloseItem closeItem = PlayerManager.CloseItemDictionary[closeID];
  233. closeItem.ChangeDress(DisplayPlayer, false);
  234. }
  235. DelayCall.Call(1, () => { DisplayPlayer.DisplayInUI(37.5f, true);});
  236. //DelayCall.Call(0.5f, () => { DisplayPlayer.ResetDepth(); });
  237. float cuteRate = FashionShowData.GetCuteRate();
  238. float gloryRate = FashionShowData.GetGloryRate();
  239. float graceRate = FashionShowData.GetGraceRate();
  240. float simpleRate = FashionShowData.GetSimpleRate();
  241. float vividRate = FashionShowData.GetVividRate();
  242. CuteSlider.value = cuteRate == 0 ? 1 : cuteRate;
  243. GlorySlider.value = cuteRate == 0 ? 1 : gloryRate;
  244. GraceSlider.value = cuteRate == 0 ? 1 : graceRate;
  245. SimpleSlider.value = cuteRate == 0 ? 1 : simpleRate;
  246. VividSlider.value = cuteRate == 0 ? 1 : vividRate;
  247. ShowRateValue();
  248. FashionTitleInputField.text = FashionShowData.title;
  249. FashionContentInputField.text = FashionShowData.content;
  250. RecommendTitle.text = Language.GetStr(LanguageLabel.UI__Pg_RecommendTitle).Replace(TransferLabel.Value, FashionShowData.playerNickName);
  251. HideRateButton();
  252. DisableRatePanel();
  253. for (int i = 0; i < CloseItems.Count; i++)
  254. {
  255. ResourceManager.Save(CloseItems[i].Transform);
  256. }
  257. CloseItems = new List<FashionShowCloseItem>();
  258. foreach (var closeID in CloseIDs)
  259. {
  260. if (PlayerManager.CloseItemDictionary[closeID].Unavailable) continue;
  261. if (PlayerManager.CloseItemDictionary[closeID].Sprites == null) continue;
  262. if (PlayerManager.CloseItemDictionary[closeID].ArmatureName == "Empty") continue;
  263. Transform itemTrans = ResourceManager.Get(ResourceLabel.FashionShowCloseItem, Folder.UI, false, FashionShowCloseGrid, false, ObjType.FashionShowCloseItem);
  264. FashionShowCloseItem item = new FashionShowCloseItem();
  265. item.Init(closeID, itemTrans);
  266. CloseItems.Add(item);
  267. }
  268. }
  269. private static void ShowRateValue()
  270. {
  271. CuteSlider.value = 3;
  272. GlorySlider.value = 3;
  273. GraceSlider.value = 3;
  274. SimpleSlider.value = 3;
  275. VividSlider.value = 3;
  276. CuteValue.text = FashionShowData.cuteScore == 0 ? "--" : FashionShowData.GetCuteRate().ToString("0.0");
  277. GloryValue.text = FashionShowData.gloryScore == 0 ? "--" : FashionShowData.GetGloryRate().ToString("0.0");
  278. GraceValue.text = FashionShowData.graceScore == 0 ? "--" : FashionShowData.GetGraceRate().ToString("0.0");
  279. SimpleValue.text = FashionShowData.simpleScore == 0 ? "--" : FashionShowData.GetSimpleRate().ToString("0.0");
  280. VividValue.text = FashionShowData.vividScore == 0 ? "--" : FashionShowData.GetVividRate().ToString("0.0");
  281. }
  282. private static void TransitPanel()
  283. {
  284. //Renderer renderer = PlayerManager.Player.HeadSlot.UnityTransform.GetComponentInChildren<Renderer>(true);
  285. //PlayerTween = AnimManager.CreateTweenRenderer(renderer, 0, 1, 0.25f, false, true, Curve.EaseOutQuad);
  286. //PlayerTween.UseSharedMaterial = true;
  287. //PlayerTween.StartBackward();
  288. PlayerManager.Player.PlayFadeOutAnim();
  289. ChangeDressPanel.GetTweenCG().AddEventOnetime(EventType.BackwardFinish, () => { Panel.TweenForVec(); });
  290. ChangeDressPanel.TweenBacCG();
  291. }
  292. private static void EnterEditMode()
  293. {
  294. FashionTitleInputField.interactable = true;
  295. FashionContentInputField.interactable = true;
  296. if (FashionShowData.showId == -1)
  297. {
  298. DeleteButton.SetActive(false);
  299. }
  300. else
  301. {
  302. DeleteButton.SetActive(true);
  303. }
  304. SaveButton.SetActive(true);
  305. ResetButton.SetActive(true);
  306. PraiseButton.SetActive(false);
  307. ShareButton.SetActive(false);
  308. CommentButton.SetActive(false);
  309. DisplayEditButton.SetActive(false);
  310. FashionTitleEditButton.SetActive(true);
  311. FashionContentEditButton.SetActive(true);
  312. FashionTitleInputField.SetActive(true);
  313. FashionContentInputField.SetActive(true);
  314. BuyAllButton.SetActive(false);
  315. foreach (var closeItem in CloseItems)
  316. {
  317. closeItem.BoxButton.interactable = false;
  318. closeItem.Text.SetActive(false);
  319. }
  320. UpdateTotalCost(false);
  321. }
  322. private static void EnterRateMode()
  323. {
  324. FashionTitleInputField.interactable = false;
  325. FashionContentInputField.interactable = false;
  326. DeleteButton.SetActive(false);
  327. SaveButton.SetActive(false);
  328. ResetButton.SetActive(false);
  329. PraiseButton.SetActive(true);
  330. RefreshPraiseButton();
  331. ShareButton.SetActive(true);
  332. CommentButton.SetActive(true);
  333. DisplayEditButton.SetActive(BelongSelf);
  334. FashionTitleEditButton.SetActive(false);
  335. FashionContentEditButton.SetActive(false);
  336. FashionTitleInputField.SetActive(false);
  337. FashionContentInputField.SetActive(false);
  338. if (FashionShowData.rated == false && FashionShowData.playerId != HttpManager.GetPlayerId())
  339. {
  340. ShowRateButton();
  341. }
  342. bool haveUnboughtClose = false;
  343. foreach (var closeItem in CloseItems)
  344. {
  345. if (closeItem.CloseItem.IsBought)
  346. {
  347. closeItem.Text.SetActive(true);
  348. }
  349. else
  350. {
  351. closeItem.Text.SetActive(false);
  352. closeItem.BoxButton.interactable = true;
  353. haveUnboughtClose = true;
  354. }
  355. }
  356. BuyAllButton.SetActive(haveUnboughtClose);
  357. UpdateTotalCost(true);
  358. }
  359. public static void HidePanel()
  360. {
  361. if (LeaveToRateMode)
  362. {
  363. EnterRateMode();
  364. LeaveToRateMode = false;
  365. }
  366. else if (LeaveToHomePage)
  367. {
  368. DisplayPlayer.DisplayInScene();
  369. ResourceManager.Save(DisplayPlayer);
  370. Panel.GetTweenVec().AddEventOnetime(EventType.BackwardFinish, () => { FashionShowHomePage.ShowSidePanel(); });
  371. Panel.TweenBacVec();
  372. LeaveToHomePage = false;
  373. }
  374. else
  375. {
  376. DestroyImmediate(DisplayPlayer.gameObject);
  377. //DisplayPlayer.DisplayInScene();
  378. //ResourceManager.Save(DisplayPlayer);
  379. //if (PlayerTween != null)
  380. //{
  381. // PlayerTween.StartForward();
  382. //}
  383. PlayerManager.Player.PlayFadeInAnim();
  384. Panel.GetTweenVec().AddEventOnetime(EventType.BackwardFinish, () => { ChangeDressPanel.TweenForCG(); });
  385. Panel.TweenBacVec();
  386. }
  387. }
  388. public static void UpdateTotalCost(bool excludeBought)
  389. {
  390. List<KV<Current, KV<int, double>>> costKvs = CloseItem.GetTotalBuyCost(excludeBought, CloseIDs);
  391. foreach (var costKv in costKvs)
  392. {
  393. if (costKv.Key == Current.Coin) TotalCoin = costKv.Value;
  394. if (costKv.Key == Current.Diamond) TotalDiamond = costKv.Value;
  395. }
  396. CloseTotalCoinText.text = Auxiliary.ShrinkBigNumberStr(TotalCoin.Value);
  397. CloseTotalDiamondText.text = Auxiliary.ShrinkBigNumberStr(TotalDiamond.Value);
  398. }
  399. private static void OnReturnButtonClick()
  400. {
  401. AudioManager.PlayClip(ResourceLabel.BtnClip);
  402. HidePanel();
  403. }
  404. private static void OnPraiseButtonClick()
  405. {
  406. AudioManager.PlayClip(ResourceLabel.BtnClip);
  407. FashionShowData.praised = !FashionShowData.praised;
  408. if (FashionShowData.praised)
  409. {
  410. FashionShowData.praiseCnt++;
  411. }
  412. else
  413. {
  414. FashionShowData.praiseCnt--;
  415. }
  416. RefreshPraiseButton();
  417. closeCell.RefreshPraiseButton();
  418. PraiseShowHttp.Praise(HttpManager.GetPlayerId(), FashionShowData.showId, null, null);
  419. }
  420. private static void RefreshPraiseButton()
  421. {
  422. if (FashionShowData.praised)
  423. {
  424. PraiseButton.image.color = Lib.Pink;
  425. PraiseText.color = Color.white;
  426. }
  427. else
  428. {
  429. PraiseButton.image.color = Color.white;
  430. PraiseText.color = Lib.PraiseTextBlue;
  431. }
  432. PraiseText.text = FashionShowData.praiseCnt.ToString();
  433. }
  434. private static void OnCommentButtonClick()
  435. {
  436. AudioManager.PlayClip(ResourceLabel.BtnClip);
  437. FashionShowCommentPanel.ShowPanel(FashionShowData);
  438. }
  439. private static void OnShareButtonClick()
  440. {
  441. AudioManager.PlayClip(ResourceLabel.BtnClip);
  442. }
  443. private static void OnDisplayEditButtonClick()
  444. {
  445. AudioManager.PlayClip(ResourceLabel.BtnClip);
  446. LeaveToRateMode = true;
  447. EnterEditMode();
  448. }
  449. private static void OnSaveButtonClick()
  450. {
  451. AudioManager.PlayClip(ResourceLabel.BtnClip);
  452. if (string.IsNullOrEmpty(FashionTitleInputField.text))
  453. {
  454. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_EmptyTitle));
  455. return;
  456. }
  457. if (string.IsNullOrEmpty(FashionContentInputField.text))
  458. {
  459. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_EmptyContent));
  460. return;
  461. }
  462. if (StringFilter.ContainSensitiveWord(FashionTitleInputField.text))
  463. {
  464. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_BadTitle));
  465. return;
  466. }
  467. if (StringFilter.ContainSensitiveWord(FashionContentInputField.text))
  468. {
  469. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_BadContent));
  470. return;
  471. }
  472. if (FashionShowData.playerNickName == FashionTitleInputField.text && FashionShowData.content == FashionContentInputField.text)
  473. {
  474. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_RepeatData));
  475. return;
  476. }
  477. SaveButton.interactable = false;
  478. GetFashionShowData data = new GetFashionShowData(FashionShowData);
  479. data.title = FashionTitleInputField.text;
  480. data.content = FashionContentInputField.text;
  481. if (data.showId == -1)
  482. {
  483. AddShowHttp.Add(data, OnAddSucceedCallback, OnAddFailedCallback);
  484. }
  485. else
  486. {
  487. ModifyShowHttp.Modify(data, OnModifySucceedCallback, OnModifyFailedCallback);
  488. }
  489. }
  490. private static void OnAddFailedCallback()
  491. {
  492. SaveButton.interactable = true;
  493. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_SaveFailed));
  494. }
  495. private static void OnAddSucceedCallback(object obj)
  496. {
  497. GetFashionShowData fashionShowData = (GetFashionShowData) obj;
  498. FashionShowData.showId = fashionShowData.showId;
  499. FashionShowData.title = fashionShowData.title;
  500. FashionShowData.content = fashionShowData.content;
  501. SaveButton.interactable = true;
  502. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_SaveSucceed));
  503. DeleteButton.SetActive(true);
  504. lastCreateDateTime = DateTime.Now;
  505. }
  506. private static void OnModifyFailedCallback()
  507. {
  508. SaveButton.interactable = true;
  509. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_SaveFailed));
  510. }
  511. private static void OnModifySucceedCallback(object obj)
  512. {
  513. GetFashionShowData fashionShowData = (GetFashionShowData)obj;
  514. FashionShowData.title = fashionShowData.title;
  515. FashionShowData.content = fashionShowData.content;
  516. SaveButton.interactable = true;
  517. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_SaveSucceed));
  518. }
  519. private static void OnResetButtonClick()
  520. {
  521. AudioManager.PlayClip(ResourceLabel.BtnClip);
  522. FashionTitleInputField.text = FashionShowData.title;
  523. FashionContentInputField.text = FashionShowData.content;
  524. }
  525. private static void OnDeleteButtonClick()
  526. {
  527. Bubble.Show
  528. (
  529. null,
  530. Language.GetStr(LanguageLabel.UI__Pg_DeleteWarning),
  531. null,
  532. null,
  533. () =>
  534. {
  535. HidePanel();
  536. HidePanel();
  537. long playerId = HttpManager.GetPlayerId();
  538. DeleteShowHttp.Delete(playerId, FashionShowData.showId, null, null);
  539. //HttpManager.DeleteFashionShowData();
  540. }
  541. );
  542. }
  543. private static void OnBuyAllButtonClick()
  544. {
  545. //Debug.Log(TotalCoin.Value);
  546. UpdateTotalCost(true);
  547. if (TotalCoin.Value > Manager.Coin)
  548. {
  549. Bubble.Show(null, Language.GetStr(LanguageLabel.Common__ShortCoin));
  550. return;
  551. }
  552. if (TotalDiamond.Value > Manager.Diamond)
  553. {
  554. Bubble.Show(null, Language.GetStr(LanguageLabel.Common__ShortDiamond));
  555. return;
  556. }
  557. ShowBuyTip();
  558. }
  559. private static void ShowBuyTip()
  560. {
  561. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pi_BuyAllTip), null, null,
  562. () =>
  563. {
  564. Manager.Pay("", TotalCoin.Value, Current.Coin, OnBuyAllSucceedCallback, StaticsManager.ItemID.解锁服装, StaticsManager.ConsumeModule.Charge, false, false, null, TotalCoin.Key);
  565. Manager.Pay("", TotalDiamond.Value, Current.Diamond, OnBuyAllSucceedCallback, StaticsManager.ItemID.解锁服装, StaticsManager.ConsumeModule.Charge, false, false, null, TotalDiamond.Key);
  566. }
  567. );
  568. }
  569. private static void OnBuyAllSucceedCallback()
  570. {
  571. bool playAudio = true;
  572. foreach (var closeItem in CloseItems)
  573. {
  574. if (!closeItem.CloseItem.IsBought)
  575. {
  576. closeItem.CloseItem.OnBuySucceed(playAudio);
  577. playAudio = false;
  578. closeItem.Text.SetActive(true);
  579. }
  580. }
  581. }
  582. private static void OnRateButtonClick()
  583. {
  584. HideRateButton();
  585. AudioManager.PlayClip(ResourceLabel.BtnClip);
  586. EnableRatePanel();
  587. }
  588. private static void OnSubmitRateClick()
  589. {
  590. if (IsRateChanged() == false)
  591. {
  592. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_RateDidntChange));
  593. return;
  594. }
  595. SubmitRate();
  596. //ShowRateButton();
  597. AudioManager.PlayClip(ResourceLabel.BtnClip);
  598. DisableRatePanel();
  599. ShowRateValue();
  600. }
  601. private static void SubmitRate()
  602. {
  603. ShowRateData data = new ShowRateData();
  604. data.showId = FashionShowData.showId;
  605. data.playerId = HttpManager.GetPlayerId();
  606. data.cuteRate = (int) CuteSlider.value;
  607. data.vividRate = (int) VividSlider.value;
  608. data.simpleRate = (int) SimpleSlider.value;
  609. data.graceRate = (int) GraceSlider.value;
  610. data.gloryRate = (int) GlorySlider.value;
  611. RateShowHttp.Rate(data, null, null);
  612. FashionShowData.cuteScore += data.cuteRate;
  613. FashionShowData.vividScore += data.vividRate;
  614. FashionShowData.simpleScore += data.simpleRate;
  615. FashionShowData.graceScore += data.graceRate;
  616. FashionShowData.gloryScore += data.gloryRate;
  617. FashionShowData.scoreCnt++;
  618. }
  619. private static bool IsRateChanged()
  620. {
  621. if (CuteValue.text == "--")
  622. return false;
  623. if (VividValue.text == "--")
  624. return false;
  625. if (GloryValue.text == "--")
  626. return false;
  627. if (GraceValue.text == "--")
  628. return false;
  629. if (SimpleValue.text == "--")
  630. return false;
  631. return true;
  632. }
  633. private static void OnResetRateClick()
  634. {
  635. ShowRateButton();
  636. AudioManager.PlayClip(ResourceLabel.BtnClip);
  637. DisableRatePanel();
  638. ShowRateValue();
  639. }
  640. private static void ShowRateButton()
  641. {
  642. RateButton.SetActive(true);
  643. rateButtonAnim.Resume();
  644. }
  645. private static void HideRateButton()
  646. {
  647. RateButton.SetActive(false);
  648. rateButtonAnim.Pause();
  649. }
  650. private static void EnableRatePanel()
  651. {
  652. SubmitRateButton.SetActive(true);
  653. ResetRateButton.SetActive(true);
  654. CuteSliderBg.SetActive(true);
  655. GlorySliderBg.SetActive(true);
  656. GraceSliderBg.SetActive(true);
  657. SimpleSliderBg.SetActive(true);
  658. VividSliderBg.SetActive(true);
  659. CuteSlider.interactable = true;
  660. GlorySlider.interactable = true;
  661. GraceSlider.interactable = true;
  662. SimpleSlider.interactable = true;
  663. VividSlider.interactable = true;
  664. CuteSlider.value = 0;
  665. GlorySlider.value = 0;
  666. SimpleSlider.value = 0;
  667. VividSlider.value = 0;
  668. GraceSlider.value = 0;
  669. CuteValue.text = "--";
  670. GloryValue.text = "--";
  671. GraceValue.text = "--";
  672. SimpleValue.text = "--";
  673. VividValue.text = "--";
  674. }
  675. private static void DisableRatePanel()
  676. {
  677. SubmitRateButton.SetActive(false);
  678. ResetRateButton.SetActive(false);
  679. CuteSliderBg.SetActive(false);
  680. GlorySliderBg.SetActive(false);
  681. GraceSliderBg.SetActive(false);
  682. SimpleSliderBg.SetActive(false);
  683. VividSliderBg.SetActive(false);
  684. CuteSlider.interactable = false;
  685. GlorySlider.interactable = false;
  686. GraceSlider.interactable = false;
  687. SimpleSlider.interactable = false;
  688. VividSlider.interactable = false;
  689. }
  690. private static void OnCuteSliderValueChange(float value)
  691. {
  692. //AudioManager.PlayClip(ResourceLabel.BtnClip);
  693. CuteRateText.text = value.ToString("0");
  694. CuteValue.text = value.ToString("0");
  695. }
  696. private static void OnCuteSliderSelect()
  697. {
  698. CuteRateBackground.SetActive(true);
  699. }
  700. private static void OnCuteSliderDeselect()
  701. {
  702. CuteRateBackground.SetActive(false);
  703. }
  704. private static void OnGraceSliderValueChange(float value)
  705. {
  706. //AudioManager.PlayClip(ResourceLabel.BtnClip);
  707. GraceRateText.text = value.ToString("0");
  708. GraceValue.text = value.ToString("0");
  709. }
  710. private static void OnGraceSliderSelect()
  711. {
  712. GraceRateBackground.SetActive(true);
  713. }
  714. private static void OnGraceSliderDeselect()
  715. {
  716. GraceRateBackground.SetActive(false);
  717. }
  718. private static void OnVividSliderValueChange(float value)
  719. {
  720. //AudioManager.PlayClip(ResourceLabel.BtnClip);
  721. VividRateText.text = value.ToString("0");
  722. VividValue.text = value.ToString("0");
  723. }
  724. private static void OnVividSliderSelect()
  725. {
  726. VividRateBackground.SetActive(true);
  727. }
  728. private static void OnVividSliderDeselect()
  729. {
  730. VividRateBackground.SetActive(false);
  731. }
  732. private static void OnSimpleSliderValueChange(float value)
  733. {
  734. //AudioManager.PlayClip(ResourceLabel.BtnClip);
  735. SimpleRateText.text = value.ToString("0");
  736. SimpleValue.text = value.ToString("0");
  737. }
  738. private static void OnSimpleSliderSelect()
  739. {
  740. SimpleRateBackground.SetActive(true);
  741. }
  742. private static void OnSimpleSliderDeselect()
  743. {
  744. SimpleRateBackground.SetActive(false);
  745. }
  746. private static void OnGlorySliderValueChange(float value)
  747. {
  748. //AudioManager.PlayClip(ResourceLabel.BtnClip);
  749. GloryRateText.text = value.ToString("0");
  750. GloryValue.text = value.ToString("0");
  751. }
  752. private static void OnGlorySliderSelect()
  753. {
  754. GloryRateBackground.SetActive(true);
  755. }
  756. private static void OnGlorySliderDeselect()
  757. {
  758. GloryRateBackground.SetActive(false);
  759. }
  760. private static void OnLevelChange(int level)
  761. {
  762. //GardenFashionShowButtonParent.SetActive(false);
  763. //DressroomFashionShowButton.SetActive(false);
  764. if (level >= TutorialManager.FashionShowTutorialLevel)
  765. {
  766. GardenFashionShowButtonParent.SetActive(true);
  767. DressroomFashionShowButton.SetActive(true);
  768. }
  769. else
  770. {
  771. GardenFashionShowButtonParent.SetActive(false);
  772. DressroomFashionShowButton.SetActive(false);
  773. }
  774. }
  775. private static DateTime lastCreateDateTime;
  776. private static void OnDressroomFashionShowButtonClick()
  777. {
  778. double timeLimit = 300;
  779. double seconds = DateTime.Now.Subtract(lastCreateDateTime).TotalSeconds;
  780. if (seconds < timeLimit)
  781. {
  782. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Pg_CrateTimeLimitWarning).Replace("%NUM%", (timeLimit - seconds).ToString("0")));
  783. return;
  784. }
  785. AudioManager.PlayClip(ResourceLabel.BtnClip);
  786. GetFashionShowData data = new GetFashionShowData();
  787. data.showId = -1;
  788. data.cuteScore = 0;
  789. data.gloryScore = 0;
  790. data.graceScore = 0;
  791. data.simpleScore = 0;
  792. data.vividScore = 0;
  793. data.title = "";
  794. data.content = "";
  795. data.playerId = HttpManager.GetPlayerId();
  796. data.playerNickName = NickNameManager.NickName;
  797. List<int> closeIds = PlayerManager.Player.GetCurrentChangableDressIDs();
  798. data.SetCloseIds(closeIds);
  799. ShowEditPanel(data);
  800. }
  801. }