123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using UI.CommonGame;
- using FairyGUI;
- using UnityEngine;
- namespace GFGGame
- {
- public class GetSuitItemVIew : BaseWindow
- {
- private UI_GetSuitItemUI _ui;
- private GameObject _scenePrefab;
- private GameObject _sceneObject;
- private GoWrapper _wrapper;
- public override void Dispose()
- {
- if (_scenePrefab != null)
- {
- GameObject.Destroy(_scenePrefab);
- _scenePrefab = 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);
- }
- protected override void OnShown()
- {
- base.OnShown();
- int itemId = (int)viewData;
- UpdateView(itemId);
- }
- protected override void OnHide()
- {
- base.OnHide();
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- if (_wrapper != null)
- {
- _wrapper.wrapTarget = null;
- }
- Timers.inst.CallLater((object param) =>
- {
- GetSuitItemController.TryShow(0);
- });
- GuideController.HideGuide();
- GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST);
- GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FULL);
- }
- private void OnClickBg()
- {
- int itemId = GetSuitItemController.TryShow(0);
- if (itemId > 0)
- {
- GuideController.HideGuide();
- GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST);
- GuideController.TryCompleteGuide(ConstGuideId.GET_SUIT_ITEM_VIEW_FULL);
- UpdateView(itemId);
- }
- else
- {
- Hide();
- }
- }
- private void UpdateItem(int itemdId)
- {
- UI_LuckyBoxBonusItem itemUI = _ui.m_item;
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdId);
- itemUI.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
- string itemName = itemCfg.name;
- itemUI.m_txtName.text = itemName;
- RarityIconController.UpdateRarityIcon(itemUI.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 itemId)
- {
- int count = 0;
- int totalCount = 1;
- int suitId = 0;
- int[] itemIds = null;
- DressUpMenuSuitDataManager.GetSuitProgressByItemId(itemId, out suitId, out count);
- 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)
- {
- GuideController.TryGuideByGuideId(null, ConstGuideId.GET_SUIT_ITEM_VIEW_FULL, 1, false, "恭喜你,集齐了第一套套装,快去换装界面穿上试试吧!点击空白区域继续", targetY);
- }
- else
- {
- GuideController.TryGuideByGuideId(null, ConstGuideId.GET_SUIT_ITEM_VIEW_FIRST, 1, false, "恭喜你,获得了一件套装配件,集齐套装有惊喜哦!点击空白区域继续", targetY);
- }
- }
- _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;
- }
- }
- }
- }
|