|
@@ -0,0 +1,166 @@
|
|
|
+using UnityEngine;
|
|
|
+using FairyGUI;
|
|
|
+using UI.OpenServerActivity;
|
|
|
+using UI.CommonGame;
|
|
|
+using System.Collections.Generic;
|
|
|
+
|
|
|
+namespace GFGGame
|
|
|
+{
|
|
|
+ public class OpenServerStoryView : BaseWindow
|
|
|
+ {
|
|
|
+ private UI_OpenServerStoryUI _ui;
|
|
|
+ private int itemIndex = 0;
|
|
|
+ private List<StoryLevelCfg> _storyLevelCfgs;
|
|
|
+ private ActivityFightCfg _activityFightCfg;
|
|
|
+ private int _activityId;
|
|
|
+ private int _activityType;
|
|
|
+ private ActivityOpenCfg _activityCfg;
|
|
|
+
|
|
|
+ public override void Dispose()
|
|
|
+ {
|
|
|
+ if (_ui != null)
|
|
|
+ {
|
|
|
+ _ui.Dispose();
|
|
|
+ _ui = null;
|
|
|
+ }
|
|
|
+ base.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void Init()
|
|
|
+ {
|
|
|
+ base.Init();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnInit()
|
|
|
+ {
|
|
|
+ base.OnInit();
|
|
|
+ packageName = UI_OpenServerStoryUI.PACKAGE_NAME;
|
|
|
+ _ui = UI_OpenServerStoryUI.Create();
|
|
|
+ viewCom = _ui.target;
|
|
|
+ isfullScreen = true;
|
|
|
+ isReturnView = true;
|
|
|
+ _ui.m_list.itemRenderer = RenderListItem;
|
|
|
+
|
|
|
+ _ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void AddEventListener()
|
|
|
+ {
|
|
|
+ base.AddEventListener();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnShown()
|
|
|
+ {
|
|
|
+ base.OnShown();
|
|
|
+ _activityType = (int)this.viewData;
|
|
|
+ StudioDataManager.Instance.VIEW_NAME = typeof(OpenServerStoryView).FullName;
|
|
|
+ StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _activityType;
|
|
|
+ _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("kfhd_sdcy_bg");
|
|
|
+ _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(_activityType);
|
|
|
+ _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
|
|
|
+ _activityFightCfg = ActivityFightCfgArray.Instance.GetCfg(_activityCfg.params3Arr[0]);
|
|
|
+ _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_activityFightCfg.type, _activityFightCfg.subType, _activityCfg.params3Arr[0]);
|
|
|
+ _ui.m_list.numItems = _storyLevelCfgs.Count;
|
|
|
+ UpdateItem();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnHide()
|
|
|
+ {
|
|
|
+ base.OnHide();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void RemoveEventListener()
|
|
|
+ {
|
|
|
+ base.RemoveEventListener();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnClickBtnBack()
|
|
|
+ {
|
|
|
+ ViewManager.GoBackFrom(typeof(OpenServerStoryView).FullName);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void RenderListItem(int index, GObject obj)
|
|
|
+ {
|
|
|
+ // int _index = _storyLevelCfgs.Count - index - 1;
|
|
|
+ UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
|
|
|
+ //item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
|
|
|
+ item.m_txtName.text = _storyLevelCfgs[index].name;
|
|
|
+ bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
|
|
|
+ string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
|
|
|
+ //item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
|
|
|
+
|
|
|
+ if (isFight)
|
|
|
+ {
|
|
|
+ //item.m_loaBg.url = "ui://Studio/cyjd_di_1";
|
|
|
+ item.m_loaIcon.visible = false;
|
|
|
+ item.m_loaItem.visible = true;
|
|
|
+ StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
|
|
|
+ int itemId = storyFightCfg.bonusBaseArr[0][0];
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
|
|
|
+ item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ if (item.m_loaItem.data == null)
|
|
|
+ {
|
|
|
+ item.m_loaItem.onClick.Add(OnLoaItemClick);
|
|
|
+ }
|
|
|
+ item.m_loaItem.data = index;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //item.m_loaBg.url = "ui://Studio/cyjd_di_2";
|
|
|
+ item.m_loaItem.visible = false;
|
|
|
+ item.m_loaIcon.visible = true;
|
|
|
+ item.m_loaIcon.url = string.Format("ui://Studio/{0}", _activityFightCfg.res);
|
|
|
+ }
|
|
|
+ item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
|
|
|
+ item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
|
|
|
+ if (item.m_loaBg.data == null)
|
|
|
+ {
|
|
|
+ item.m_loaBg.onClick.Add(OnListItemClick);
|
|
|
+ }
|
|
|
+ item.m_loaBg.data = index;
|
|
|
+ UI_ListLevelItem.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnListItemClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ int index = (int)obj.data;
|
|
|
+ StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
|
|
|
+ if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("Ðèͨ¹ØÇ°Öùؿ¨");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
|
|
|
+ InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStudioStoryLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnLoaItemClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ int index = (int)obj.data;
|
|
|
+ StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
|
|
|
+ int itemId = storyFightCfg.bonusBaseArr[0][0];
|
|
|
+ GoodsItemTipsController.ShowItemTips(itemId);
|
|
|
+
|
|
|
+ }
|
|
|
+ private void UpdateItem()
|
|
|
+ {
|
|
|
+ for (int i = 0; i < _ui.m_list.numChildren; i++)
|
|
|
+ {
|
|
|
+ _ui.m_list.GetChildAt(i).visible = false;
|
|
|
+ }
|
|
|
+ itemIndex = 0;
|
|
|
+ Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddItemUpdate(object param)
|
|
|
+ {
|
|
|
+ _ui.m_list.GetChildAt(itemIndex).visible = true;
|
|
|
+ UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
|
|
|
+ item.m_Left.Play();
|
|
|
+ itemIndex++;
|
|
|
+ UI_ListLevelItem.ProxyEnd();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|