117 lines
2.6 KiB
C#
117 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cute;
|
|
using UnityEngine;
|
|
|
|
public class MyPageItem : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private MyPageCardPanelAnimation _cardMove;
|
|
|
|
[SerializeField]
|
|
private MyPageCardPanel[] _cardPanelList;
|
|
|
|
private MyPageMenu _parent;
|
|
|
|
private Dictionary<int, Vector3> _defaultPosition = new Dictionary<int, Vector3>();
|
|
|
|
private bool cardAnimationInitialized;
|
|
|
|
protected MyPageCardPanelAnimation CardAnimation => _cardMove;
|
|
|
|
protected MyPageMenu Parent => _parent;
|
|
|
|
public bool IsEnableFooterCurrentMenu { get; set; }
|
|
|
|
public virtual void Initialize(MyPageMenu parent)
|
|
{
|
|
_parent = parent;
|
|
SaveCardPanelDefaultPosition();
|
|
if (cardAnimationInitialized)
|
|
{
|
|
return;
|
|
}
|
|
cardAnimationInitialized = true;
|
|
if (_cardMove != null)
|
|
{
|
|
GameObject[] array = new GameObject[_cardPanelList.Length];
|
|
for (int i = 0; i < _cardPanelList.Length; i++)
|
|
{
|
|
array[i] = _cardPanelList[i].gameObject;
|
|
}
|
|
_cardMove.SetCardPanelList(array);
|
|
}
|
|
}
|
|
|
|
public virtual void Show(bool skipCardAnimation = false)
|
|
{
|
|
base.gameObject.SetActive(value: true);
|
|
IsEnableFooterCurrentMenu = false;
|
|
}
|
|
|
|
public virtual void Hide()
|
|
{
|
|
base.gameObject.SetActive(value: false);
|
|
}
|
|
|
|
protected void SaveCardPanelDefaultPosition()
|
|
{
|
|
int num = _cardPanelList.Length;
|
|
if (num > 0)
|
|
{
|
|
Vector3[] array = new Vector3[num];
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
array[i] = _cardPanelList[i].SavePosition();
|
|
}
|
|
CardAnimation.UpdateCardPanelDefaultPosition(array);
|
|
}
|
|
}
|
|
|
|
public virtual void OnMyPageInfoReceive()
|
|
{
|
|
if (_cardPanelList == null)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < _cardPanelList.Length; i++)
|
|
{
|
|
if (_cardPanelList[i] != null)
|
|
{
|
|
_cardPanelList[i].CheckMaintenanceType();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void RemoveITween(GameObject obj)
|
|
{
|
|
iTween component = obj.GetComponent<iTween>();
|
|
if (component != null)
|
|
{
|
|
UnityEngine.Object.Destroy(component);
|
|
}
|
|
}
|
|
|
|
protected void TweenMoveTo(GameObject obj, float x)
|
|
{
|
|
RemoveITween(obj);
|
|
iTween.MoveTo(obj, iTween.Hash("x", x, "time", 0.3f, "delay", 0.1f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
|
|
}
|
|
|
|
protected void FadeOutCardPanel(MyPageCardPanel panel, Action onFinish)
|
|
{
|
|
panel.EffectActive = false;
|
|
FadeOutObject(panel.gameObject.AddMissingComponent<UITweenAlpha>(), delegate
|
|
{
|
|
onFinish.Call();
|
|
});
|
|
}
|
|
|
|
protected static void FadeOutObject(UITweenAlpha tweenAlpha, Action onFinish = null)
|
|
{
|
|
tweenAlpha.End();
|
|
FadeUtility.FadeOutObject(tweenAlpha, onFinish);
|
|
}
|
|
}
|