209 lines
6.7 KiB
C#
209 lines
6.7 KiB
C#
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
using System;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
// 运营活动按钮控制
|
|||
|
// 注意:
|
|||
|
// 其中超值首冲活动非常特殊,显示方式不为图片,而是序列帧,单独做了预设体
|
|||
|
// 为 MarketingMainMenuItemSpecial,该活动的_MenuIcon为空
|
|||
|
public class MarketingMainMenu : UIItemBase
|
|||
|
{
|
|||
|
public GameObject _RedDot;
|
|||
|
public Text remainTimeText; // 剩余次数
|
|||
|
|
|||
|
public Transform displayRt;
|
|||
|
public GameObject descObj; // 描述控制文件
|
|||
|
public Text desc; // 描述
|
|||
|
public GameObject tomorrow; // 明日标记
|
|||
|
|
|||
|
private MarketingActState myActState;
|
|||
|
public MarketingActState MyActState
|
|||
|
{
|
|||
|
get { return myActState; }
|
|||
|
}
|
|||
|
|
|||
|
public override void Init()
|
|||
|
{
|
|||
|
if(descObj != null)
|
|||
|
{
|
|||
|
descObj.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
if (tomorrow != null)
|
|||
|
{
|
|||
|
tomorrow.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
base.Init();
|
|||
|
}
|
|||
|
|
|||
|
public override void Show(Hashtable hash)
|
|||
|
{
|
|||
|
base.Show(hash);
|
|||
|
|
|||
|
MarketingActState actState = (MarketingActState)hash["InitObj"];
|
|||
|
myActState = actState;
|
|||
|
ShowActState(actState);
|
|||
|
}
|
|||
|
|
|||
|
private void ShowActState(MarketingActState actState)
|
|||
|
{
|
|||
|
var tabAct = TableManager.GetActInfoClientByID(actState.actID, 0);
|
|||
|
|
|||
|
if(MyActState.leftOrRight == 1)
|
|||
|
{
|
|||
|
switch(actState.enumType)
|
|||
|
{
|
|||
|
case 1:
|
|||
|
descObj.gameObject.SetActive(true);
|
|||
|
tomorrow.SetActive(false);
|
|||
|
desc.text = actState.pluginfo[0];
|
|||
|
|
|||
|
ShowPrefab(tabAct.Icon);
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
descObj.gameObject.SetActive(true);
|
|||
|
tomorrow.SetActive(false);
|
|||
|
desc.text = StrDictionary.GetClientDictionaryString("#{6756}", actState.pluginfo[0]);
|
|||
|
|
|||
|
ShowPrefab(tabAct.Icon);
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
descObj.gameObject.SetActive(false);
|
|||
|
tomorrow.SetActive(false);
|
|||
|
|
|||
|
ShowPrefab(tabAct.Icon + actState.pluginfo[0]);
|
|||
|
break;
|
|||
|
case 4:
|
|||
|
descObj.gameObject.SetActive(true);
|
|||
|
desc.text = actState.pluginfo[1];
|
|||
|
tomorrow.SetActive(true);
|
|||
|
|
|||
|
ShowPrefab(tabAct.Icon + actState.pluginfo[0]);
|
|||
|
break;
|
|||
|
default:
|
|||
|
descObj.gameObject.SetActive(false);
|
|||
|
tomorrow.SetActive(false);
|
|||
|
//_MenuIcon.gameObject.SetActive(true);
|
|||
|
//LoadAssetBundle.Instance.SetImageSprite(_MenuIcon, tabAct.Icon);
|
|||
|
|
|||
|
ShowPrefab(tabAct.Icon);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 策划要求左边的按钮只会出现一个,不会再多
|
|||
|
// 现在后续增加的左侧按钮仅做特殊处理。
|
|||
|
else if(MyActState.leftOrRight == 0)
|
|||
|
{
|
|||
|
ShowPrefab(tabAct.Icon);
|
|||
|
}
|
|||
|
|
|||
|
_RedDot.SetActive(actState.state > 0);
|
|||
|
if(remainTimeText)
|
|||
|
remainTimeText.text = (actState.state > 99 ? 99 : actState.state).ToString();
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnClick()
|
|||
|
{
|
|||
|
//OnItemClick();
|
|||
|
if (MarketingActsRoot.Instance())
|
|||
|
MarketingActsRoot.Instance().OnActBtnClick(MyActState);
|
|||
|
}
|
|||
|
|
|||
|
//private void LoadIcon(string iconPath)
|
|||
|
//{
|
|||
|
// int childCount = iconParent.childCount;
|
|||
|
// for(int i = childCount; i >=0; --i)
|
|||
|
// {
|
|||
|
// Destroy(iconParent.GetChild(i));
|
|||
|
// }
|
|||
|
|
|||
|
// LoadAssetBundle.Instance.LoadGameObject(LoadAssetBundle.BUNDLE_PATH_UI, iconPath,
|
|||
|
// (string assetName, GameObject assetItem, Hashtable hashTable) =>
|
|||
|
// {
|
|||
|
// if (assetItem != null)
|
|||
|
// {
|
|||
|
// GameObject newIconObj = Instantiate(assetItem, iconParent);
|
|||
|
// newIconObj.transform.localPosition = Vector3.zero;
|
|||
|
// newIconObj.transform.localScale = Vector3.one;
|
|||
|
// }
|
|||
|
// }, null);
|
|||
|
//}
|
|||
|
|
|||
|
private void ShowPrefab(string name)
|
|||
|
{
|
|||
|
if(displayRt.childCount > 0)
|
|||
|
{
|
|||
|
Transform child = displayRt.GetChild(0);
|
|||
|
if(name.Equals(child.gameObject.name, StringComparison.OrdinalIgnoreCase))
|
|||
|
{
|
|||
|
child.gameObject.SetActive(true);
|
|||
|
var script = child.GetComponentInChildren<MarketingModelIcon>();
|
|||
|
if(script != null)
|
|||
|
{
|
|||
|
script.OnEnable();
|
|||
|
}
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Destroy(child.gameObject);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
GameObject newParent = new GameObject(name);
|
|||
|
newParent.gameObject.SetActive(true);
|
|||
|
newParent.transform.SetParent(displayRt);
|
|||
|
newParent.transform.SetSiblingIndex(0);
|
|||
|
newParent.transform.localScale = Vector3.one;
|
|||
|
newParent.transform.localPosition = Vector3.zero;
|
|||
|
|
|||
|
Hashtable data = new Hashtable();
|
|||
|
data["Name"] = name;
|
|||
|
data["Parent"] = newParent.transform;
|
|||
|
|
|||
|
LoadAssetBundle.Instance.LoadGameObject(LoadAssetBundle.BUNDLE_PATH_EFFECT, name,
|
|||
|
(string assetName, GameObject assetItem, Hashtable hashTable) =>
|
|||
|
{
|
|||
|
if (assetItem != null)
|
|||
|
{
|
|||
|
GameObject prefab = assetItem as GameObject;
|
|||
|
if(prefab == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("No this resource " + assetName + ".prefab");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Transform newRt = hashTable["Parent"] as Transform;
|
|||
|
if(newRt == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
GameObject newOne = Instantiate(prefab, newRt);
|
|||
|
newOne.SetActive(true);
|
|||
|
newOne.name = (string)hashTable["Name"];
|
|||
|
newOne.transform.localScale = Vector3.one;
|
|||
|
newOne.transform.localPosition = Vector3.zero;
|
|||
|
UIParticleSystem script = newOne.GetComponentInChildren<UIParticleSystem>(true);
|
|||
|
if(script != null)
|
|||
|
{
|
|||
|
script.Init();
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LogModule.ErrorLog("No this resource " + assetName + ".prefab");
|
|||
|
}
|
|||
|
}, data);
|
|||
|
}
|
|||
|
}
|