123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections;
- using UnityEngine;
- using UI.LuckyBox;
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class LuckyBoxCardView : BaseWindow
- {
- private UI_LuckyBoxCardUI _ui;
- private List<ItemData> _rewardList;
- private int _type = 0;//弹窗类型:0可跳过,1:首次获得物品不可跳过,2首次获得物品不可跳过,不弹获得套装界面
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_LuckyBoxUI.PACKAGE_NAME;
- _ui = UI_LuckyBoxCardUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- this.modal = true;
- _ui.m_bg.onTouchBegin.Add(OnClickBg);
- _ui.m_btnPass.onClick.Add(OnClickBtnPass);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _rewardList = new List<ItemData>(((this.viewData as object[])[0] as List<ItemData>));
- _type = (int)(this.viewData as object[])[1];
- _ui.m_btnPass.visible = _type == (int)FirstGetCardViewType.JUMP ? true : false;
- UpdateView();
- }
- private void UpdateView()
- {
- if (_rewardList.Count - 1 < 0) return;
- ItemData itemdata = _rewardList[_rewardList.Count - 1];
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdata.id);
- _ui.m_comCard.m_loaType.url = ResPathUtil.GetCommonGameResPath("hd_sxicon_" + itemCfg.rarity);
- _ui.m_comCard.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
- int mainScore = 0;
- int mainScoreValue = 0;
- ItemDataManager.GetMainScore(itemdata.id, out mainScore, out mainScoreValue);
- _ui.m_comCard.m_loaProperty.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + mainScore);
- _ui.m_comCard.m_txtName.text = itemCfg.name;
- _ui.m_comCard.m_txtDiscribe.text = itemCfg.desc;
- 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 (_rewardList.Count == 0)
- {
- if (_type == (int)FirstGetCardViewType.JUMP)
- {
- ViewManager.Show(ViewName.LUCKY_BOX_BONUS_VIEW, new object[] { (this.viewData as object[])[0] as List<ItemData>, _rewardList });
- }
- else if (_type == (int)FirstGetCardViewType.CANNOT_JUMP)
- {
- int itemId = GetSuitItemController.TryShow(0);
- }
- this.Hide();
- return;
- }
- _ui.m_t_close.Play(() =>
- {
- _ui.m_t_open.Play();
- UpdateView();
- });
- }
- private void OnClickBtnPass()
- {
- ViewManager.Show(ViewName.LUCKY_BOX_BONUS_VIEW, new object[] { (this.viewData as object[])[0], _rewardList });
- this.Hide();
- }
- protected override void OnHide()
- {
- _ui.m_t_close.Stop(true, false);
- _ui.m_t_open.Stop(true, false);
- base.OnHide();
- }
- }
- }
|