225 lines
6.4 KiB
C#
225 lines
6.4 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
using System.Collections.Generic;
|
|
using Module.Log;
|
|
|
|
public class MarryRoot : MonoBehaviour
|
|
{
|
|
// 红点更新类型 - 左侧菜单
|
|
public enum RedTipType
|
|
{
|
|
Ring,
|
|
Fetter,
|
|
AcaciaTree,
|
|
Copy
|
|
}
|
|
|
|
public List<GameObject> redTips = new List<GameObject>();
|
|
|
|
public static MarryRoot Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public enum MarryMenuItemType
|
|
{
|
|
Marry = 0,
|
|
Ring,
|
|
Relation,
|
|
Tree,
|
|
Copy,
|
|
}
|
|
|
|
public void ShowPage(MarryMenuItemType type)
|
|
{
|
|
OnMenuItemClick(type);
|
|
}
|
|
|
|
public List<MarryMenuItem> menuItemList;
|
|
public Transform contentTrans;
|
|
public GameObject alsoHaveItemmarkIcon;
|
|
private float wrongDisRemixValue = 10.0f;
|
|
public void OnMenuItemClick(MarryMenuItemType type)
|
|
{
|
|
switch(type)
|
|
{
|
|
case MarryMenuItemType.Ring:
|
|
if(GameManager.gameManager.PlayerDataPool.MyRingInfoData.GetRingInfo().ringType == (int)MarryRingCtr.RingType.Invalid)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46523}"));
|
|
return;
|
|
}
|
|
break;
|
|
case MarryMenuItemType.Relation:
|
|
case MarryMenuItemType.Tree:
|
|
case MarryMenuItemType.Copy:
|
|
//{
|
|
// if(!GameManager.gameManager.PlayerDataPool.IsMarried)
|
|
// {
|
|
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46514}"));
|
|
// return;
|
|
// }
|
|
//}
|
|
break;
|
|
}
|
|
|
|
for (int index = 0; index < panelLists.Count; index++)
|
|
{
|
|
panelLists[index].SetActive((int)type == index);
|
|
}
|
|
|
|
for (int index = 0; index < menuItemList.Count; index++)
|
|
{
|
|
menuItemList[index].ShowMarkIcon(index == (int)type);
|
|
}
|
|
}
|
|
|
|
public void OnScrollViewDrag()
|
|
{
|
|
alsoHaveItemmarkIcon.SetActive(
|
|
contentTrans.transform.localPosition.y >= menuItemList[0].GetComponent<ILayoutElement>().minHeight - wrongDisRemixValue ? false : true);
|
|
}
|
|
|
|
IEnumerator ShowDefaultFirst()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
if (menuItemList.Count > 0)
|
|
{
|
|
menuItemList[0].OnItemClick();
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
StartCoroutine(ShowDefaultFirst());
|
|
|
|
if(ringPanelCtr != null)
|
|
{
|
|
// 主要用于红点更新
|
|
ringPanelCtr.PreInit();
|
|
}
|
|
|
|
if (fetterPanelCtr != null)
|
|
{
|
|
// 主要用于红点更新
|
|
fetterPanelCtr.PreInit();
|
|
}
|
|
|
|
if (acaciaTreePanelCtr != null)
|
|
{
|
|
// 主要用于红点更新
|
|
acaciaTreePanelCtr.PreInit();
|
|
}
|
|
|
|
if(marryCopyPanelCtr != null)
|
|
{
|
|
marryCopyPanelCtr.PreInit();
|
|
}
|
|
|
|
// 添加监听
|
|
Hashtable add = new Hashtable();
|
|
add["name"] = "diamondsUpdate";
|
|
Games.Events.MessageEventCallBack call = ringPanelCtr.UpdataRedTips;
|
|
add["callFun"] = call;
|
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FRESHSAMEUSETIP, add);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "diamondsUpdate");
|
|
}
|
|
#region
|
|
public List<GameObject> panelLists;
|
|
public RingPanelCtr ringPanelCtr;
|
|
public FetterPanelCtr fetterPanelCtr;
|
|
public AcaciaTreePanelCtr acaciaTreePanelCtr;
|
|
public MarryCopyPanelCtr marryCopyPanelCtr;
|
|
|
|
#endregion
|
|
|
|
|
|
public void OnCloseBtnClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MarryRoot);
|
|
}
|
|
|
|
#region 红点更新
|
|
|
|
// 左侧菜单的红点更新应由子页面驱动更新
|
|
public void UpdateRedTips(RedTipType tipType, bool isActive)
|
|
{
|
|
if((int)tipType > (int)RedTipType.Copy)
|
|
{
|
|
LogModule.ErrorLog("Try to Update red tip in MarryRoor.cs, but type is wrong !!!");
|
|
return;
|
|
}
|
|
|
|
if (redTips[(int)tipType] != null)
|
|
{
|
|
// 戒指不需要判断是否结婚
|
|
if(tipType == RedTipType.Ring)
|
|
{
|
|
redTips[(int)tipType].SetActive(isActive);
|
|
}
|
|
// 其他需要再结婚的情况下才显示红点
|
|
else if (GameManager.gameManager.PlayerDataPool.IsMarried)
|
|
{
|
|
redTips[(int)tipType].SetActive(isActive);
|
|
}
|
|
else
|
|
{
|
|
redTips[(int)tipType].SetActive(false);
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < redTips.Count; ++i)
|
|
{
|
|
if (redTips[i] != null && redTips[i].activeSelf)
|
|
{
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.Marry, true);
|
|
return;
|
|
}
|
|
}
|
|
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.Marry, false);
|
|
return;
|
|
}
|
|
|
|
// 主动检测
|
|
private static bool ringHasRed = false;
|
|
private static bool fetterHasRed = false;
|
|
private static bool acaciaHasRed = false;
|
|
private static bool marryCopyHasRed = false;
|
|
public static void UpdateRedTips(bool isCopyShow = false)
|
|
{
|
|
if (RingPanelCtr.Instance && RingPanelCtr.Instance.isActiveAndEnabled)
|
|
RingPanelCtr.Instance.UpdataRedTips();
|
|
if (FetterPanelCtr.Instance && FetterPanelCtr.Instance.isActiveAndEnabled)
|
|
FetterPanelCtr.Instance.UpdataRedTips();
|
|
if (AcaciaTreePanelCtr.Instance && AcaciaTreePanelCtr.Instance.isActiveAndEnabled)
|
|
AcaciaTreePanelCtr.Instance.UpdataRedTips();
|
|
ringHasRed = RingPanelCtr.HasRedPoint();
|
|
fetterHasRed = FetterPanelCtr.HasRedPoint();
|
|
acaciaHasRed = AcaciaTreePanelCtr.HasRedPoint();
|
|
MarryCopyPanelCtr.HasRedPoint();
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.Marry, ringHasRed || fetterHasRed || acaciaHasRed || marryCopyHasRed);
|
|
}
|
|
|
|
public static void RefreshRedTip(bool isShow)
|
|
{
|
|
marryCopyHasRed = isShow;
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.Marry, ringHasRed || fetterHasRed || acaciaHasRed || marryCopyHasRed);
|
|
}
|
|
|
|
#endregion
|
|
}
|