152 lines
3.8 KiB
C#
152 lines
3.8 KiB
C#
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Games.GlobeDefine;
|
|
using GCGame.Table;
|
|
using GCGame;
|
|
using System;
|
|
|
|
// 进阶特惠
|
|
public class MarketingWinRootCS : MarketingUIBaseCS
|
|
{
|
|
#region
|
|
|
|
public static MarketingWinRootCS Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public void OnEnable()
|
|
{
|
|
InitWin();
|
|
}
|
|
|
|
public void OnDisable()
|
|
{
|
|
lastSelectedMenuItem = null;
|
|
if (MarketingActsRoot.Instance())
|
|
{
|
|
MarketingActsRoot.Instance().ClearShowingWin(_ActID);
|
|
}
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
// 用于设置活动接收菜单数据后显示的活动
|
|
// 无论存在此活动与否,都要在第一次显示过后,设回 -1
|
|
// -1 不跳转
|
|
private static int openWithAct = -1;
|
|
public static int OpenWithAct
|
|
{
|
|
set { openWithAct = value; }
|
|
}
|
|
|
|
public Text _Title;
|
|
public UIContainerSelect _MenuContainer;
|
|
public Transform _PageContainer;
|
|
public List<MarketingActState> _ActPageInfo;
|
|
|
|
private int _SelectedActID;
|
|
|
|
public void InitWin()
|
|
{
|
|
ReqActList();
|
|
|
|
}
|
|
|
|
public void SetActListMenu(List<MarketingActState> actStages)
|
|
{
|
|
if (actStages.Count > 0)
|
|
{
|
|
List<MarketingActState> selectMenus = new List<MarketingActState>();
|
|
|
|
// 查看是否有需要打开的活动ID
|
|
int index = actStages.FindIndex((MarketingActState m) => { return m.actID == openWithAct; });
|
|
if (index != -1)
|
|
{
|
|
selectMenus.Add(actStages[index]);
|
|
}
|
|
else
|
|
{
|
|
selectMenus.Add(actStages[0]);
|
|
if (openWithAct != -1)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6741}"));
|
|
}
|
|
}
|
|
if(lastSelectedMenuItem == null)
|
|
{
|
|
_MenuContainer.InitSelectContent(actStages, selectMenus, OnMenuSelect);
|
|
}
|
|
else
|
|
{
|
|
_MenuContainer.InitSelectContent(actStages, selectMenus);
|
|
}
|
|
}
|
|
|
|
openWithAct = -1;
|
|
}
|
|
|
|
private MarketingActState lastSelectedMenuItem = null;
|
|
public void OnMenuSelect(object actObj)
|
|
{
|
|
MarketingActState actState = actObj as MarketingActState;
|
|
lastSelectedMenuItem = actState;
|
|
if (MarketingActsRoot.Instance())
|
|
{
|
|
if (MarketingActsRoot.Instance()._ShowingWin.ContainsKey(_SelectedActID))
|
|
{
|
|
if (MarketingActsRoot.Instance()._ShowingWin[_SelectedActID] != null)
|
|
MarketingActsRoot.Instance()._ShowingWin[_SelectedActID].SetActive(false);
|
|
MarketingActsRoot.Instance()._ShowingWin.Remove(_SelectedActID);
|
|
}
|
|
}
|
|
|
|
_SelectedActID = actState.actID;
|
|
LoadPage(actState);
|
|
}
|
|
|
|
private void LoadPage(MarketingActState page)
|
|
{
|
|
var actInfo = TableManager.GetActInfoClientByID(page.actID, 0);
|
|
Hashtable hash = new Hashtable();
|
|
hash.Add("ActState", page);
|
|
|
|
{
|
|
LuaUIManager.Instance.ShowLuaUIAsChild(actInfo.UIPath, _PageContainer.gameObject, MarketingActsRoot.Instance().LoadUICallBack, hash, true);
|
|
}
|
|
}
|
|
|
|
#region
|
|
|
|
private void ReqActList()
|
|
{
|
|
MarketingActsReq packet = new MarketingActsReq();
|
|
packet.actType = _ActID;
|
|
packet.SendMsg();
|
|
}
|
|
|
|
protected override void MarketingActRetInner(MarketingActsRet marketActsRet)
|
|
{
|
|
base.MarketingActRetInner(marketActsRet);
|
|
|
|
SetActListMenu(marketActsRet.actIDState);
|
|
}
|
|
#endregion
|
|
|
|
}
|