123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using UI.CommonGame;
- using FairyGUI;
- using UnityEngine;
- using UI.LuckyBox;
- namespace GFGGame
- {
- public class SuitItemView : BaseWindow
- {
- private UI_SuitItemUI _ui;
- private int suitID;
- private int countSuitId;//当前获得的物品还有多少个相同套装的部件需要展示
- private int count = 0;//套装当前拥有的部件数量
- private int totalCount = 1;
- private EffectUI _effectUI1;
- private EffectUI _effectUI2;
- private EffectUI _effectUI3;
- public override void Dispose()
- {
- EffectUIPool.Recycle(_effectUI1);
- _effectUI1 = null;
- EffectUIPool.Recycle(_effectUI2);
- _effectUI2 = null;
- EffectUIPool.Recycle(_effectUI3);
- _effectUI3 = null;
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_SuitItemUI.PACKAGE_NAME;
- _ui = UI_SuitItemUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
- _ui.m_probar.max = 0;
- _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_topEffect, "ui_LuckyBox", "SJJD_CradUp");
- _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_probarEffect, "ui_LuckyBox", "SJJD_CradUP_once");
- _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_downEffect, "ui_LuckyBox", "SJJD_CradDown");
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_loaBg.touchable = false;
- if (this.viewData != null) {
- suitID = (int)(this.viewData as object[])[0];
- countSuitId = (int)(this.viewData as object[])[1];
- }
- UpdateView();
- Timers.inst.Add(0.5f, 1, OnTimerClick);
- }
- private void UpdateView()
- {
- DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
- count = count - countSuitId;
- if (suitID > 0)
- {
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitID);
- _ui.m_txtName.text = "套装·" + suitCfg.name;
- _ui.m_icon.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
- }
- _ui.m_probar.max = totalCount;
- _ui.m_probar.value = count - 1;
- _ui.m_t_open.Play();
- _ui.m_probar.TweenValue(count, 0.7f);
- }
- private void OnTimerClick(object param)
- {
- _ui.m_loaBg.touchable = true;
- }
- private void OnClickBg()
- {
- if(!GetSuitItemController.isAuto)
- {
- if (count == totalCount)
- {
- ViewManager.Show<GetSuitItemVIew>(suitID);
- }
- this.Hide();
- //EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
- }
- }
- protected override void OnHide()
- {
- _ui.m_probar.max = 0;
- _ui.m_probar.value = 0;
- Timers.inst.Remove(OnTimerClick);
- _ui.m_loaBg.touchable = true;
- }
- }
- }
|