|
@@ -1,357 +0,0 @@
|
|
|
-using UnityEngine;
|
|
|
-using FairyGUI;
|
|
|
-using UI.LuckyBox;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Collections;
|
|
|
-
|
|
|
-namespace GFGGame
|
|
|
-{
|
|
|
- public class LuckyBoxBonusView : BaseWindow
|
|
|
- {
|
|
|
- private UI_LuckBoxBonusUI _ui;
|
|
|
- private List<ItemData> itemList;
|
|
|
- private List<ItemData> itemListAni;
|
|
|
- private GComponent _curComItem;
|
|
|
- private int openCount = 0;
|
|
|
- private List<ItemData> newItemList = new List<ItemData>();
|
|
|
- private List<int> newCardList = new List<int>();
|
|
|
- private List<bool> openState = new List<bool>();
|
|
|
- // private int openIndex = 0;
|
|
|
-
|
|
|
- private List<GameObject> _gameobjects = new List<GameObject>();
|
|
|
- private List<GoWrapper> _wrappers = new List<GoWrapper>();
|
|
|
- private GameObject _gameobject;
|
|
|
- private GoWrapper _wrapper;
|
|
|
-
|
|
|
- private string _goBackViewName;
|
|
|
- private object _goBackParams;
|
|
|
- public override void Dispose()
|
|
|
- {
|
|
|
- base.Dispose();
|
|
|
- for (int i = 0; i < _gameobjects.Count; i++)
|
|
|
- {
|
|
|
- SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]);
|
|
|
-
|
|
|
- }
|
|
|
- SceneController.DestroyObjectFromView(_gameobject, _wrapper);
|
|
|
-
|
|
|
- if (_ui != null)
|
|
|
- {
|
|
|
- _ui.Dispose();
|
|
|
- _ui = null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- protected override void OnInit()
|
|
|
- {
|
|
|
- base.OnInit();
|
|
|
- packageName = UI_LuckBoxBonusUI.PACKAGE_NAME;
|
|
|
- _ui = UI_LuckBoxBonusUI.Create();
|
|
|
- this.viewCom = _ui.target;
|
|
|
- isfullScreen = true;
|
|
|
-
|
|
|
- InitAllItem();
|
|
|
- _ui.m_loaBg.onClick.Add(OnClickBg);
|
|
|
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
|
|
|
- _ui.m_btnPass.onClick.Add(OnBtnPassClick);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- protected override void OnShown()
|
|
|
- {
|
|
|
- base.OnShown();
|
|
|
- _goBackViewName = ViewManager.GetGoBackDatas(typeof(LuckyBoxStarView).FullName)[0].ToString();
|
|
|
- _goBackParams = ViewManager.GetGoBackDatas(typeof(LuckyBoxStarView).FullName)[1];
|
|
|
-
|
|
|
- itemList = (viewData as object[])[0] as List<ItemData>;
|
|
|
- itemListAni = new List<ItemData>(itemList.ToArray());
|
|
|
- _ui.m_loaMask.visible = true;
|
|
|
-
|
|
|
- int count = itemList.Count;
|
|
|
- if (count == 10)
|
|
|
- {
|
|
|
- _ui.m_c1.selectedIndex = 1;
|
|
|
- }
|
|
|
- else if (count > 0)
|
|
|
- {
|
|
|
- _ui.m_c1.selectedIndex = 0;
|
|
|
- }
|
|
|
- ShowBonusList();
|
|
|
-
|
|
|
- _ui.m_t0.Play(UpdateView);
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
- protected override void OnHide()
|
|
|
- {
|
|
|
- base.OnHide();
|
|
|
- _ui.m_t1.Play();
|
|
|
- openCount = 0;
|
|
|
- newCardList.Clear();
|
|
|
- newItemList.Clear();
|
|
|
- itemList.Clear();
|
|
|
- for (int i = 0; i < openState.Count; i++)
|
|
|
- {
|
|
|
- openState[i] = false;
|
|
|
- }
|
|
|
- }
|
|
|
- private void InitAllItem()
|
|
|
- {
|
|
|
- string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_fk");
|
|
|
- UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_itemOne.target);
|
|
|
- itemUI.target.onClick.Add(OnClickItem);
|
|
|
- itemUI.m_comIcon.m_icon.onClick.Add(OnClickItemTips);
|
|
|
- SceneController.AddObjectToView(null, null, itemUI.m_holder, resPath, out _gameobject, out _wrapper);
|
|
|
- UI_LuckyBoxBonusItem.ProxyEnd();
|
|
|
-
|
|
|
- for (int i = 0; i < 10; i++)
|
|
|
- {
|
|
|
- GObject itemObject = _ui.target.GetChild("item" + i);
|
|
|
- if (itemObject != null)
|
|
|
- {
|
|
|
- UI_LuckyBoxBonusItem itemUITen = UI_LuckyBoxBonusItem.Proxy(itemObject);
|
|
|
- itemUITen.target.onClick.Add(OnClickItem);
|
|
|
- itemUITen.m_comIcon.m_icon.onClick.Add(OnClickItemTips);
|
|
|
- SceneController.AddObjectToView(null, null, itemUITen.m_holder, resPath, out GameObject gameobject, out GoWrapper wrapper);
|
|
|
- _gameobjects.Add(gameobject);
|
|
|
- _wrappers.Add(wrapper);
|
|
|
- UI_LuckyBoxBonusItem.ProxyEnd();
|
|
|
- openState.Add(false);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- private void OnClickBg()
|
|
|
- {
|
|
|
- if (openCount < itemList.Count)
|
|
|
- {
|
|
|
- OnClickOpen();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.Hide();
|
|
|
- ViewManager.Show(_goBackViewName, _goBackParams);
|
|
|
- GetSuitItemController.TryShow(0);
|
|
|
- _ui.m_t0.Stop(true, false);
|
|
|
- }
|
|
|
- }
|
|
|
- private void UpdateView()
|
|
|
- {
|
|
|
-
|
|
|
- _ui.m_loaMask.visible = false;
|
|
|
- // int[][] bonus = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.luckyBoxId).bonusArr;
|
|
|
- // List<ItemData> itemDatas = ItemUtil.CreateItemDataList(bonus, LuckyBoxDataManager.Instance.times);
|
|
|
- // ViewManager.Show<LuckyBoxNewDressView>(itemDatas);
|
|
|
- }
|
|
|
- private void ShowBonusList()
|
|
|
- {
|
|
|
- if (itemList.Count > 1)
|
|
|
- {
|
|
|
- for (int i = 0; i < itemList.Count; i++)
|
|
|
- {
|
|
|
- GObject itemObject = _ui.target.GetChild("item" + i);
|
|
|
- if (itemObject != null)
|
|
|
- {
|
|
|
- _gameobjects[i].SetActive(false);
|
|
|
- UpdateItem(i, itemObject);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _gameobject.SetActive(false);
|
|
|
- UpdateItem(0, _ui.m_itemOne.target);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void UpdateItem(int index, GObject obj)
|
|
|
- {
|
|
|
- ItemData itemData = itemList[index];
|
|
|
- UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(obj);
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
|
|
|
- bool isFirst = true;
|
|
|
- int count = 0;
|
|
|
- for (int i = 0; i < itemList.Count; i++)
|
|
|
- {
|
|
|
- if (i < index && itemList[i].id == itemData.id)
|
|
|
- {
|
|
|
- isFirst = false;
|
|
|
- }
|
|
|
- if (itemList[i].id == itemData.id)
|
|
|
- {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
- itemUI.m_comIcon.m_imgNew.visible = itemCfg.itemType != ConstItemType.ITEM && ItemDataManager.GetItemNum(itemData.id) == count && isFirst ? true : false;
|
|
|
- string itemName = itemCfg.name;
|
|
|
- itemUI.m_comIcon.m_txtName.text = itemName;
|
|
|
- itemUI.m_c1.selectedIndex = itemCfg.rarity;
|
|
|
- itemUI.m_comIcon.m_c1.selectedIndex = itemCfg.rarity;
|
|
|
- RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemData.id, false);
|
|
|
- itemUI.m_comIcon.m_icon.data = itemData.id;
|
|
|
- itemUI.target.data = index;
|
|
|
- itemUI.m_t0.Play();
|
|
|
- UI_LuckyBoxBonusItem.ProxyEnd();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void OnClickItem(EventContext context)
|
|
|
- {
|
|
|
- GComponent item = context.sender as GComponent;
|
|
|
-
|
|
|
- PlayOpenAni(item);
|
|
|
- }
|
|
|
- private void OnClickOpen()
|
|
|
- {
|
|
|
- if (itemList.Count == 1)
|
|
|
- {
|
|
|
- PlayOpenAni(_ui.m_itemOne.target);
|
|
|
- return;
|
|
|
- }
|
|
|
- for (int i = 0; i < itemList.Count; i++)
|
|
|
- {
|
|
|
- GComponent component = _ui.target.GetChild("item" + i).asCom;
|
|
|
- if (component != null)
|
|
|
- {
|
|
|
- bool playing = PlayOpenAni(component);
|
|
|
- if (!playing) continue;
|
|
|
- if (playing) break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private bool PlayOpenAni(GComponent component)
|
|
|
- {
|
|
|
- Transition transition = component.GetTransition("t1");
|
|
|
- GComponent comIcon = component.GetChild("comIcon").asCom;
|
|
|
- if (transition.playing || comIcon.alpha == 1) return false;
|
|
|
- GImage imgNew = component.GetChild("comIcon").asCom.GetChild("imgNew").asImage;
|
|
|
- if (imgNew.visible)
|
|
|
- {
|
|
|
- _ui.m_loaMask.visible = true;
|
|
|
-
|
|
|
- }
|
|
|
- _curComItem = component;
|
|
|
- int index = (int)_curComItem.data;
|
|
|
- if (itemList.Count == 1)
|
|
|
- {
|
|
|
- _gameobject.SetActive(true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _gameobjects[index].SetActive(true);
|
|
|
- }
|
|
|
- transition.Play(UpdateOpenCount);
|
|
|
- return true;
|
|
|
- }
|
|
|
- private void UpdateOpenCount()
|
|
|
- {
|
|
|
- GImage imgNew = _curComItem.GetChild("comIcon").asCom.GetChild("imgNew").asImage;
|
|
|
- int index = (int)_curComItem.data;
|
|
|
- if (imgNew.visible)
|
|
|
- {
|
|
|
- ItemData itemData = itemList[index];
|
|
|
- ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemData.id);
|
|
|
- if (cfg.itemType == ConstItemType.DRESS_UP)
|
|
|
- {
|
|
|
- List<ItemData> itemDatas = ItemUtil.CreateItemDataList(itemData.id, itemData.num);
|
|
|
- ViewManager.Show<LuckyBoxNewDressView>(itemDatas);
|
|
|
- }
|
|
|
- else if (cfg.itemType == ConstItemType.CARD)
|
|
|
- {
|
|
|
- List<int> list = new List<int>();
|
|
|
- list.Add(itemData.id);
|
|
|
- ViewManager.Show<LuckyBoxNewCardView>(new object[] { list, new List<ItemData>() });
|
|
|
- }
|
|
|
- }
|
|
|
- openCount++;
|
|
|
- openState[index] = true;
|
|
|
- _ui.m_loaMask.visible = false;
|
|
|
-
|
|
|
- }
|
|
|
- private void OnClickItemTips(EventContext context)
|
|
|
- {
|
|
|
- GLoader item = context.sender as GLoader;
|
|
|
- int itemID = (int)item.data;
|
|
|
- GoodsItemTipsController.ShowItemTips(itemID);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void OnBtnPassClick()
|
|
|
- {
|
|
|
- if (openCount == itemList.Count)
|
|
|
- {
|
|
|
- OnClickBg();
|
|
|
- return;
|
|
|
- }
|
|
|
- _ui.m_loaMask.visible = true;
|
|
|
- if (itemList.Count == 1)
|
|
|
- {
|
|
|
- PlayOpenAni(_ui.m_itemOne.target);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Timers.inst.Add(0.3f, openState.Count - openCount, UpdateTime);
|
|
|
- Timers.inst.StartCoroutine(UpdatePass());
|
|
|
- }
|
|
|
- }
|
|
|
- public IEnumerator UpdatePass()
|
|
|
- {
|
|
|
- for (int i = 0; i < openState.Count; i++)
|
|
|
- {
|
|
|
- if (openState[i] == false)
|
|
|
- {
|
|
|
- yield return new WaitForSeconds(0.3f);
|
|
|
- yield return UpdateTime(i);
|
|
|
- }
|
|
|
- }
|
|
|
- _ui.m_loaMask.visible = false;
|
|
|
- }
|
|
|
- private IEnumerator UpdateTime(int index)
|
|
|
- {
|
|
|
- GComponent component = _ui.target.GetChild("item" + index).asCom;
|
|
|
- Transition transition = component.GetTransition("t1");
|
|
|
- GComponent comIcon = component.GetChild("comIcon").asCom;
|
|
|
- GImage imgNew = comIcon.GetChild("imgNew").asImage;
|
|
|
-
|
|
|
- openCount++;
|
|
|
- openState[index] = true;
|
|
|
- if (imgNew.visible)
|
|
|
- {
|
|
|
- ItemData itemData = itemList[index];
|
|
|
- ET.Log.Debug("zoya: itemData:" + itemData);
|
|
|
- ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemData.id);
|
|
|
- if (cfg.itemType == ConstItemType.DRESS_UP)
|
|
|
- {
|
|
|
- newItemList.Insert(0, itemData);
|
|
|
- }
|
|
|
- else if (cfg.itemType == ConstItemType.CARD)
|
|
|
- {
|
|
|
- newCardList.Insert(0, itemData.id);
|
|
|
- }
|
|
|
- }
|
|
|
- _gameobjects[index].SetActive(true);
|
|
|
- if (openCount == itemList.Count)
|
|
|
- {
|
|
|
- transition.Play(PlayComplete);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- transition.Play();
|
|
|
- }
|
|
|
- yield return null;
|
|
|
- }
|
|
|
- private void PlayComplete()
|
|
|
- {
|
|
|
- if (newCardList.Count > 0)
|
|
|
- {
|
|
|
- ViewManager.Show<LuckyBoxNewCardView>(new object[] { newCardList, newItemList });
|
|
|
- }
|
|
|
- else if (newItemList.Count > 0)
|
|
|
- {
|
|
|
- ViewManager.Show<LuckyBoxNewDressView>(newItemList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|