123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class FashionShowCloseCell
- {
- #region Config
- //public bool Praised;
- public Text PraiseText;
- public Button PraiseButton;
- public Button ShareButton;
- public Button DisplayButton;
- public Player Player;
- public GetFashionShowData FashionShowData;
- #endregion
- public FashionShowCloseCell(Text praiseText, Button praiseButton, Button shareButton, Button displayButton)
- {
- PraiseText = praiseText;
- PraiseButton = praiseButton;
- ShareButton = shareButton;
- DisplayButton = displayButton;
- PraiseButton.onClick.AddListener(OnPraiseButtonClick);
- ShareButton.onClick.AddListener(OnShareButtonClick);
- DisplayButton.onClick.AddListener(OnDisplayButtonClick);
- }
- public void Init(float uiScale, Vector3 playerScale, GetFashionShowData data)
- {
- FashionShowData = data;
- RefreshPraiseButton();
- PraiseText.text = data.praiseCnt.ToString();
- DisplayButton.transform.SetActive(true);
- Player = PlayerManager.Instance.GetRawPlayer();
- Player.transform.SetParent(DisplayButton.transform);
- Player.transform.SetSiblingIndex(1);
- Player.transform.localPosition = Vector3.zero;
- Player.transform.localScale = playerScale;
- foreach (var closeID in data.GetCloseIds())
- {
- CloseItem closeItem = PlayerManager.CloseItemDictionary[closeID];
- closeItem.ChangeDress(Player, false);
- }
- DelayCall.Call(1, ()=> { Player.DisplayInUI(uiScale, false); Player.ResetDepth(); });
- }
- public void Save()
- {
- DisplayButton.SetActive(false);
- if (Player != null)
- {
- Object.DestroyImmediate(Player.gameObject);
- //Player.DisplayInScene();
- //ResourceManager.Save(Player, true);
- }
- }
- private void OnShareButtonClick()
- {
- AudioManager.PlayClip(ResourceLabel.BtnClip);
- }
- private void OnPraiseButtonClick()
- {
- AudioManager.PlayClip(ResourceLabel.BtnClip);
- FashionShowData.praised = !FashionShowData.praised;
- if (FashionShowData.praised)
- {
- FashionShowData.praiseCnt++;
- }
- else
- {
- FashionShowData.praiseCnt--;
- }
- RefreshPraiseButton();
- PraiseShowHttp.Praise(HttpManager.GetPlayerId(), FashionShowData.showId, null, null);
- }
- private void RefreshPraiseButton()
- {
- if (FashionShowData.praised)
- {
- PraiseButton.image.color = Lib.Pink;
- }
- else
- {
- PraiseButton.image.color = Color.white;
- }
- PraiseText.text = FashionShowData.praiseCnt.ToString();
- }
- private void OnDisplayButtonClick()
- {
- AudioManager.PlayClip(ResourceLabel.BtnClip);
- TweenRoot tween = FashionShowHomePage.HideSidePanel();
- bool belongSelf = FashionShowData.playerId == long.Parse(HttpManager.SerialNumber);
- tween.AddEventOnetime(EventType.BackwardFinish, ()=> { FashionShowEditPage.ShowRatePanel(belongSelf, FashionShowData); FashionShowEditPage.LeaveToHomePage = true; });
- }
- }
- public class FashionShowCloseBox : VirtualScrollRectItem
- {
- #region Config
- //StartMark-Used by LabelUtility-Do not remove
- private Text A_PraiseText;
- private Text B_PraiseText;
- private Text C_PraiseText;
- private Text D_PraiseText;
- private Text E_PraiseText;
- private Button A_DisplayBackground;
- private Button A_PraiseButton;
- private Button A_ShareButton;
- private Button B_DisplayBackground;
- private Button B_PraiseButton;
- private Button B_ShareButton;
- private Button C_DisplayBackground;
- private Button C_PraiseButton;
- private Button C_ShareButton;
- private Button D_DisplayBackground;
- private Button D_PraiseButton;
- private Button D_ShareButton;
- private Button E_DisplayBackground;
- private Button E_PraiseButton;
- private Button E_ShareButton;
- //EndMark-Used by LabelUtility-Do not remove
- public List<FashionShowCloseCell> Cells = new List<FashionShowCloseCell>();
- public List<FashionShowCloseCell> UnusedCells = new List<FashionShowCloseCell>();
- #endregion
- public override bool Init()
- {
- if (base.Init()) return true;
- //RegistStartMark-Used by LabelUtility-Do not remove
- Dictionary<string, Transform> childDictionary = new Dictionary<string, Transform>();
- Auxiliary.CompileDic(transform, childDictionary);
- A_PraiseText = childDictionary[FashionShowCloseBoxLabel.A_PraiseText].GetComponent<Text>();
- B_PraiseText = childDictionary[FashionShowCloseBoxLabel.B_PraiseText].GetComponent<Text>();
- C_PraiseText = childDictionary[FashionShowCloseBoxLabel.C_PraiseText].GetComponent<Text>();
- D_PraiseText = childDictionary[FashionShowCloseBoxLabel.D_PraiseText].GetComponent<Text>();
- E_PraiseText = childDictionary[FashionShowCloseBoxLabel.E_PraiseText].GetComponent<Text>();
- A_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.A_DisplayBackground].GetComponent<Button>();
- A_PraiseButton = childDictionary[FashionShowCloseBoxLabel.A_PraiseButton].GetComponent<Button>();
- A_ShareButton = childDictionary[FashionShowCloseBoxLabel.A_ShareButton].GetComponent<Button>();
- B_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.B_DisplayBackground].GetComponent<Button>();
- B_PraiseButton = childDictionary[FashionShowCloseBoxLabel.B_PraiseButton].GetComponent<Button>();
- B_ShareButton = childDictionary[FashionShowCloseBoxLabel.B_ShareButton].GetComponent<Button>();
- C_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.C_DisplayBackground].GetComponent<Button>();
- C_PraiseButton = childDictionary[FashionShowCloseBoxLabel.C_PraiseButton].GetComponent<Button>();
- C_ShareButton = childDictionary[FashionShowCloseBoxLabel.C_ShareButton].GetComponent<Button>();
- D_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.D_DisplayBackground].GetComponent<Button>();
- D_PraiseButton = childDictionary[FashionShowCloseBoxLabel.D_PraiseButton].GetComponent<Button>();
- D_ShareButton = childDictionary[FashionShowCloseBoxLabel.D_ShareButton].GetComponent<Button>();
- E_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.E_DisplayBackground].GetComponent<Button>();
- E_PraiseButton = childDictionary[FashionShowCloseBoxLabel.E_PraiseButton].GetComponent<Button>();
- E_ShareButton = childDictionary[FashionShowCloseBoxLabel.E_ShareButton].GetComponent<Button>();
- //RegistEndMark-Used by LabelUtility-Do not remove
- Cells.Add(new FashionShowCloseCell(A_PraiseText, A_PraiseButton, A_ShareButton, A_DisplayBackground));
- Cells.Add(new FashionShowCloseCell(B_PraiseText, B_PraiseButton, B_ShareButton, B_DisplayBackground));
- Cells.Add(new FashionShowCloseCell(C_PraiseText, C_PraiseButton, C_ShareButton, C_DisplayBackground));
- Cells.Add(new FashionShowCloseCell(D_PraiseText, D_PraiseButton, D_ShareButton, D_DisplayBackground));
- Cells.Add(new FashionShowCloseCell(E_PraiseText, E_PraiseButton, E_ShareButton, E_DisplayBackground));
- reset();
- return false;
- }
- public bool HaveUnusedCell()
- {
- return UnusedCells.Count > 0;
- }
- public void SetNextCell(GetFashionShowData data)
- {
- float scale = UnusedCells.Count == 5 ? 37.5f : 17.5f;
- Vector3 playerScale = UnusedCells.Count == 5 ? new Vector3(0.8442904f, 0.8442904f, 0.8442904f) :
- new Vector3(1.763814f, 1.763814f, 1.763814f);
- FashionShowCloseCell cell = UnusedCells.Forward(0, true);
- cell.Init(scale, playerScale, data);
- }
- public void reset()
- {
- UnusedCells = new List<FashionShowCloseCell>(Cells);
- foreach (var cell in Cells)
- {
- cell.Save();
- }
- }
- }
|