123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- using FairyGUI;
- using UI.FieldGuide;
- using System.Collections.Generic;
- using System;
- namespace GFGGame
- {
- public class FieldGuideView : BaseWindow
- {
- private UI_FieldGuideUI _ui;
- private int[] _listBannerDatas = new int[3] { ConstBannerId.ZHAI_XING, ConstBannerId.ZHAI_XING, ConstBannerId.ZHAI_XING };
- private int[] _listGuideDatas = new int[1] { ConstFieldGuideId.SUIT_GUIDE };
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_FieldGuideUI.PACKAGE_NAME;
- _ui = UI_FieldGuideUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_compBanner.m_listTab.itemRenderer = ListBannerItemRenderer;
- _ui.m_compBanner.m_listTab.numItems = _listBannerDatas.Length;
- _ui.m_listGuide.itemRenderer = ListGuideItemRenderer;
- _ui.m_listGuide.numItems = _listGuideDatas.Length;
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_listGuide.onClickItem.Add(OnClickListGuideItem);
- _ui.m_compBanner.m_listTab.onClickItem.Add(OnClickListBannerItem);
- _ui.m_compBanner.m_loaderPic.onClick.Add(OnClickBannerPic);
- }
- protected override void OnShown()
- {
- base.OnShown();
- UpdatePrgress();
- _ui.m_compBanner.m_listTab.selectedIndex = 0;
- UpdateBanner(_ui.m_compBanner.m_listTab.GetChildAt(_ui.m_compBanner.m_listTab.selectedIndex));
- Timers.inst.Add(3, 0, SwitchBannerPic);
- }
- protected override void OnHide()
- {
- base.OnHide();
- Timers.inst.Remove(SwitchBannerPic);
- }
- private void OnClickBtnBack()
- {
- // this.Hide();
- ViewManager.GoBackFrom(ViewName.FIELD_GUIDE_VIEW);
- }
- private void ListBannerItemRenderer(int index, GObject item)
- {
- UI_ButtonBannerPage listItem = UI_ButtonBannerPage.Proxy(item);
- int id = _listBannerDatas[index];
- listItem.target.data = id;
- }
- private void OnClickBannerPic()
- {
- int id = _listBannerDatas[_ui.m_compBanner.m_listTab.selectedIndex];
- switch (id)
- {
- case ConstBannerId.ZHAI_XING:
- ViewManager.Show(ViewName.LUCKY_BOX_VIEW);
- break;
- }
- }
- private void ListGuideItemRenderer(int index, GObject item)
- {
- UI_CompGuideItem listItem = UI_CompGuideItem.Proxy(item);
- int id = _listGuideDatas[index];
- listItem.m_loaderTitle.url = "ui://FieldGuide/tujian_taoz_" + id;
- listItem.m_loaderPic.url = "ui://FieldGuide/tujian_tup_" + id;
- listItem.target.data = id;
- }
- private void OnClickListBannerItem(EventContext context)
- {
- UpdateBanner(context.data as GObject);
- }
- private void OnClickListGuideItem(EventContext context)
- {
- GObject listItem = context.data as GObject;
- int id = (int)listItem.data;
- switch (id)
- {
- case ConstFieldGuideId.SUIT_GUIDE:
- ViewManager.Show(ViewName.SUIT_GUIDE_VIEW, null, new object[] { ViewName.FIELD_GUIDE_VIEW, this.viewData });
- break;
- }
- }
- private void GetGuideProgress(int id, out int haveCount, out int totalCount)
- {
- switch (id)
- {
- case ConstFieldGuideId.SUIT_GUIDE:
- DressUpMenuSuitDataManager.GetTotalProgress(out haveCount, out totalCount);
- break;
- default:
- haveCount = 0;
- totalCount = 1;
- break;
- }
- }
- private void UpdatePrgress()
- {
- int num = _ui.m_listGuide.numChildren;
- for (int i = 0; i < num; i++)
- {
- UI_CompGuideItem listItem = UI_CompGuideItem.Proxy(_ui.m_listGuide.GetChildAt(i));
- int id = (int)listItem.target.data;
- int haveCount = 0;
- int totalCount = 1;
- GetGuideProgress(id, out haveCount, out totalCount);
- decimal value = Math.Floor((decimal)100 * haveCount / totalCount);
- listItem.m_txtProgress.text = value + "%";
- }
- }
- private void UpdateBanner(GObject listItem)
- {
- string resName = "tujian_huodtu_1";
- int id = (int)listItem.data;
- switch (id)
- {
- case ConstBannerId.ZHAI_XING:
- resName = "tujian_huodtu_1";
- break;
- }
- _ui.m_compBanner.m_loaderPic.url = "ui://FieldGuide/" + resName;
- UpdateListBannerItems();
- }
- private void UpdateListBannerItems()
- {
- int num = _ui.m_compBanner.m_listTab.numChildren;
- for (int i = 0; i < num; i++)
- {
- UI_ButtonBannerPage listItem = UI_ButtonBannerPage.Proxy(_ui.m_compBanner.m_listTab.GetChildAt(i));
- if (listItem.target.selected)
- {
- listItem.target.width = 47;
- }
- else
- {
- listItem.target.width = 15;
- }
- }
- _ui.m_compBanner.m_listTab.ResizeToFit();
- }
- private void SwitchBannerPic(object param)
- {
- int index = _ui.m_compBanner.m_listTab.selectedIndex;
- index++;
- if (index >= _listBannerDatas.Length)
- {
- index = 0;
- }
- _ui.m_compBanner.m_listTab.selectedIndex = index;
- UpdateBanner(_ui.m_compBanner.m_listTab.GetChildAt(_ui.m_compBanner.m_listTab.selectedIndex));
- }
- }
- }
|