123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections.Generic;
- using FairyGUI;
- using UI.Studio;
- using UnityEngine;
- namespace GFGGame
- {
- public class StudioPropertyView : StudioBaseView
- {
- private int _propertySelectIndex = 0;
- private int _typeSelectIndex = 0;
- private int firstOpenProperty = -1;//第一个开放的副本(打开界面时,如未选择副本,则默认选中第一个开启的副本)
- //书画副本
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_listProperty.itemRenderer = ListPropertyItemRender;
- _ui.m_listProperty.onClickItem.Add(OnClickListProperty);
- }
- protected override void OnShown()
- {
- firstOpenProperty = -1;
- _typeSelectIndex = this.viewData == null ? 1 : (int)(this.viewData as object[])[0];
- _propertySelectIndex = this.viewData == null ? 0 : (int)(this.viewData as object[])[1];
- _ui.m_c1.selectedIndex = _typeSelectIndex;
- StudioDataManager.Instance.VIEW_NAME = typeof(StudioPropertyView).FullName;
- List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
- _ui.m_listProperty.numItems = studioCfgs.Count;
- _propertySelectIndex = TimeUtil.CheckDayOfWeek(studioCfgs[_propertySelectIndex].timeArr) ? _propertySelectIndex : firstOpenProperty;
- _ui.m_listProperty.selectedIndex = _propertySelectIndex;
- this.studioCfg = studioCfgs[_ui.m_listProperty.selectedIndex];
- this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
- this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
- _ui.m_list.numItems = this.storyLevelCfgs.Count;
- _ui.m_list.ScrollToView(curIndex);
- base.OnShown();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(StudioPropertyView).FullName);
- }
- private void ListPropertyItemRender(int index, GObject obj)
- {
- List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
- GButton item = obj.asButton;
- item.GetChild("icon0").asLoader.url = string.Format("ui://Studio/gzsltb_{0}", index + 1);
- item.GetChild("icon1").asLoader.url = string.Format("ui://Studio/gzsatb_{0}", index + 1);
- item.GetChild("icon2").asLoader.url = string.Format("ui://Studio/gzswtb_{0}", index + 1);
- item.GetChild("icon2").asLoader.visible = TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr) ? false : true;
- if (firstOpenProperty < 0 && TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr)) firstOpenProperty = index;
- item.data = index;
- }
- private void OnClickListProperty(EventContext context)
- {
- GButton item = (context.data as GObject).asButton;
- int index = (int)item.data;
- List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
- StudioCfg studioCfg = studioCfgs[index];
- if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
- {
- _ui.m_listProperty.selectedIndex = _propertySelectIndex;
- string str = "";
- for (int i = 0; i < studioCfg.timeArr.Length; i++)
- {
- str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
- if (i == studioCfg.timeArr.Length - 1) break;
- str += "、";
- }
- PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
- return;
- }
- _propertySelectIndex = index;
- this.studioCfg = studioCfg;
- this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
- this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
- _ui.m_list.numItems = this.storyLevelCfgs.Count;
- _ui.m_list.ScrollToView(curIndex);
- UpdateView();
- StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _ui.m_listProperty.selectedIndex;
- }
- }
- }
|