123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using UI.CommonGame;
- using FairyGUI;
- using UnityEngine;
- using UI.LuckyBox;
- namespace GFGGame
- {
- public class GetSuitItemVIew : BaseWindow
- {
- private UI_GetSuitItemUI _ui;
- private GameObject _scenePrefab;
- private GameObject _sceneObject;
- private GoWrapper _wrapper;
- private GameObject _gameObject1;
- private GoWrapper _wrapper1;
- private DressUpObj _dressUpObj;
- public override void Dispose()
- {
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
- if (_wrapper != null)
- {
- _wrapper.Dispose();
- _wrapper = null;
- }
- if (_dressUpObj != null)
- {
- _dressUpObj.Dispose();
- _dressUpObj = 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;
- _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
- _dressUpObj = new DressUpObj();
- _ui.m_bg.onClick.Add(OnClickBg);
- string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_tz");
- SceneController.AddObjectToView(null, null, _ui.m_holderEffect, resPath, out _gameObject1, out _wrapper1);
- }
- protected override void OnShown()
- {
- base.OnShown();
- GRoot.inst.touchable = true;
- int suitId = (int)viewData;
- UpdateView(suitId);
- }
- protected override void OnHide()
- {
- base.OnHide();
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- if (_wrapper != null)
- {
- _wrapper.wrapTarget = null;
- }
- if (this.viewCom == null || this.viewCom.root == null)
- {
- Timers.inst.CallLater((object param) =>
- {
- GetSuitItemController.TryShow(0);
- });
- }
- TryCompleteGuide();
- }
- private void OnClickBg()
- {
- int suitId = GetSuitItemController.TryShow(0);
- if (suitId > 0)
- {
- UpdateView(suitId);
- }
- else
- {
- Hide();
- }
- }
- private void UpdateItem(int itemdId)
- {
- UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_item);
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(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 UpdateView(int suitId)
- {
- _ui.m_holderEffect.visible = true;
- int count = 0;//套装当前拥有的部件数量
- int totalCount = 1;
- // int suitId = 0;
- DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
- // totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
- if (suitId > 0)
- {
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
- _ui.m_txtName.text = "套装·" + suitCfg.name;
- int targetY = (int)(_ui.m_item.y + _ui.m_item.height + 50);
- }
- _ui.m_probar.max = totalCount;
- _ui.m_probar.value = count;
- // UpdateItem(itemId);
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- _sceneObject = GameObject.Instantiate(_scenePrefab);
- int scale = 70;
- _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
- _dressUpObj.setSceneObj(_sceneObject, false, true, null, false);
- _dressUpObj.PutOnDefaultDressUpData();
- _dressUpObj.PutOnSuitCfg(suitId, false, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
- if (_wrapper == null)
- {
- _wrapper = new GoWrapper(_sceneObject);
- _ui.m_holder.SetNativeObject(_wrapper);
- }
- else
- {
- _wrapper.wrapTarget = _sceneObject;
- }
- }
- }
- }
|