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 (_scenePrefab != null) { GameObject.Destroy(_scenePrefab); _scenePrefab = null; } SceneController.DestroyObjectFromView(_gameObject1); base.Dispose(); } protected override void OnInit() { base.OnInit(); _ui = UI_GetSuitItemUI.Create(); this.viewCom = _ui.target; isfullScreen = true; _scenePrefab = GFGAsset.Load(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); } 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.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; } } 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); } } }