//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Sunday, April 28, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class ReikiFuncOpenWin : Window
|
{
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
[SerializeField] UIAlphaTween m_AlphaTween1;
|
[SerializeField] Transform m_ContainerReikiIcon;
|
[SerializeField] Transform m_ContainerFly;
|
[SerializeField] UIEffect m_Effect;
|
[SerializeField] Transform[] m_FlyIcons;
|
[SerializeField] float m_OpenTime = 2f;
|
|
bool displayAnimation = false;
|
|
public static Action onFlyComplete;
|
|
float timer = 0f;
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
timer = 0f;
|
|
displayAnimation = false;
|
|
m_AlphaTween.SetStartState();
|
m_AlphaTween1.SetStartState();
|
m_ContainerReikiIcon.gameObject.SetActive(true);
|
m_ContainerFly.gameObject.SetActive(false);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
StopAllCoroutines();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
if (displayAnimation)
|
{
|
return;
|
}
|
timer += Time.deltaTime;
|
if (timer >= m_OpenTime)
|
{
|
displayAnimation = true;
|
StartAnimation();
|
}
|
}
|
#endregion
|
|
void StartAnimation()
|
{
|
m_AlphaTween.Play();
|
m_AlphaTween1.Play();
|
|
StartCoroutine(Co_Fly());
|
}
|
|
IEnumerator Co_Fly()
|
{
|
yield return WaitingForSecondConst.GetWaitForSeconds(m_AlphaTween.delay);
|
|
m_Effect.Play();
|
|
yield return null;
|
|
m_ContainerReikiIcon.gameObject.SetActive(false);
|
m_ContainerFly.gameObject.SetActive(true);
|
var parent = m_Effect.target.transform.Find("Animation/B/JIN");
|
SetParent(m_FlyIcons[0], parent, Vector3.one);
|
parent = m_Effect.target.transform.Find("Animation/B/MU");
|
SetParent(m_FlyIcons[1], parent, Vector3.one);
|
parent = m_Effect.target.transform.Find("Animation/B/SHUI");
|
SetParent(m_FlyIcons[2], parent, Vector3.one);
|
parent = m_Effect.target.transform.Find("Animation/B/HUO");
|
SetParent(m_FlyIcons[3], parent, Vector3.one);
|
parent = m_Effect.target.transform.Find("Animation/B/TU");
|
SetParent(m_FlyIcons[4], parent, Vector3.one);
|
|
yield return WaitingForSecondConst.WaitMS500;
|
for (int i = 0; i < m_FlyIcons.Length; i++)
|
{
|
SetParent(m_FlyIcons[i], m_ContainerFly, Vector3.zero);
|
}
|
|
yield return WaitingForSecondConst.WaitMS800;
|
if (onFlyComplete != null)
|
{
|
onFlyComplete();
|
}
|
|
yield return WaitingForSecondConst.WaitMS2000;
|
CloseClick();
|
}
|
|
void SetParent(Transform source, Transform dest, Vector3 scale)
|
{
|
source.SetParentEx(dest, Vector3.zero, Quaternion.identity, scale);
|
}
|
}
|
|
}
|
|
|
|
|