You've already forked taptap2024_GJ_chidouren
92 lines
2.8 KiB
C#
92 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.RandomPool;
|
|
using System.Utils;
|
|
using Framework.Timer;
|
|
using Game.Data;
|
|
using UnityEngine;
|
|
|
|
namespace Game.Component
|
|
{
|
|
public class CardEffectShower : DoubleCardEntity
|
|
{
|
|
private static readonly Dictionary<CardQuality , Color> _COLORS = new Dictionary<CardQuality, Color>
|
|
{
|
|
{CardQuality.N , new Color (0.86f, 0.91f, 1f)},
|
|
{CardQuality.R , new Color (0.23f, 0.65f, 1f)},
|
|
{CardQuality.SR , new Color (0.73f, 0.31f, 1f)},
|
|
{CardQuality.SSR , new Color (1f, 0.47f, 0.07f)},
|
|
{CardQuality.UR , new Color (1f, 0.95f, 0f)},
|
|
{CardQuality.SP , new Color (1f, 0.26f, 0.3f)},
|
|
};
|
|
|
|
[SerializeField] private List<CardEffectNode> _effectNodes;
|
|
[SerializeField] private float _openDelay;
|
|
[SerializeField] private float _openDuration;
|
|
[SerializeField] private MultiGraphicControl _graphicControl;
|
|
|
|
private TimeHandler _timeHandler;
|
|
private CardQuality _quality;
|
|
private Action _callback;
|
|
|
|
|
|
public void Init (CardQuality quality , Transform cameraTransform)
|
|
{
|
|
ResetNode ();
|
|
this.Init (cameraTransform , -1);
|
|
this._quality = quality;
|
|
}
|
|
|
|
public void ClickOpen (Action action)
|
|
{
|
|
this._callback = action;
|
|
if (this._timeHandler != null && this._timeHandler.IsPlaying)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CheckEffectNode (CardEffectNode.EffectAnimState.StartShow);
|
|
this._timeHandler = GameUpdateMgr.Instance.CreateTimer (this._openDelay , () =>
|
|
{
|
|
this.ToFore (this._openDuration , ShowCardComplete);
|
|
});
|
|
}
|
|
|
|
public void NotAnimOpen (Action action)
|
|
{
|
|
this._callback = action;
|
|
this.ToFore (0 , ShowCardComplete);
|
|
}
|
|
|
|
public void ClickClose ()
|
|
{
|
|
ResetNode ();
|
|
this.ToBreak (0);
|
|
}
|
|
|
|
private void ShowCardComplete ()
|
|
{
|
|
this._graphicControl.gameObject.SetActive (true);
|
|
this._graphicControl.SetColor (_COLORS[this._quality]);
|
|
CheckEffectNode (CardEffectNode.EffectAnimState.Opened);
|
|
this._callback?.Invoke ();
|
|
}
|
|
|
|
private void CheckEffectNode (CardEffectNode.EffectAnimState state)
|
|
{
|
|
foreach (var effectNode in this._effectNodes)
|
|
{
|
|
effectNode.CheckNode (state , this._quality);
|
|
}
|
|
}
|
|
|
|
private void ResetNode ()
|
|
{
|
|
foreach (var effectNode in this._effectNodes)
|
|
{
|
|
effectNode.ResetNode ();
|
|
}
|
|
this._graphicControl.gameObject.SetActive (false);
|
|
}
|
|
}
|
|
} |