101 lines
2.0 KiB
C#
101 lines
2.0 KiB
C#
using UnityEngine;
|
|
|
|
public class MyPageCardPanelAnimation : MonoBehaviour
|
|
{
|
|
public enum State
|
|
{
|
|
Start,
|
|
End
|
|
}
|
|
|
|
private float ClickRotateTime;
|
|
|
|
private bool _isCutCardMotion;
|
|
|
|
private State _state = State.End;
|
|
|
|
private float _timer;
|
|
|
|
private float[] _randomTimer;
|
|
|
|
private int[] _randomDir;
|
|
|
|
private GameObject[] _cardPanel;
|
|
|
|
private UIPanel[] _panel;
|
|
|
|
private Vector3[] _defaultPosition;
|
|
|
|
public void SetCardPanelList(GameObject[] list)
|
|
{
|
|
_cardPanel = new GameObject[list.Length];
|
|
for (int i = 0; i < list.Length; i++)
|
|
{
|
|
_cardPanel[i] = list[i];
|
|
MyPageCardPanel component = list[i].GetComponent<MyPageCardPanel>();
|
|
if (component != null)
|
|
{
|
|
component.Index = i;
|
|
}
|
|
}
|
|
InitRandom();
|
|
InitializePanel();
|
|
}
|
|
|
|
public void UpdateCardPanelDefaultPosition(Vector3[] newPosition)
|
|
{
|
|
_defaultPosition = newPosition;
|
|
}
|
|
|
|
private void InitializePanel()
|
|
{
|
|
if (_panel == null)
|
|
{
|
|
_panel = new UIPanel[_cardPanel.Length];
|
|
_defaultPosition = new Vector3[_cardPanel.Length];
|
|
for (int i = 0; i < _cardPanel.Length; i++)
|
|
{
|
|
GameObject gameObject = _cardPanel[i];
|
|
_panel[i] = gameObject.GetComponent<UIPanel>();
|
|
_defaultPosition[i] = gameObject.transform.localPosition;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ColorChange(bool isForceOpacity = false)
|
|
{
|
|
if (_panel == null)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < _cardPanel.Length; i++)
|
|
{
|
|
if (_panel[i].alpha < 1f && !isForceOpacity)
|
|
{
|
|
float alpha = _panel[i].alpha;
|
|
alpha += Time.deltaTime * 4f;
|
|
if (alpha >= 1f)
|
|
{
|
|
alpha = 1f;
|
|
}
|
|
_panel[i].alpha = alpha;
|
|
}
|
|
else
|
|
{
|
|
_panel[i].alpha = 1f;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void InitRandom()
|
|
{
|
|
_randomDir = new int[_cardPanel.Length];
|
|
_randomTimer = new float[_cardPanel.Length];
|
|
for (int i = 0; i < _cardPanel.Length; i++)
|
|
{
|
|
_randomDir[i] = (((double)Random.value > 0.5) ? 1 : (-1));
|
|
_randomTimer[i] = Random.Range(-0.3f, 0f);
|
|
}
|
|
}
|
|
}
|