using UI.FieldGuide; using FairyGUI; using UnityEngine; using System.Collections.Generic; using cfg.GfgCfg; using ET; namespace GFGGame { public class SuitShowView : BaseWindow { private UI_SuitShowUI _ui; private int _suitTypeId; private int _suitId; private DressUpObjUI _dressUpObjUI; private bool _actionIsPic; private List _suitIds; private bool touchClick = true; public override void Dispose() { Timers.inst.Remove(OnTimerUpDate); if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_SuitShowUI.PACKAGE_NAME; _ui = UI_SuitShowUI.Create(); this.viewCom = _ui.target; isfullScreen = true; //isReturnView = true; this.clickBlankToClose = false; //_dressUpObjUI = new DressUpObjUI("SceneDressUp"); _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_imgBonusBox.target.onClick.Add(OnClickImgBonusBox); _ui.m_btnChangeAction.visible = false; _ui.m_btnLeft.onClick.Add(OnClickBtnLeft); _ui.m_btnRight.onClick.Add(OnClickBtnRight); } protected override void OnShown() { base.OnShown(); object[] datas = this.viewData as object[]; _suitTypeId = (int)datas[0]; _suitId = (int)datas[1]; List suitIds = datas[2] as List; _ui.m_imgBonusBox.target.visible = datas.Length >= 4 ? (bool)datas[3] : true; _suitIds = new List(); foreach (int suitId in suitIds) { if (DressUpMenuSuitDataManager.CheckHaveSuit(suitId)) { _suitIds.Add(suitId); } } SuitGuideMenuCfg cfg = CommonDataManager.Tables.TblSuitGuideMenuCfg.GetOrDefault(_suitTypeId); if (cfg == null) { SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_suitId); _ui.m_txtSuitName.text = suitCfg.Name; } else { _ui.m_txtTypeName.text = cfg.Name; } _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tjtj_bjbj"); UpdateArrows(); UpdateSuitView(); UpdateSuitBoxStatus(); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus); } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus); } private void OnClickBtnBack() { this.Hide(); } private void OnClickImgBonusBox() { SuitUtil.ShowSuitGuideBonus(_suitId); } private void OnTimerUpDate(object param = null) { touchClick = true; _dressUpObjUI.UpdateWrapper(_ui.m_holder); } private async void UpdateSuitView(bool isPic = true) { _actionIsPic = isPic; SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_suitId); _ui.m_txtSuitName.text = suitCfg.Name; if (GameGlobal.ShowPainting) { touchClick = true; //_ui.m_loaCard.url = ResPathUtil.GetLiHuiPath(suitCfg.Illustration); } else { if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } _dressUpObjUI = new DressUpObjUI("SceneDressUp"); // 使用异步方式重置场景对象 _dressUpObjUI.ResetSceneObjAsync(100, false, true, null, false, (sceneObj) => { if (sceneObj != null) { //_dressUpObjUI.dressUpObj.SetOnSuitPutOnCompleteCallback(() => //{ //_dressUpObjUI.UpdateWrapper(_ui.m_holder); //UpdateSuitBoxStatus(); //}); // 场景对象加载完成后穿上套装 _dressUpObjUI.dressUpObj.PutOnSuitCfg( _suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING }, true, false, false, (needYooAsseetDown) => { if(needYooAsseetDown) Timers.inst.Add(4f, 1, OnTimerUpDate); else Timers.inst.Add(0.3f, 1, OnTimerUpDate); } ); UpdateSuitBoxStatus(); } else { Debug.LogError("Failed to load scene object for suit view"); } }); } } private void UpdateArrows() { int index = _suitIds.IndexOf(_suitId); int count = _suitIds.Count; _ui.m_btnRight.visible = (index + 1 < count); _ui.m_btnLeft.visible = (index - 1 >= 0); } private void OnClickBtnLeft() { if (!touchClick) return; touchClick = false; int index = _suitIds.IndexOf(_suitId); int targetIndex = index - 1; if (targetIndex >= 0) { _suitId = _suitIds[targetIndex]; UpdateArrows(); UpdateSuitView(); } UpdateSuitBoxStatus(); } private void OnClickBtnRight() { if (!touchClick) return; touchClick = false; int index = _suitIds.IndexOf(_suitId); int targetIndex = index + 1; if (targetIndex < _suitIds.Count) { _suitId = _suitIds[targetIndex]; UpdateArrows(); UpdateSuitView(); } UpdateSuitBoxStatus(); } private void UpdateSuitBoxStatus(EventContext eventContext = null) { if (eventContext == null || _suitId == (int)eventContext.data) { int status = DressUpMenuSuitDataManager.GetSuitGuideBonusStatus(_suitId); RedDotController.Instance.SetComRedDot(_ui.m_imgBonusBox.target, false); RedDotController.Instance.SetComRedDot(_ui.m_imgBonusBox.target, status == ConstBonusStatus.CAN_GET); if (status == ConstBonusStatus.CAN_GET) { _ui.m_imgBonusBox.m_c1.selectedIndex = 1; } else { _ui.m_imgBonusBox.m_c1.selectedIndex = 0; } } } } }