//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, March 28, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
|
namespace Snxxz.UI
|
{
|
|
public class MainWinTopGrid : MonoBehaviour
|
{
|
[SerializeField] bool m_AlwayShow;
|
[SerializeField] int m_FunctionId;
|
[SerializeField] OpenServerActivityCenter.OSActivityType m_OpenServerActivityType = OpenServerActivityCenter.OSActivityType.max;
|
[SerializeField] bool m_IsAnyOpenServerActivity = false;
|
[SerializeField] Operation m_OperationActivityType = Operation.max;
|
|
[SerializeField] RectTransform m_Content;
|
[SerializeField] CanvasGroup m_CanvasGroup;
|
[SerializeField] IsPlayerUIeffect m_IsPlayerUIeffect;
|
|
public RectTransform rectTransform { get { return this.transform as RectTransform; } }
|
public bool alwayShow { get { return m_AlwayShow; } }
|
|
float targetY = 0f;
|
float targetAlpha = 0f;
|
|
public void Switch(bool active, float offset, float delay)
|
{
|
if (m_AlwayShow)
|
{
|
return;
|
}
|
|
targetY = active ? 0 : (120f + offset);
|
targetAlpha = active ? 1f : 0f;
|
|
if (active)
|
{
|
m_Content.DOLocalMoveY(targetY, 0.5f).SetDelay(delay).SetEase(Ease.OutSine).OnComplete(PlayerUIEffect);
|
}
|
else
|
{
|
m_Content.DOLocalMoveY(targetY, 0.5f).SetDelay(delay).SetEase(Ease.InSine).OnStart(StopUIEffect);
|
}
|
|
m_CanvasGroup.DOFade(targetAlpha, 0.5f).SetDelay(delay).SetEase(active ? Ease.OutSine : Ease.InSine);
|
m_CanvasGroup.blocksRaycasts = active;
|
}
|
|
public void SwitchImmediately(bool active, float offset)
|
{
|
if (m_AlwayShow)
|
{
|
return;
|
}
|
|
targetY = active ? 0 : (120f + offset);
|
targetAlpha = active ? 1f : 0f;
|
m_Content.anchoredPosition = m_Content.anchoredPosition.SetY(targetY);
|
m_CanvasGroup.alpha = targetAlpha;
|
m_CanvasGroup.blocksRaycasts = active;
|
|
if (active)
|
{
|
PlayerUIEffect();
|
}
|
else
|
{
|
StopUIEffect();
|
}
|
}
|
|
public bool IsOpen()
|
{
|
if (m_FunctionId > 0)
|
{
|
return FuncOpen.Instance.IsFuncOpen(m_FunctionId);
|
}
|
|
if (m_OpenServerActivityType != OpenServerActivityCenter.OSActivityType.max)
|
{
|
return OpenServerActivityCenter.Instance.IsActivityOpen((int)m_OpenServerActivityType);
|
}
|
|
if (m_IsAnyOpenServerActivity)
|
{
|
var functionOrder = 0;
|
return OpenServerActivityCenter.Instance.IsAnyActivityOpen(out functionOrder);
|
}
|
|
if (m_OperationActivityType != Operation.max)
|
{
|
return OperationTimeHepler.Instance.SatisfyOpenCondition(m_OperationActivityType);
|
}
|
|
return false;
|
}
|
|
private void PlayerUIEffect()
|
{
|
if (m_IsPlayerUIeffect != null)
|
{
|
m_IsPlayerUIeffect.StartPlayUIEffect();
|
}
|
}
|
|
private void StopUIEffect()
|
{
|
if (m_IsPlayerUIeffect != null)
|
{
|
m_IsPlayerUIeffect.ObtainPlayUIEffect();
|
}
|
}
|
|
}
|
|
}
|