| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- 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_loaCard.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);
- }
- if (GameGlobal.ShowPainting)
- {
- SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitId);
- //_ui.m_loaCard.url = ResPathUtil.GetLiHuiPath(suitCfg.Illustration);
- }
- else
- {
- 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(2f, 1, OnTimerUpDate);
- }
- else
- {
- Debug.LogError($"Failed to load scene object for suit: {suitId}");
- }
- }
- );
- }
- }
- }
- }
|