You've already forked taptap2024_GJ_chidouren
109 lines
3.2 KiB
C#
109 lines
3.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.RandomPool;
|
|||
|
|
using Coffee.UIExtensions;
|
|||
|
|
using Game.Data;
|
|||
|
|
using Sirenix.OdinInspector;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Game.Component
|
|||
|
|
{
|
|||
|
|
[Serializable]
|
|||
|
|
public class CardEffectNode : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public enum EffectAnimState
|
|||
|
|
{
|
|||
|
|
Close = 0, //卡牌背面状态
|
|||
|
|
StartShow, //点击翻开
|
|||
|
|
Opened //完成翻转
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[SerializeField] private bool HasUIParticle;
|
|||
|
|
|
|||
|
|
[SerializeField, HideIf ("HasUIParticle")]
|
|||
|
|
private ParticleSystem Effect;
|
|||
|
|
|
|||
|
|
[SerializeField, ShowIf ("HasUIParticle")]
|
|||
|
|
private UIParticle UiEffect;
|
|||
|
|
|
|||
|
|
[SerializeField] private EffectAnimState State;
|
|||
|
|
[SerializeField] private CardQuality Quality;
|
|||
|
|
[SerializeField] private bool IsSoleQuality; //是否唯一展示
|
|||
|
|
[SerializeField] private bool IsCloseActive; //是否在不满足指定State状态下,主动关闭当前特效的GameObject.Active状态
|
|||
|
|
[SerializeField] private bool OverlyColor;
|
|||
|
|
|
|||
|
|
|
|||
|
|
[SerializeField, ShowIf ("OverlyColor")]
|
|||
|
|
private Color[] QualityColors;
|
|||
|
|
|
|||
|
|
private GameObject EffectObject => this.HasUIParticle ? this.UiEffect.gameObject : this.Effect.gameObject;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void CheckNode (EffectAnimState state , CardQuality quality)
|
|||
|
|
{
|
|||
|
|
if (state == this.State)
|
|||
|
|
{
|
|||
|
|
if (this.OverlyColor)
|
|||
|
|
{
|
|||
|
|
if (this.HasUIParticle)
|
|||
|
|
{
|
|||
|
|
this.UiEffect.color = this.QualityColors[(int)quality];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
var effectMain = this.Effect.main;
|
|||
|
|
effectMain.startColor = new ParticleSystem.MinMaxGradient (this.QualityColors[(int)quality]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!this.IsSoleQuality && (int)quality >= (int)this.Quality)
|
|||
|
|
{
|
|||
|
|
SetActive (true);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (this.IsSoleQuality && quality == this.Quality)
|
|||
|
|
{
|
|||
|
|
SetActive (true);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (this.IsCloseActive)
|
|||
|
|
{
|
|||
|
|
SetActive (false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetActive (bool isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
this.EffectObject.gameObject.SetActive (true);
|
|||
|
|
if (this.HasUIParticle)
|
|||
|
|
{
|
|||
|
|
this.UiEffect.Stop ();
|
|||
|
|
this.UiEffect.Play ();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Effect.Stop();
|
|||
|
|
this.Effect.Simulate (0 , false , true);
|
|||
|
|
// this.Effect.Play (false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.EffectObject.gameObject.SetActive (false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ResetNode ()
|
|||
|
|
{
|
|||
|
|
var effectGameObject = this.EffectObject;
|
|||
|
|
if (effectGameObject.activeSelf)
|
|||
|
|
{
|
|||
|
|
effectGameObject.SetActive (false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|