123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- using UI.CommonGame;
- using FairyGUI;
- using UnityEngine;
- using static UnityEditor.Progress;
- 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 int guideId = 0;//0:没有引导 1:首次获得套装2:首次获得套装部件
- public override void Dispose()
- {
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
- if (_wrapper != null)
- {
- _wrapper.Dispose();
- _wrapper = 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"));
- _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;
- guideId = 0;
- UpdateView(suitId);
- Timers.inst.AddUpdate(CheckGuide);
- }
- 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();
- Timers.inst.Remove(CheckGuide);
- }
- private void OnClickBg()
- {
- int suitId = GetSuitItemController.TryShow(0);
- if (suitId > 0)
- {
- UpdateView(suitId);
- }
- else
- {
- Hide();
- }
- }
- private void UpdateItem(int itemdId)
- {
- UI_LuckyBoxBonusItem itemUI = _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);
- }
- 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;
- int[] itemIds = null;
- DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
- // totalCount = SuitCfgManager.Instance.GetTotalCountOfOneSuit(suitId);
- itemIds = SuitCfgManager.Instance.GetSuitItems(suitId);
- if (suitId > 0)
- {
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
- _ui.m_txtName.text = "套装·" + suitCfg.name;
- int targetY = (int)(_ui.m_item.target.y + _ui.m_item.target.height + 50);
- if (count == totalCount)
- {
- guideId = 1;
- }
- else
- {
- guideId = 2;
- }
- }
- _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);
- SceneController.UpdateRole(itemIds, _sceneObject);
- if (_wrapper == null)
- {
- _wrapper = new GoWrapper(_sceneObject);
- _ui.m_holder.SetNativeObject(_wrapper);
- }
- else
- {
- _wrapper.wrapTarget = _sceneObject;
- }
- }
- private void CheckGuide(object param)
- {
- if (GuideDataManager.IsGuideFinish(ConstGuideId.GET_SUIT_ITEM_FULL) <= 0
- || GuideDataManager.IsGuideFinish(ConstGuideId.GET_SUIT_ITEM_FIRST) <= 0)
- {
- UpdateToCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- if (guideId == 1) GuideController.TryGuide(null, ConstGuideId.GET_SUIT_ITEM_FULL, 1, "恭喜你,集齐了第一套套装,快去换装界面穿上试试吧!点击空白区域继续", -1, true, (int)(this.viewCom.height - 150));
- if (guideId == 2) GuideController.TryGuide(null, ConstGuideId.GET_SUIT_ITEM_FIRST, 1, "恭喜你,获得了一件套装配件,集齐套装有惊喜哦!点击空白区域继续", -1, true, (int)(this.viewCom.height - 150));
- }
- protected override void TryCompleteGuide()
- {
- GuideCfg cfg;
- cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.GET_SUIT_ITEM_FULL);
- GuideController.TryCompleteGuideIndex(cfg.id, 1);
- GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_FULL, 1);
- cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.GET_SUIT_ITEM_FIRST);
- GuideController.TryCompleteGuideIndex(cfg.id, 1);
- GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_FIRST, 1);
- }
- }
- }
|