123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- 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 FashionShowData 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 scale, FashionShowData data)
- {
- FashionShowData = data;
- Praised = data.Praised;
- if (Praised)
- {
- PraiseButton.image.color = Lib.Pink;
- }
- else
- {
- PraiseButton.image.color = Color.white;
- }
- PraiseText.text = data.PraisedAmount.ToString();
- DisplayButton.transform.SetActive(true);
- List<string> closeNames = Player.DressIDToDressName(data.CloseIDs);
- Player = PlayerManager.Instance.GetRawPlayer();
- Player.transform.SetParent(DisplayButton.transform);
- Player.transform.localPosition = Vector3.zero;
- Player.ChangeClose(BodyPart.Head, closeNames[0], false);
- Player.ChangeClose(BodyPart.Dress, closeNames[1], false);
- Player.ChangeClose(BodyPart.Shoe, closeNames[2], false);
- Player.ChangeClose(BodyPart.Headwear, closeNames[3], false);
- Player.ChangeClose(BodyPart.Top, closeNames[4], false);
- Player.ChangeClose(BodyPart.Eye, closeNames[5], false);
- Player.ChangeClose(BodyPart.Mouse, closeNames[6], false);
- Player.ChangeClose(BodyPart.Wing, closeNames[7], false);
- DelayCall.Call(1, ()=> { Player.DisplayInUI(scale); Player.ResetDepth(); });
- }
- public void Save()
- {
- DisplayButton.SetActive(false);
- if (Player != null)
- {
- Player.DisplayInScene();
- ResourceManager.Save(Player);
- Player = null;
- }
- }
- private void OnShareButtonClick()
- {
- AudioManager.PlayClip(ResourceLabel.BtnClip);
- }
- private void OnPraiseButtonClick()
- {
- AudioManager.PlayClip(ResourceLabel.BtnClip);
- if (Praised)
- {
- Praised = false;
- PraiseButton.image.color = Color.white;
- PraiseText.text = (int.Parse(PraiseText.text) - 1).ToString();
- HttpManager.UnpraiseFashionShow(null, null);
- }
- else
- {
- Praised = true;
- PraiseButton.image.color = Lib.Pink;
- PraiseText.text = (int.Parse(PraiseText.text) + 1).ToString();
- HttpManager.PraiseFashionShow(null, null);
- }
- }
- private void OnDisplayButtonClick()
- {
- AudioManager.PlayClip(ResourceLabel.BtnClip);
- FashionShowEditPage.ShowEditPanel(FashionShowData);
- }
- }
- 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(FashionShowData data)
- {
- float scale = UnusedCells.Count == 5 ? 50 : 20;
- FashionShowCloseCell cell = UnusedCells.Forward(0, true);
- cell.Init(scale, data);
- }
- public void reset()
- {
- UnusedCells = new List<FashionShowCloseCell>(Cells);
- foreach (var cell in Cells)
- {
- cell.Save();
- }
- }
- }
|