using System.Collections.Generic;
using System.Linq;
using Cute;
using UnityEngine;

namespace Wizard;

public class ReplaySkipAnimation : MonoBehaviour
{
	[SerializeField]
	private UISprite TitleSkip;

	[SerializeField]
	private UITexture Bg;

	[SerializeField]
	private UITexture FieldHideBg;

	[SerializeField]
	private UIPanel MainPanel;

	[SerializeField]
	private UISprite ArcaneIn;

	[SerializeField]
	private UISprite ArcaneOut;

	private List<string> _loadFileList = new List<string>();

	private GameObject _effectObject;

	private const int LOADING_LAYER = 26;

	private const string REPLAY_SKIP_EFFECT = "cmn_replay_skipping_1";

	public const float FADE_IN_TIME = 0.1f;

	public const float FADE_OUT_TIME = 0.1f;

	public void SetUp()
	{
		ArcaneIn.alpha = 0f;
		ArcaneOut.alpha = 0f;
		ArcaneIn.transform.localScale = Vector3.one;
		ArcaneOut.transform.localScale = Vector3.one;
		Bg.alpha = 0f;
		FieldHideBg.alpha = 0f;
		UIAtlas atlas = UIManager.GetInstance().GetAtlasList().FirstOrDefault((UIAtlas s) => s.name == "BattleLang");
		TitleSkip.atlas = atlas;
		TitleSkip.spriteName = "result_text_skipping";
		_loadFileList = new List<string> { Toolbox.ResourcesManager.GetAssetTypePath("cmn_replay_skipping_1", ResourcesManager.AssetLoadPathType.Effect2D) };
		StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(_loadFileList, delegate
		{
			_effectObject = Object.Instantiate(Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("cmn_replay_skipping_1", ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true)) as GameObject);
			_effectObject.transform.SetParent(base.gameObject.transform);
			_effectObject.SetLayer(26, isSetChildren: true);
			_effectObject.transform.localPosition = Vector3.zero;
			_loadFileList.AddRange(GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(_effectObject, null));
			_effectObject.SetActive(value: false);
		}));
		base.gameObject.SetLayer(26, isSetChildren: true);
		Bg.gameObject.SetActive(value: false);
		FieldHideBg.gameObject.SetActive(value: false);
	}

	public void Unload()
	{
		Toolbox.ResourcesManager.RemoveAssetGroup(_loadFileList);
		_loadFileList.Clear();
	}

	public void Run()
	{
		Bg.gameObject.SetActive(value: true);
		FieldHideBg.gameObject.SetActive(value: true);
		FieldHideBg.alpha = 0f;
		TitleSkip.gameObject.SetActive(value: true);
		TitleSkip.transform.localScale = Vector3.one;
		TitleSkip.alpha = 0f;
		Bg.color = new Color32(0, 102, 153, 0);
		MainPanel.alpha = 1f;
		ArcaneIn.gameObject.SetActive(value: true);
		ArcaneOut.gameObject.SetActive(value: true);
		_effectObject.SetActive(value: true);
		TweenAlpha.Begin(TitleSkip.gameObject, 0.1f, 1f);
		TweenAlpha.Begin(Bg.gameObject, 0.1f, 0.25f);
		TweenAlpha.Begin(FieldHideBg.gameObject, 0.1f, 1f);
		TweenAlpha.Begin(ArcaneIn.gameObject, 0.1f, 0.75f);
		TweenAlpha.Begin(ArcaneOut.gameObject, 0.1f, 1f);
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_REPLAY_TURN_SKIPPING);
	}

	public void End()
	{
		TweenAlpha.Begin(TitleSkip.gameObject, 0.1f, 0f);
		TweenAlpha.Begin(Bg.gameObject, 0.1f, 0f);
		TweenAlpha.Begin(FieldHideBg.gameObject, 0.1f, 0f);
		TweenAlpha.Begin(ArcaneIn.gameObject, 0.1f, 0f);
		TweenAlpha.Begin(ArcaneOut.gameObject, 0.1f, 0f);
		_effectObject.SetActive(value: false);
	}

	public void Hide()
	{
		Bg.gameObject.SetActive(value: false);
		FieldHideBg.gameObject.SetActive(value: false);
		TitleSkip.gameObject.SetActive(value: false);
		ArcaneIn.gameObject.SetActive(value: false);
		ArcaneOut.gameObject.SetActive(value: false);
	}
}
