123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- 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<ItemData> _rewardList = new List<ItemData>();
- private List<ItemData> _rewardParamList = new List<ItemData>();
- private List<ItemData> _newRewardList = new List<ItemData>();
- private List<ItemData> _oldRewardList = new List<ItemData>();
- // private List<ItemData> _showRewardList = new List<ItemData>();
- // private int _type = 0;//弹窗类型:0可跳过,1:首次获得物品不可跳过,2首次获得物品不可跳过,不弹获得套装界面
- private EffectUI _effectUI1;
- private EffectUI _effectUI2;
- private EffectUI _effectUI3;
- private EffectUI _effectUI4;
- private EffectUI _effectUI5;
- private EffectUI _effectUI6;
- public override void Dispose()
- {
- EffectUIPool.Recycle(_effectUI1);
- _effectUI1 = null;
- EffectUIPool.Recycle(_effectUI2);
- _effectUI2 = null;
- EffectUIPool.Recycle(_effectUI3);
- _effectUI3 = null;
- EffectUIPool.Recycle(_effectUI4);
- _effectUI4 = null;
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- 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()
- {
- _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_ck", "ui_ck_zs");
- _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
- _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI");
- _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
- }
- protected override void OnShown()
- {
- base.OnShown();
- _rewardParamList.Clear();
- _rewardList.Clear();
- _rewardParamList.AddRange(this.viewData as List<ItemData>);
- _rewardList = this.viewData as List<ItemData>;
- _ui.m_btnPass.visible = false;
- _newRewardList.Clear();
- _oldRewardList.Clear();
- for (int i = 0; i < _rewardList.Count; i++)
- {
- long hasCount = ItemDataManager.GetItemNum(_rewardList[i].id);
- int thisCount = GetThisCount(_rewardList[i].id, _rewardList);
- bool isAddToNew = IsAddToNewRewardList(_rewardList[i].id);
- if (thisCount == hasCount && !isAddToNew)
- {
- _newRewardList.Add(_rewardList[i]);
- }
- else
- {
- _oldRewardList.Add(_rewardList[i]);
- }
- }
- UpdateView();
- }
- private void UpdateView()
- {
- if (_effectUI5 != null)
- {
- EffectUIPool.Recycle(_effectUI5);
- _effectUI5 = null;
- }
- if (_effectUI6 != null)
- {
- EffectUIPool.Recycle(_effectUI6);
- _effectUI6 = null;
- }
- _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);
- switch (itemCfg.rarity)
- {
- case ConstDressRarity.Rarity_TIANYI:
- _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_LuckyBox", "CK_Yellow_01");
- _ui.m_comCard.m_holder.visible = true;
- _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder1, "ui_LuckyBox", "CK_Yellow_01_top");
- _ui.m_comCard.m_holder1.visible = true;
- break;
- case ConstDressRarity.Rarity_DIANCANG:
- _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_LuckyBox", "CK_Purple_02");
- _ui.m_comCard.m_holder.visible = true;
- _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder1, "ui_LuckyBox", "CK_Purple_02_top");
- _ui.m_comCard.m_holder1.visible = true;
- break;
- case ConstDressRarity.Rarity_ZHENXI:
- _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_LuckyBox", "CK_Bule_03");
- _ui.m_comCard.m_holder.visible = true;
- break;
- case ConstDressRarity.Rarity_FANPIN:
- _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_LuckyBox", "CK_grey_04");
- _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<LuckyBoxNewCardView>(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()
- {
- _ui.m_t_close.Play(() =>
- {
- _ui.m_comCard.m_holder.visible = false;
- _ui.m_comCard.m_holder1.visible = false;
- if (_newRewardList.Count == 0 && _oldRewardList.Count == 0)
- {
- this.Hide();
- }
- else {
- _ui.m_t_open.Play();
- UpdateView();
- }
- });
- }
- private int GetThisCount(int itemId, List<ItemData> 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 < _newRewardList.Count; i++)
- {
- if (itemId == _newRewardList[i].id)
- {
- return true;
- }
- }
- return false;
- }
- protected override void OnHide()
- {
- EffectUIPool.Recycle(_effectUI5);
- _effectUI5 = null;
- EffectUIPool.Recycle(_effectUI6);
- _effectUI6 = null;
- _ui.m_t_close.Stop(true, false);
- _ui.m_t_open.Stop(true, false);
- _rewardList.Clear();
- base.OnHide();
- ViewManager.Show<LuckyBoxBonusShowView>(_rewardParamList);
- }
- }
- }
|