using UnityEngine;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
|
//主界面的右边栏缩进功能
|
public class RightFuncInHome : MonoBehaviour
|
{
|
|
[SerializeField] ClickScreenOtherSpaceEvent clickScreenOtherSpaceEvent;
|
[SerializeField] RectTransform funcCol;
|
[SerializeField] RectTransform showPoint;
|
[SerializeField] RectTransform hidePoint;
|
[SerializeField] Button closeBtn;
|
[SerializeField] Button storeBtn;
|
[SerializeField] Button monthCardBtn;
|
[SerializeField] Button dayMissionBtn;
|
|
static string listenWindowName = ""; //监听关闭时再显示
|
|
bool isShow = false;
|
void Awake()
|
{
|
monthCardBtn.AddListener(() =>
|
{
|
//用于监听界面,打开时缩进右边功能栏,关闭时显示
|
// ListenWindow("");
|
InvestModel.Instance.BuyInvest(InvestModel.monthCardType);
|
});
|
storeBtn.AddListener(() =>
|
{
|
//用于监听界面,打开时缩进右边功能栏,关闭时显示
|
ListenWindow("StoreBaseWin");
|
UIManager.Instance.OpenWindow<StoreBaseWin>();
|
});
|
|
clickScreenOtherSpaceEvent.AddListener(() =>
|
{
|
if (isShow)
|
{
|
isShow = !isShow;
|
ShowFuncCol(isShow);
|
}
|
});
|
closeBtn.AddListener(() =>
|
{
|
ShowFuncCol(false);
|
});
|
|
UIManager.Instance.OnCloseWindow -= OnCloseWindow;
|
UIManager.Instance.OnCloseWindow += OnCloseWindow;
|
|
dayMissionBtn.AddListener(() =>
|
{
|
//用于监听界面,打开时缩进右边功能栏,关闭时显示
|
ListenWindow("DayMissionBaseWin");
|
UIManager.Instance.OpenWindow<DayMissionBaseWin>();
|
});
|
}
|
|
void ShowBtns()
|
{
|
storeBtn.SetActive(FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store));
|
dayMissionBtn.SetActive(FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.DayMission));
|
}
|
|
|
//显隐功能栏
|
public void ShowFuncCol(bool _isShow)
|
{
|
isShow = _isShow;
|
funcCol.DOLocalMove(isShow ? showPoint.localPosition : hidePoint.localPosition, 0.3f);
|
if (isShow)
|
{
|
ShowBtns();
|
}
|
}
|
|
void OnCloseWindow(UIBase win)
|
{
|
if (win.name == listenWindowName)
|
{
|
ShowFuncCol(true);
|
listenWindowName = "";
|
}
|
}
|
|
//用于监听界面,打开时缩进右边功能栏,关闭时显示
|
void ListenWindow(string _listenWindowName)
|
{
|
ShowFuncCol(false);
|
listenWindowName = _listenWindowName;
|
}
|
|
public static void RemoveListenWindow()
|
{
|
listenWindowName = "";
|
}
|
|
}
|