using System.Collections; using System.Collections.Generic; using System.IO; using repeatCallUtility; using UnityEngine; using UnityEngine.UI; public class FashionShowCloseCell { #region Config //public bool Praised; public Text PraiseText; public Image ShadowImg; public Button PraiseButton; public Button ShareButton; public Button DisplayButton; public Player Player; public GetFashionShowData FashionShowData; #endregion public FashionShowCloseCell(Text praiseText, Image shadowImg, Button praiseButton, Button shareButton, Button displayButton) { PraiseText = praiseText; ShadowImg = shadowImg; 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); } } public static Player photoShopPlayer; public string path = Application.persistentDataPath + Path.DirectorySeparatorChar + "FashionShow.png"; private void OnShareButtonClick() { if (photoShopPlayer != null) { Object.Destroy(photoShopPlayer.gameObject); } AudioManager.PlayClip(ResourceLabel.BtnClip); ResourceManager.Get("PhotoShop").SetParent(null); ResourceManager.Get("PhotoShop").SetActive(true); photoShopPlayer = PlayerManager.Instance.GetRawPlayer(); PlayerManager.BuildPlayer(Player.GetAllDressNames(), photoShopPlayer); photoShopPlayer.SetParent(ResourceManager.Get("PhotoShopPlayer")); photoShopPlayer.transform.localPosition = new Vector3(0, 0, -1); photoShopPlayer.ResetDepth(); Camera camera = ResourceManager.Get("PhotoShopCamera"); PhotoShopCamera shopCamera = camera.GetComponent(); if (shopCamera == null) { shopCamera = camera.AddComponent(); } shopCamera.onRenderFinish = null; shopCamera.onRenderFinish += ScreenShot; } private void ScreenShot(Texture2D tex) { float left = 0.02f; float right = 0.4f; float top = 0.8f; float bottom = 0.05f; int width = (int)(tex.width * (right - left)); int height = (int)(tex.height * (top - bottom)); int leftOffset = (int)(tex.width * left); int bottomOffset = (int)(tex.height * bottom); Texture2D newTex = new Texture2D(width, height); newTex.SetPixels(tex.GetPixels(leftOffset, bottomOffset, width, height)); newTex.Apply(); File.WriteAllBytes(path, newTex.EncodeToJPG()); ResourceManager.Get("PhotoShop").SetActive(false); IAPManager.Share(path, Language.GetStr(LanguageLabel.Common__ScreenShotShareContent)); } 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); } public void RefreshPraiseButton() { if (FashionShowData.praised) { PraiseButton.image.color = Lib.Pink; PraiseText.color = Color.white; } else { PraiseButton.image.color = Color.white; PraiseText.color = Lib.PraiseTextBlue; } PraiseText.text = FashionShowData.praiseCnt.ToString(); } private void OnDisplayButtonClick() { FashionShowEditPage.closeCell = this; 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 Image A_Img; private Image B_Img; private Image C_Img; private Image D_Img; private Image E_Img; 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 RectTransform rectTrans { get { if (m_rectTrans == null) { m_rectTrans = GetComponent(); } return m_rectTrans; } } public RectTransform m_rectTrans; public Canvas canvas { get { if (m_canvas == null) { m_canvas = ResourceManager.Get(CanvasLabel.Canvas); RectTransform trans = m_canvas.GetComponent(); canvasMin = trans.position.x + trans.rect.xMin* m_canvas.scaleFactor; canvasMax = trans.position.x + trans.rect.xMax* m_canvas.scaleFactor; } return m_canvas; } } public Canvas m_canvas; public float canvasMin; public float canvasMax; public List Cells = new List(); public List UnusedCells = new List(); #endregion public override bool Init() { if (base.Init()) return true; //RegistStartMark-Used by LabelUtility-Do not remove Dictionary childDictionary = new Dictionary(); Auxiliary.CompileDic(transform, childDictionary); A_PraiseText = childDictionary[FashionShowCloseBoxLabel.A_PraiseText].GetComponent(); B_PraiseText = childDictionary[FashionShowCloseBoxLabel.B_PraiseText].GetComponent(); C_PraiseText = childDictionary[FashionShowCloseBoxLabel.C_PraiseText].GetComponent(); D_PraiseText = childDictionary[FashionShowCloseBoxLabel.D_PraiseText].GetComponent(); E_PraiseText = childDictionary[FashionShowCloseBoxLabel.E_PraiseText].GetComponent(); A_Img = childDictionary["A_Image"].GetComponent(); B_Img = childDictionary["A_Image"].GetComponent(); C_Img = childDictionary["A_Image"].GetComponent(); D_Img = childDictionary["A_Image"].GetComponent(); E_Img = childDictionary["A_Image"].GetComponent(); A_DisplayBackground = childDictionary[FashionShowCloseBoxLabel.A_DisplayBackground].GetComponent