using cfg.GfgCfg; using UI.CommonGame; using FairyGUI; using UnityEngine; using UI.LuckyBox; namespace GFGGame { public class GetSuitItemVIew : BaseWindow { private UI_GetSuitItemUI _ui; private EffectUI _effectUI1; private DressUpObjUI _dressUpObjUI; public override void Dispose() { Timers.inst.Remove(OnTimerUpDate); EffectUIPool.Recycle(_effectUI1); _effectUI1 = null; if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); _ui = UI_GetSuitItemUI.Create(); this.viewCom = _ui.target; isfullScreen = true; //_dressUpObjUI = new DressUpObjUI("SceneDressUp", onShowAction); _ui.m_loaBg.onClick.Add(OnClickBg); _ui.m_btnShare.onClick.Add(OnClickShare); EffectUIPool.CreateEffectUI(_ui.m_holderEffect, "ui_ck", "ui_ck_tz", onComplete: (effect) => { if (effect != null) { _effectUI1 = effect; } }); } void onShowAction() { EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT); } protected override void OnShown() { base.OnShown(); GRoot.inst.touchable = true; _ui.m_loaBg.touchable = false; int suitId = (int)viewData; if (suitId == 202025) { _ui.m_icon.x = -600; } else { _ui.m_icon.x = 0; } if (!GetSuitItemController.isAuto) { _ui.m_btnShare.visible = false; } else { _ui.m_btnShare.visible = false; } UpdateView(suitId); Timers.inst.Add(0.5f, 1, OnTimerClick); } protected override void OnHide() { base.OnHide(); if (this.viewCom == null || this.viewCom.root == null) { Timers.inst.CallLater((object param) => { GetSuitItemController.TryShow(0); }); } TryCompleteGuide(); Timers.inst.Remove(OnTimerClick); _ui.m_loaBg.touchable = true; } private void OnTimerClick(object param) { _ui.m_loaBg.touchable = true; } private void OnClickBg() { if (!GetSuitItemController.isAuto) { Hide(); EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE); EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT); } } private void OnClickShare() { ShareDataManager.Instance.CaptureCameraToImage(); } private void UpdateItem(int itemdId) { UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_item); ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemdId); itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg); string itemName = itemCfg.Name; itemUI.m_comIcon.m_txtName.text = itemName; RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemdId, false); itemUI.target.data = itemdId; itemUI.target.onClick.Clear(); itemUI.target.onClick.Add(OnClickItemUI); UI_LuckyBoxBonusItem.ProxyEnd(); } private void OnClickItemUI(EventContext context) { GComponent item = context.sender as GComponent; int itemID = (int)item.data; GoodsItemTipsController.ShowItemTips(itemID); } private void OnTimerUpDate(object param = null) { _dressUpObjUI.UpdateWrapper(_ui.m_holder); } private void UpdateView(int suitId) { _ui.m_holderEffect.visible = true; int count = 0; // 套装当前拥有的部件数量 int totalCount = 1; _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_zhuxian"); DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount); if (suitId > 0) { SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitId); _ui.m_txtName.text = "套装·" + suitCfg.Name; int targetY = (int)(_ui.m_item.y + _ui.m_item.height + 50); } bool showAction = SuitCfgArray.Instance.CheckSuitHasAction(suitId) && DressUpMenuSuitDataManager.CheckSuitHasActionRes(suitId); if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } _dressUpObjUI = new DressUpObjUI("SceneDressUp", onShowAction); // 使用异步方式重置场景对象 _dressUpObjUI.ResetSceneObjAsync( 115, false, true, null, false, (sceneObj) => { if (sceneObj != null) { // 场景对象加载完成后穿上套装 _dressUpObjUI.dressUpObj.PutOnSuitCfg( suitId, showAction, null, false, false ); Timers.inst.Add(0.1f, 1, OnTimerUpDate); } else { Debug.LogError($"Failed to load scene object for suit: {suitId}"); } } ); } } }