470 lines
13 KiB
C#
470 lines
13 KiB
C#
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using Module.Log;
|
|||
|
using GCGame;
|
|||
|
using System;
|
|||
|
|
|||
|
|
|||
|
public class MarketingActsRoot : UIControllerBase<MarketingActsRoot>
|
|||
|
{
|
|||
|
#region
|
|||
|
|
|||
|
public static void ShowMarketingAct(string actIDStr)
|
|||
|
{
|
|||
|
if (!MarketingActsRoot.Instance())
|
|||
|
return;
|
|||
|
|
|||
|
int actID = int.Parse(actIDStr);
|
|||
|
var actState = MarketingActsRoot.Instance().actStages.Find((actStage) =>
|
|||
|
{
|
|||
|
if (actStage.actID == actID)
|
|||
|
return true;
|
|||
|
return false;
|
|||
|
});
|
|||
|
|
|||
|
if (actState != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().OnActBtnClick(actState);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowMarketingActByUI(string uiName)
|
|||
|
{
|
|||
|
var actState = MarketingActsRoot.Instance().actStages.Find((actStage) =>
|
|||
|
{
|
|||
|
var actinfo = TableManager.GetActInfoClientByID(actStage.actID);
|
|||
|
if (actinfo.UIPath.Equals(uiName))
|
|||
|
return true;
|
|||
|
return false;
|
|||
|
});
|
|||
|
|
|||
|
if (actState != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().OnActBtnClick(actState);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region
|
|||
|
|
|||
|
public void Start()
|
|||
|
{
|
|||
|
SetInstance(this);
|
|||
|
|
|||
|
ReqActList();
|
|||
|
|
|||
|
ShowRefresh();
|
|||
|
}
|
|||
|
|
|||
|
public void OnDestory()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
}
|
|||
|
|
|||
|
public void Close()
|
|||
|
{
|
|||
|
LuaUIManager.Instance.CloseUI("MarketingActsRoot");
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
// 显示获得物品数据相关
|
|||
|
public float showTipsInterval = 0.0f; // 显示提示的间隔
|
|||
|
private Queue<MarketingActAwardItem> tipsQueue; // 等待显示的获取信息队列
|
|||
|
|
|||
|
public List<MarketingActState> actStages; // 目前开启的活动数组
|
|||
|
|
|||
|
// 现活动分两侧显示
|
|||
|
public UIContainerBase _ActContainer_R; // 右侧显示的活动
|
|||
|
public UIContainerBase _ActContainer_L; // 左侧显示的活动 虽说是左侧显示的活动,但仅为超值首冲活动服务,加上其他活动按钮上的显示会存在问题。
|
|||
|
|
|||
|
public Dictionary<int, GameObject> _ShowingWin = new Dictionary<int, GameObject>();
|
|||
|
|
|||
|
//public delegate void ShowSubActByID(GameObject uiGO);
|
|||
|
//public ShowSubActByID openSubActDel;
|
|||
|
private bool isOpenSubAct = false;
|
|||
|
private int entranceID = int.MinValue;
|
|||
|
private int actID = int.MinValue;
|
|||
|
|
|||
|
public void SetActListMenu(List<MarketingActState> actStages)
|
|||
|
{
|
|||
|
List<MarketingActState> rightMarketingActState = new List<MarketingActState>();
|
|||
|
List<MarketingActState> leftMarketingActState = new List<MarketingActState>();
|
|||
|
|
|||
|
for(int i = 0; i < actStages.Count; ++i)
|
|||
|
{
|
|||
|
if(actStages[i].leftOrRight == 0)
|
|||
|
{
|
|||
|
leftMarketingActState.Add(actStages[i]);
|
|||
|
}
|
|||
|
|
|||
|
if(actStages[i].leftOrRight == 1)
|
|||
|
{
|
|||
|
rightMarketingActState.Add(actStages[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
this.actStages = actStages;
|
|||
|
|
|||
|
leftMarketingActState.Sort(ActMenuSort);
|
|||
|
rightMarketingActState.Sort(ActMenuSort);
|
|||
|
|
|||
|
_ActContainer_L.InitContentItem(leftMarketingActState, OnActBtnClick);
|
|||
|
_ActContainer_R.InitContentItem(rightMarketingActState, OnActBtnClick);
|
|||
|
}
|
|||
|
|
|||
|
public void OnActBtnClick(object actObj)
|
|||
|
{
|
|||
|
MarketingActState actState = actObj as MarketingActState;
|
|||
|
var tabAct = TableManager.GetActInfoClientByID(actState.actID, 0);
|
|||
|
if (tabAct == null)
|
|||
|
return;
|
|||
|
|
|||
|
// vip特殊处理
|
|||
|
if (actState.actID == 1000)
|
|||
|
{
|
|||
|
YuanBaoShopLogic.OpenVipPage();
|
|||
|
}
|
|||
|
else if(actState.JumpTo != null && !string.IsNullOrEmpty(actState.JumpTo))
|
|||
|
{
|
|||
|
string[] parms = actState.JumpTo.TrimEnd(' ', '"').Split('*');
|
|||
|
if (parms.Length > 0)
|
|||
|
{
|
|||
|
int jumpToEnhance = Convert.ToInt32(parms[0]);
|
|||
|
if(jumpToEnhance == actState.actID)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("ERROR: Trying jump to the same act !!!");
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (parms.Length > 1)
|
|||
|
{
|
|||
|
ItemGetPathPopRoot.GotoOperationalAct(Convert.ToInt32(parms[0]), Convert.ToInt32(parms[1]));
|
|||
|
}
|
|||
|
else if (parms.Length > 0)
|
|||
|
{
|
|||
|
ItemGetPathPopRoot.GotoOperationalAct(Convert.ToInt32(parms[0]), -1);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("ActState", actState);
|
|||
|
LuaUIManager.Instance.ShowLuaUI(tabAct.UIPath, LoadUICallBack, hash, true);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 每次关闭页面,更新红点信息。
|
|||
|
public void ClearShowingWin(int actID)
|
|||
|
{
|
|||
|
_ShowingWin.Remove(actID);
|
|||
|
ReqActList();
|
|||
|
}
|
|||
|
|
|||
|
public void LoadUICallBack(bool sucess, object param, GameObject uiObj)
|
|||
|
{
|
|||
|
Hashtable hash = (Hashtable)param;
|
|||
|
MarketingActState actState = (MarketingActState)hash["ActState"];
|
|||
|
if(_ShowingWin.ContainsKey(actState.actID))
|
|||
|
{
|
|||
|
_ShowingWin.Remove(actState.actID);
|
|||
|
}
|
|||
|
_ShowingWin.Add(actState.actID, uiObj);
|
|||
|
|
|||
|
var uiCs = uiObj.GetComponent<MarketingUIBaseCS>();
|
|||
|
if (uiCs != null)
|
|||
|
{
|
|||
|
uiCs._ActID = actState.actID;
|
|||
|
}
|
|||
|
|
|||
|
var uiLua = uiObj.GetComponent<MarketingUIBaseLua>();
|
|||
|
if (uiLua != null)
|
|||
|
{
|
|||
|
uiLua.Awake();
|
|||
|
uiLua.ActID = actState.actID;
|
|||
|
}
|
|||
|
|
|||
|
uiObj.transform.SetAsLastSibling();
|
|||
|
|
|||
|
uiObj.SetActive(true);
|
|||
|
|
|||
|
if (isOpenSubAct == true)
|
|||
|
{
|
|||
|
isOpenSubAct = false;
|
|||
|
if (actID != int.MinValue)
|
|||
|
{
|
|||
|
var luaScript = uiObj.GetComponent<MarketingUIBaseLua>();
|
|||
|
if (luaScript != null)
|
|||
|
{
|
|||
|
luaScript.CallScriptFuncAtPath(luaScript.luaScript + ".ShowActByID", this.actID);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 清空指定打开页面记录
|
|||
|
SetOpenData();
|
|||
|
}
|
|||
|
|
|||
|
public void LoadUICallBackLua(bool sucess, MarketingActState param, GameObject uiObj)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash["ActState"] = param;
|
|||
|
LoadUICallBack(sucess, hash, uiObj);
|
|||
|
}
|
|||
|
|
|||
|
#region
|
|||
|
|
|||
|
public void ReqActList()
|
|||
|
{
|
|||
|
MarketingActsReq packet = new MarketingActsReq();
|
|||
|
packet.actType = -1;
|
|||
|
packet.SendMsg();
|
|||
|
|
|||
|
//MarketingActsRet packetRet = new MarketingActsRet();
|
|||
|
//packetRet.actType = -1;
|
|||
|
//packetRet.actIDState = new System.Collections.Generic.List<MarketingActState>();
|
|||
|
//packetRet.actIDState.Add(new MarketingActState() { actID = 1, state = 0 });
|
|||
|
//packetRet.actIDState.Add(new MarketingActState() { actID = 2, state = 0 });
|
|||
|
//packetRet.actIDState.Add(new MarketingActState() { actID = 3, state = 1 });
|
|||
|
//packetRet.actIDState.Add(new MarketingActState() { actID = 4, state = 1 });
|
|||
|
//packetRet.SendMsg();
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region showAnim
|
|||
|
|
|||
|
public Animator _ShowAnim;
|
|||
|
private bool _FlagStateChange = true;
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if(_FlagStateChange)
|
|||
|
{
|
|||
|
AnimatorStateInfo info = _ShowAnim.GetCurrentAnimatorStateInfo(0);
|
|||
|
if (_ShowFlag)
|
|||
|
{
|
|||
|
if (!info.IsName("Show"))
|
|||
|
{
|
|||
|
_ShowAnim.Play("Show", 0, 0);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (!info.IsName("Hide"))
|
|||
|
{
|
|||
|
_ShowAnim.Play("Hide", 0, 0);
|
|||
|
}
|
|||
|
}
|
|||
|
_FlagStateChange = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static bool _ShowFlag = true;
|
|||
|
|
|||
|
public void ShowRefresh()
|
|||
|
{
|
|||
|
_FlagStateChange = true;
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowBtns()
|
|||
|
{
|
|||
|
_ShowFlag = true;
|
|||
|
if (MarketingActsRoot.Instance())
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowRefresh();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void HideBtns()
|
|||
|
{
|
|||
|
_ShowFlag = false;
|
|||
|
if (MarketingActsRoot.Instance())
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowRefresh();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
#region Show tips
|
|||
|
|
|||
|
// 显示获得的信息
|
|||
|
public void ShowGetTips(List<MarketingActAwardItem> awardList)
|
|||
|
{
|
|||
|
if(tipsQueue == null)
|
|||
|
{
|
|||
|
tipsQueue = new Queue<MarketingActAwardItem>();
|
|||
|
}
|
|||
|
|
|||
|
if (tipsQueue.Count > 0)
|
|||
|
{
|
|||
|
for (int i = 0; i < awardList.Count; i++)
|
|||
|
{
|
|||
|
tipsQueue.Enqueue(awardList[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
for (int i = 0; i < awardList.Count; i++)
|
|||
|
{
|
|||
|
tipsQueue.Enqueue(awardList[i]);
|
|||
|
}
|
|||
|
StartCoroutine("ShowTips");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator ShowTips()
|
|||
|
{
|
|||
|
// 安全计数,防止死循环
|
|||
|
int count = 0;
|
|||
|
while (tipsQueue.Count > 0)
|
|||
|
{
|
|||
|
MarketingActAwardItem item = tipsQueue.Dequeue();
|
|||
|
Tab_CommonItem tab = TableManager.GetCommonItemByID(item.awardSubType, 0);
|
|||
|
string tip = tab.Name + " X " + item.awardNum;
|
|||
|
GUIData.AddNotifyData(tip);
|
|||
|
|
|||
|
for (float i = 0.0f; i < showTipsInterval; i += Time.deltaTime)
|
|||
|
{
|
|||
|
yield return null;
|
|||
|
}
|
|||
|
|
|||
|
count++;
|
|||
|
if (count > 50)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
// 替代 UIContainerBase.GetContainItem<T>。
|
|||
|
public MarketingMainMenu GetContainItem(int enhanceID)
|
|||
|
{
|
|||
|
bool hasFound = false;
|
|||
|
MarketingMainMenu result = null;
|
|||
|
_ActContainer_R.ForeachActiveItem<MarketingMainMenu>((MarketingMainMenu obj) =>
|
|||
|
{
|
|||
|
if (hasFound == false && obj.MyActState.actID == enhanceID)
|
|||
|
{
|
|||
|
hasFound = true;
|
|||
|
result = obj;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
if(hasFound == true)
|
|||
|
{
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
_ActContainer_L.ForeachActiveItem<MarketingMainMenu>((MarketingMainMenu obj) =>
|
|||
|
{
|
|||
|
if (hasFound == false && obj.MyActState.actID == enhanceID)
|
|||
|
{
|
|||
|
hasFound = true;
|
|||
|
result = obj;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
//对外接口,开启入口活动的界面,entrance = 入口ID,actID = 活动ID。
|
|||
|
public bool ShowActById(int entranceID = int.MinValue, int actID = int.MinValue)
|
|||
|
{
|
|||
|
if ((actID > 0 && GlobalData.IsMarketingActActive(actID) == false)
|
|||
|
|| (actID < 0 && GlobalData.IsMarketingActActive(entranceID) == false))
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6741}"));
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
SetOpenData(entranceID, actID);
|
|||
|
isOpenSubAct = true;
|
|||
|
MarketingActState newAct = new MarketingActState();
|
|||
|
newAct.actID = entranceID;
|
|||
|
|
|||
|
OnActBtnClick(newAct);
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
// 设置打开活动参数
|
|||
|
private void SetOpenData(int entranceID = int.MinValue, int actID = int.MinValue)
|
|||
|
{
|
|||
|
this.entranceID = entranceID;
|
|||
|
this.actID = actID;
|
|||
|
}
|
|||
|
|
|||
|
private int ActMenuSort(MarketingActState l, MarketingActState r)
|
|||
|
{
|
|||
|
Tab_ActInfoClient tab_l = TableManager.GetActInfoClientByID(l.actID, 0);
|
|||
|
Tab_ActInfoClient tab_r = TableManager.GetActInfoClientByID(r.actID, 0);
|
|||
|
|
|||
|
if(tab_l.Order != -1 && tab_r.Order != -1)
|
|||
|
{
|
|||
|
return tab_l.Order.CompareTo(tab_r.Order);
|
|||
|
}
|
|||
|
else if(tab_l.Order != tab_r.Order)
|
|||
|
{
|
|||
|
return -tab_l.Order.CompareTo(tab_r.Order);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int index_l = actStages.IndexOf(l);
|
|||
|
int index_r = actStages.IndexOf(r);
|
|||
|
|
|||
|
return index_l.CompareTo(index_r);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 标准化一次传过来的特效
|
|||
|
// 因为这个特效需要匹配不同的大小框
|
|||
|
//public static void GetEffet(float size, int quality, Transform parent)
|
|||
|
//{
|
|||
|
// int effectID = -1;
|
|||
|
// if (quality == 1)
|
|||
|
// {
|
|||
|
// effectID = 7405;
|
|||
|
// }
|
|||
|
// else if (quality == 2)
|
|||
|
// {
|
|||
|
// effectID = 7405;
|
|||
|
// }
|
|||
|
|
|||
|
// Tab_Effect effect = TableManager.GetEffectByID(effectID, 0);
|
|||
|
// if (effect != null)
|
|||
|
// {
|
|||
|
// Hashtable Info = new Hashtable();
|
|||
|
// Info.Add("parent", parent);
|
|||
|
// Info.Add("size", size);
|
|||
|
|
|||
|
// LoadAssetBundle.Instance.LoadGameObject(LoadAssetBundle.BUNDLE_PATH_EFFECT, effect.Path,
|
|||
|
// (string assetName, GameObject assetItem, Hashtable hashTable) =>
|
|||
|
// {
|
|||
|
// Transform newParent = hashTable["size"] as Transform;
|
|||
|
// if (assetItem != null && newParent.gameObject.activeInHierarchy)
|
|||
|
// {
|
|||
|
// Transform newEffect = Instantiate(assetItem).transform;
|
|||
|
// float scale = (float)hashTable["size"];
|
|||
|
// scale = scale / 72.0f;
|
|||
|
// newEffect.localScale = new Vector3(scale, scale, 1.0f);
|
|||
|
// newEffect.parent = newParent;
|
|||
|
// newEffect.localPosition = Vector3.zero;
|
|||
|
// }
|
|||
|
// }, Info);
|
|||
|
// }
|
|||
|
//}
|
|||
|
}
|