using System.Collections; using UnityEngine; using UI.LuckyBox; using System.Collections.Generic; using FairyGUI; using System.Linq; namespace GFGGame { public class LuckyBoxNewDressView : BaseWindow { private UI_LuckyBoxNewDressUI _ui; private List _rewardList = new List(); private List _rewardParamList = new List(); private List _newRewardList = new List(); private List _oldRewardList = new List(); // private List _showRewardList = new List(); // private int _type = 0;//弹窗类型:0可跳过,1:首次获得物品不可跳过,2首次获得物品不可跳过,不弹获得套装界面 private GameObject gameObject; private GoWrapper wrapper; private GameObject gameObject1; private GoWrapper wrapper1; private GameObject gameObject2; private GoWrapper wrapper2; private GameObject _gameObject0; private GameObject _gameObject1; private GameObject _gameObject2; private GoWrapper _wrapper0; private GoWrapper _wrapper1; private GoWrapper _wrapper2; public override void Dispose() { base.Dispose(); SceneController.DestroyObjectFromView(gameObject, wrapper); SceneController.DestroyObjectFromView(gameObject1, wrapper1); SceneController.DestroyObjectFromView(gameObject2, wrapper2); SceneController.DestroyObjectFromView(_gameObject0, _wrapper0); SceneController.DestroyObjectFromView(_gameObject1, _wrapper1); SceneController.DestroyObjectFromView(_gameObject2, _wrapper2); if (_ui != null) { _ui.Dispose(); _ui = null; } } protected override void OnInit() { base.OnInit(); packageName = UI_LuckyBoxNewDressUI.PACKAGE_NAME; _ui = UI_LuckyBoxNewDressUI.Create(); this.viewCom = _ui.target; isfullScreen = true; this.modal = true; _ui.m_loaBg.onTouchBegin.Add(OnClickBg); _ui.m_btnPass.onClick.Add(Hide); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg"); UpdateEffect(); } private void UpdateEffect() { string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_zs"); SceneController.AddObjectToView(gameObject, null, _ui.m_comCard.m_holder, resPath, out gameObject, out wrapper); string resPath0 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "bg_liuxing"); SceneController.AddObjectToView(null, null, _ui.m_holder_star, resPath0, out _gameObject0, out _wrapper0); string resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_UI"); SceneController.AddObjectToView(null, null, _ui.m_holder_bg, resPath1, out _gameObject1, out _wrapper1); string resPath2 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "bg_cloud"); SceneController.AddObjectToView(null, null, _ui.m_holder_cloud, resPath2, out _gameObject2, out _wrapper2); } protected override void OnShown() { base.OnShown(); _rewardParamList.Clear(); _rewardList.Clear(); _rewardParamList.AddRange(this.viewData as List); _rewardList = this.viewData as List; _ui.m_btnPass.visible = false; _newRewardList.Clear(); _oldRewardList.Clear(); for (int i = 0; i < _rewardList.Count; i++) { if (GetThisCount(_rewardList[i].id, _rewardList) == ItemDataManager.GetItemNum(_rewardList[i].id) && !IsAddToNewRewardList(_rewardList[i].id)) { _newRewardList.Add(_rewardList[i]); } else { _oldRewardList.Add(_rewardList[i]); } } UpdateView(); } private void UpdateView() { _ui.m_btnPass.visible = _newRewardList.Count <= 1; _rewardList = _newRewardList.Count > 0 ? _newRewardList : _oldRewardList; if (_rewardList.Count - 1 < 0) return; ItemData itemdata = _rewardList[_rewardList.Count - 1]; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdata.id); string resPath = ""; string resPath1 = ""; switch (itemCfg.rarity) { case ConstDressRarity.Rarity_TIANYI: resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Yellow_01"); SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1); _ui.m_comCard.m_holder.visible = true; resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Yellow_01_top"); SceneController.AddObjectToView(gameObject2, wrapper2, _ui.m_comCard.m_holder1, resPath1, out gameObject2, out wrapper2); _ui.m_comCard.m_holder1.visible = true; break; case ConstDressRarity.Rarity_DIANCANG: resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Purple_02"); SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1); _ui.m_comCard.m_holder.visible = true; resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Purple_02_top"); SceneController.AddObjectToView(gameObject2, wrapper2, _ui.m_comCard.m_holder1, resPath1, out gameObject2, out wrapper2); _ui.m_comCard.m_holder1.visible = true; break; case ConstDressRarity.Rarity_ZHENXI: resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Bule_03"); SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1); _ui.m_comCard.m_holder.visible = true; break; case ConstDressRarity.Rarity_FANPIN: resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_grey_04"); SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1); _ui.m_comCard.m_holder.visible = true; break; } _ui.m_comCard.m_loaType.url = ResPathUtil.GetCommonGameResPath("hd_sxicon_" + itemCfg.rarity); _ui.m_comCard.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg); _ui.m_comCard.m_loaProperty.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore); _ui.m_comCard.m_txtName.text = itemCfg.name; _ui.m_comCard.m_txtDiscribe.text = itemCfg.desc; if (itemCfg.itemType == ConstItemType.CARD) { _ui.m_t_open.Play(() => { ViewManager.Show(itemCfg.id); }); } else { _ui.m_t_open.Play(); } if (LuckyBoxDataManager.Instance.FirstRewardList.ContainsKey(_rewardList.Count - 1) == true) { LuckyBoxDataManager.Instance.FirstRewardList.Remove(_rewardList.Count - 1); } _rewardList.RemoveAt(_rewardList.Count - 1); } private void OnClickBg() { if (_newRewardList.Count == 0 && _oldRewardList.Count == 0) { this.Hide(); return; } _ui.m_t_close.Play(() => { _ui.m_comCard.m_holder.visible = false; _ui.m_comCard.m_holder1.visible = false; _ui.m_t_open.Play(); UpdateView(); }); } private int GetThisCount(int itemId, List rewards) { int count = 0; for (int i = 0; i < rewards.Count; i++) { if (rewards[i].id == itemId) { count++; } } return count; } private bool IsAddToNewRewardList(int itemId) { for (int i = 0; i < _rewardList.Count; i++) { if (itemId == _rewardList[i].id) { return true; } } return false; } protected override void OnHide() { _ui.m_t_close.Stop(true, false); _ui.m_t_open.Stop(true, false); _rewardList.Clear(); base.OnHide(); ViewManager.Show(_rewardParamList); } } }