using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.Battle.View;

public class CardDetailUI : UIBase
{
	private class CardVoiceData
	{
		private const string ACC_CARD_ID_GROUP = "ACC_CARD_ID";

		private const string ACC_CARD_ID_REGEX = "card_id=(?<ACC_CARD_ID>80\\d*)";

		public readonly string MainVoiceId;

		public readonly List<string> _acceleratedVoiceIdList = new List<string>();

		public readonly List<string> _voiceListBeforeEvo;

		public readonly List<string> _voiceListAfterEvo;

		private CardMaster.CardMasterId _cardMasterId;

		private List<VoiceDictionary> _splitVoiceList;

		public CardVoiceData(CardParameter cardParam, CardMaster.CardMasterId cardMasterId)
		{
			_cardMasterId = cardMasterId;
			VoiceDictionaries voiceDictionaries = new VoiceDictionaries(cardParam.CardId, _cardMasterId);
			MainVoiceId = voiceDictionaries.VoiceId;
			List<string> list = new List<string>();
			List<string> normalPlayVoices = voiceDictionaries.GetNormalPlayVoices();
			list.AddRange(normalPlayVoices);
			list.AddRange(voiceDictionaries.atkVoices.GetAllVoiceList());
			list.AddRange(voiceDictionaries.destroyVoices.GetAllVoiceList());
			AddVoiceList(list, voiceDictionaries.skillVoices);
			SkillOptionValue skillOptionValue = new SkillOptionValue(cardParam.SkillOption);
			string option = skillOptionValue.GetOption(SkillFilterCreator.ContentKeyword.skill);
			if (!string.IsNullOrEmpty(option))
			{
				Skill_attach_skill.AttachOptionInfo attachOptionInfo = new Skill_attach_skill.AttachOptionInfo(option);
				if (attachOptionInfo.Voice != string.Empty)
				{
					VoiceDictionary item = new VoiceDictionary(attachOptionInfo.Voice);
					voiceDictionaries.attachSkillVoices.Add(item);
				}
			}
			bool flag = skillOptionValue.GetOption(SkillFilterCreator.ContentKeyword.is_evolve, "false") == "true";
			if (voiceDictionaries.attachSkillVoices.Count > 0 && !flag)
			{
				AddVoiceList(list, voiceDictionaries.attachSkillVoices, list);
			}
			MatchCollection matchCollection = new Regex("card_id=(?<ACC_CARD_ID>80\\d*)").Matches(cardParam.SkillOption);
			_acceleratedVoiceIdList.Clear();
			for (int i = 0; i < matchCollection.Count; i++)
			{
				VoiceDictionaries voiceDictionaries2 = new VoiceDictionaries(int.Parse(matchCollection[i].Groups["ACC_CARD_ID"].Value), _cardMasterId);
				list.AddRange(voiceDictionaries2.playVoices.GetAllVoiceList());
				string voiceId = voiceDictionaries2.VoiceId;
				if (!string.IsNullOrEmpty(voiceId))
				{
					_acceleratedVoiceIdList.Add(voiceId);
				}
			}
			_voiceListBeforeEvo = GetPlayableVoiceList(list);
			List<string> list2 = new List<string>();
			list2.AddRange(voiceDictionaries.evoVoices.GetAllVoiceList());
			list2.AddRange(voiceDictionaries.evoAtkVoices.GetAllVoiceList());
			list2.AddRange(voiceDictionaries.evoDestroyVoices.GetAllVoiceList());
			AddVoiceList(list2, voiceDictionaries.evoSkillVoices, list);
			if (voiceDictionaries.attachSkillVoices.Count > 0 && flag)
			{
				AddVoiceList(list2, voiceDictionaries.attachSkillVoices, list2);
			}
			_voiceListAfterEvo = GetPlayableVoiceList(list2);
		}

		private List<string> GetPlayableVoiceList(List<string> voiceList)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < voiceList.Count; i++)
			{
				if (!Data.Master.CardDetailVoiceIgnoreList.Contains(voiceList[i]))
				{
					list.Add(voiceList[i]);
				}
			}
			return list;
		}

		private void AddVoiceList(List<string> tempVoiceList, List<VoiceDictionary> voices, List<string> normalVoiceList = null)
		{
			if (_splitVoiceList != null && normalVoiceList != null)
			{
				if (voices == null)
				{
					voices = _splitVoiceList;
				}
				else
				{
					for (int num = _splitVoiceList.Count - 1; num >= 0; num--)
					{
						voices.Insert(0, _splitVoiceList[num]);
					}
				}
			}
			if (voices == null || voices.Count <= 0)
			{
				return;
			}
			for (int i = 0; i < voices.Count; i++)
			{
				string[] allVoiceList = voices[i].GetAllVoiceList();
				foreach (string text in allVoiceList)
				{
					if (text.Contains("none") || tempVoiceList.Contains(text))
					{
						continue;
					}
					if (text.Contains('|'))
					{
						if (_splitVoiceList == null)
						{
							_splitVoiceList = new List<VoiceDictionary>();
							_splitVoiceList.Add(voices[i]);
						}
						else if (!_splitVoiceList.Contains(voices[i]))
						{
							_splitVoiceList.Add(voices[i]);
						}
						string[] array = text.Split('|');
						if (array.Length == 2)
						{
							string item = ((normalVoiceList == null) ? array[0] : array[1]);
							tempVoiceList.Add(item);
						}
					}
					else if (normalVoiceList == null)
					{
						tempVoiceList.Add(text);
					}
					else if (!normalVoiceList.Contains(text))
					{
						tempVoiceList.Add(text);
					}
				}
			}
		}
	}

	private class CardVoiceManager
	{
		private int _cardId;

		private bool _isPlayEvoVoice;

		private CardVoiceData _voiceData;

		private int _playIndex;

		private List<string> _playVoiceList;

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

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

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

		private const string VOICE_DATA_PREFIX = "vo_";

		public void SequentiallyPlay(CardParameter cardParam, bool isPlayEvoVoice, CardMaster.CardMasterId cardMasterId)
		{
			int cardId = cardParam.CardId;
			if (cardId == _cardId)
			{
				if (isPlayEvoVoice != _isPlayEvoVoice)
				{
					_isPlayEvoVoice = isPlayEvoVoice;
					_playIndex = 0;
					_playVoiceList = (isPlayEvoVoice ? _voiceData._voiceListAfterEvo : _voiceData._voiceListBeforeEvo);
				}
				else
				{
					_playIndex = (_playIndex + 1) % _playVoiceList.Count;
				}
				Stop();
				Play();
				return;
			}
			_cardId = cardId;
			_isPlayEvoVoice = isPlayEvoVoice;
			CardVoiceData voiceData = _voiceData;
			_voiceData = new CardVoiceData(cardParam, cardMasterId);
			_playIndex = 0;
			_playVoiceList = (isPlayEvoVoice ? _voiceData._voiceListAfterEvo : _voiceData._voiceListBeforeEvo);
			float unloadWaitTime = Stop();
			LoadAndUnload(_voiceData, voiceData, unloadWaitTime, delegate
			{
				Play();
			});
		}

		private void Play()
		{
			GameMgr.GetIns().GetSoundMgr().PlayVoiceScenario("vo_" + _playVoiceList[_playIndex]);
		}

		public float Stop()
		{
			return GameMgr.GetIns().GetSoundMgr().StopVoiceAll();
		}

		private void LoadAndUnload(CardVoiceData loadData, CardVoiceData unloadData, float unloadWaitTime = 0f, Action onFinishLoad = null)
		{
			_loadVoiceIdList.Clear();
			if (loadData != null)
			{
				_loadVoiceIdList.Add(loadData.MainVoiceId);
				_loadVoiceIdList.AddRange(loadData._acceleratedVoiceIdList);
				_loadVoiceIdList = _loadVoiceIdList.Distinct().ToList();
			}
			_unloadVoiceIdList.Clear();
			if (unloadData != null)
			{
				_unloadVoiceIdList.Add(unloadData.MainVoiceId);
				_unloadVoiceIdList.AddRange(unloadData._acceleratedVoiceIdList);
				_unloadVoiceIdList = _unloadVoiceIdList.Distinct().ToList();
			}
			List<string> list = _loadVoiceIdList.Intersect(_unloadVoiceIdList).ToList();
			if (list.Count > 0)
			{
				_loadVoiceIdList = _loadVoiceIdList.Except(list).ToList();
				_unloadVoiceIdList = _unloadVoiceIdList.Except(list).ToList();
			}
			SoundMgr soundMgr = GameMgr.GetIns().GetSoundMgr();
			int loadTargetCount = _loadVoiceIdList.Count;
			if (loadTargetCount <= 0)
			{
				onFinishLoad.Call();
			}
			else
			{
				int loadedCount = 0;
				for (int i = 0; i < loadTargetCount; i++)
				{
					string text = _loadVoiceIdList[i];
					soundMgr.LoadVoice("vo_" + text, delegate
					{
						if (++loadedCount == loadTargetCount)
						{
							onFinishLoad.Call();
						}
					});
				}
				_loadedVoiceIdList.AddRange(_loadVoiceIdList);
			}
			for (int num = 0; num < _unloadVoiceIdList.Count; num++)
			{
				string unloadId = _unloadVoiceIdList[num];
				UIManager.GetInstance().StartCoroutine(Timer.DelayMethod(unloadWaitTime, delegate
				{
					soundMgr.UnloadVoice("vo_" + unloadId);
				}));
				_loadedVoiceIdList.Remove(unloadId);
			}
		}

		public void UnloadAll(float unloadWaitTime = 0f)
		{
			SoundMgr soundMgr = GameMgr.GetIns().GetSoundMgr();
			for (int i = 0; i < _loadedVoiceIdList.Count; i++)
			{
				string unloadId = _loadedVoiceIdList[i];
				UIManager.GetInstance().StartCoroutine(Timer.DelayMethod(unloadWaitTime, delegate
				{
					soundMgr.UnloadVoice("vo_" + unloadId);
				}));
			}
			_loadedVoiceIdList.Clear();
		}
	}

	private static readonly string RELATION_CARD_DISABLE_CARD_ID_HEADER = "80";

	private static readonly int[] RELATION_CARD_BUTTON_DISABLE_CARD_IDS = new int[2] { 810014010, 810034010 };

	private readonly List<string> RELATION_CARD_SKILLOPTION_EXCLUDED_OPTIONS = new List<string> { "effect_path", "se_path", "skill_voice" };

	private readonly char[] RELATION_CARD_SKILLOPTION_SEPARATORS = new char[2] { '(', ')' };

	[SerializeField]
	private GameObject DarkPanel;

	[SerializeField]
	private GameObject Frame;

	[SerializeField]
	private GameObject CardTexture;

	[SerializeField]
	private GameObject CardNum;

	[SerializeField]
	private GameObject CardText;

	[SerializeField]
	private GameObject CardViewBG;

	[SerializeField]
	private GameObject CardShadow;

	[SerializeField]
	private GameObject UnitCardStatusObj;

	[SerializeField]
	private GameObject UnitCardIntroductionObj;

	[SerializeField]
	private GameObject SettingCardStatusObj;

	[SerializeField]
	private GameObject SettingCardIntroductionObj;

	[SerializeField]
	private GameObject SpellCardStatusObj;

	[SerializeField]
	private GameObject SpellCardIntroductionObj;

	[SerializeField]
	private UIScrollView UnitCardTextScrollView;

	[SerializeField]
	private UIScrollView SpellCardTextScrollView;

	[SerializeField]
	private UIScrollView SettingCardTextScrollView;

	[SerializeField]
	private UILabel UnitCardSkill;

	[SerializeField]
	private UILabel UnitCardEvoSkill;

	[SerializeField]
	private UILabel UnitCardAtkRight;

	[SerializeField]
	private UILabel UnitCardLifeRight;

	[SerializeField]
	private UILabel UnitCardEvoAtkRight;

	[SerializeField]
	private UILabel UnitCardEvoLifeRight;

	[SerializeField]
	private UILabel UnitCardIntroduction;

	[SerializeField]
	private UILabel SpellCardSkill;

	[SerializeField]
	private UILabel SpellCardIntroduction;

	[SerializeField]
	private UILabel SettingCardSkill;

	[SerializeField]
	private UILabel SettingCardIntroduction;

	[SerializeField]
	private GameObject ReturnButton;

	[SerializeField]
	private GameObject CardIntroductionButton;

	[SerializeField]
	private UIButton _favoriteButton;

	[SerializeField]
	private UIButton _voiceButton;

	[SerializeField]
	private GameObject CardEvolButton;

	[SerializeField]
	private UIButton _premiumCardConversionButton;

	[SerializeField]
	private GameObject RelationWrapperObj;

	[SerializeField]
	private GameObject RelationCardButton;

	[SerializeField]
	private GameObject RightButton;

	[SerializeField]
	private GameObject LeftButton;

	[SerializeField]
	private GameObject RelationBackButton;

	[SerializeField]
	private UILabel DialogTitleLabel;

	[SerializeField]
	private UILabel _cardNumLabel;

	[SerializeField]
	private UILabel _nameValueLabel;

	[SerializeField]
	private UILabel _classValueLabel;

	[SerializeField]
	private UILabel _typeValueLabel;

	[SerializeField]
	private UILabel _redEtherHaveValueLabel;

	[SerializeField]
	private UILabel _evolutionButtonLabel;

	[SerializeField]
	private GameObject _cardVoiceLabelRoot;

	[SerializeField]
	private UILabel _cardVoiceValueLabel;

	[SerializeField]
	private GameObject _cardSetLabelRoot;

	[SerializeField]
	private UILabel _cardSetValueLabel;

	[SerializeField]
	private GameObject RedEtherFrame;

	[SerializeField]
	private GameObject RedEtherIcon;

	[SerializeField]
	private GameObject QuestionMark;

	[SerializeField]
	private PurchaseConfirm PurchaseConfirmPrefab;

	[SerializeField]
	private PremiumCardConversionDialogParts _premiumCardConversionDialogPrefab;

	[SerializeField]
	private CardCraftPanel _craftPanel;

	[SerializeField]
	private UIPanel[] _allPanel;

	[SerializeField]
	private UIButton _blankColliderButton;

	private GameObject _rotationOnlyIconSpell;

	private GameObject _rotationOnlyIconFollower;

	private GameObject _rotationOnlyIconAmulet;

	private static readonly float kCARD_SCALE = 90f;

	private static readonly float kCARD_POS_Z = -4f;

	private readonly Vector3 CardViewScale = new Vector3(110f, 110f, 1f);

	private const float CARD_ANIMATION_TIME = 0.3f;

	private const float CARD_ROTATION = 0f;

	private static readonly Color CARD_LIQUEFY_PARTICLE_COLOR = new Color(1f, 0.2509804f, 0.2509804f);

	private static readonly Color CARD_CREATE_PARTICLE_COLOR = new Color(1f, 0.2509804f, 0.2509804f);

	private static readonly Color PREMIUM_CARD_CONVERSION_PARTICLE_COLOR = new Color(14f / 85f, 32f / 85f, 0.5568628f);

	private static readonly Vector3 CARD_DESTROY_PARTICLE_OFFSET = new Vector3(0f, 0f, -1f);

	private const string EVO_EFFECT_PATH = "cmn_deckedit_evo_1";

	private const float EVO_EFFECT_SCALE = 600f;

	private const float FAVORITE_BUTTON_INVALID_TIME = 0.9f;

	private const int PREMIUM_CARD_CONVERSION_PARTICLE_NUM = 4;

	private const int KEYWORD_DIALOG_DEPTH = 120;

	private const int KEYWORD_DIALOG_POSITION_Z = -5;

	private const int KEYWORD_DIALOG_POSITION_Y = 0;

	private static readonly Vector3 KEYWORD_DIALOG_BACK_VIEW_POSITION = new Vector3(0f, 0f, -5f);

	private GameObject UnitCardObject;

	private GameObject SpellCardObject;

	private GameObject FieldCardObject;

	private GameObject ViewCardObject;

	private UILabel UnitCost;

	private UILabel UnitAtk;

	private UILabel UnitLife;

	private UILabel UnitName;

	private UILabel SpellCost;

	private UILabel SpellName;

	private UILabel FieldCost;

	private UILabel FieldName;

	private BoxCollider UnitCardCollider;

	private BoxCollider SpellCardCollider;

	private BoxCollider FieldCardCollider;

	private bool _isFavorite;

	private bool _isFavoriteButtonEnabled;

	private bool _isEvolCard;

	private bool _isShowCardAblityText = true;

	private bool _shouldResetTextScrollView;

	private bool isCardViewMode;

	private bool isAnimation;

	[SerializeField]
	private TextLineCreater _cardSkillTextLineCreater;

	[SerializeField]
	private TextLineCreater _cardEvoSkillTextLineCreater;

	[SerializeField]
	private TextLineCreater _cardSpellTextLineCreater;

	[SerializeField]
	private TextLineCreater _cardAmuletTextLineCreater;

	[SerializeField]
	private GameObject _evolveInfoObjectRoot;

	[SerializeField]
	private UILabel _normalTitleLavel;

	private int _relationIndex;

	private List<int> _relationCardIds = new List<int>();

	private Dictionary<int, List<int>> _relationCardParentDict = new Dictionary<int, List<int>>();

	private GameObject _relationCardBaseGameObject;

	private int LayerDetail = 14;

	private bool isDetailOn;

	private ParticleSystem _evolEffect;

	private bool IsAnimationPlaying;

	private DialogBase _craftDialog;

	private DialogBase _keyWordDialog;

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

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

	private CardVoiceManager _cardVoiceManager = new CardVoiceManager();

	private bool _isAbleTapDialogObject = true;

	private static Shader _normalShader = null;

	private static Shader _premiumShader = null;

	private DialogBase _dialogForClose;

	private Material _cardMaterial;

	private int _originalCardId;

	private CardMaster.CardMasterId _cardMasterId;

	private UIButton[] _enableButtonList;

	private IFormatBehavior _formatBehaviorForCardPoolChange;

	public Action<int> OnCardSellId;

	public Action OnCardBuy;

	public Action OnClose;

	public Action<Vector2> OnDragCard;

	public Action<CardParameter> OnLiquefyAllCard;

	public Action OnChangeCardFavoriteState;

	public Action<CardParameter> OnConvertedPremiumCard;

	public Action OnCreateFirstCard;

	private bool _isCardTextDialogLayerSet = true;

	private bool _isOwnCardNum;

	public CardParameter CardData { get; private set; }

	public Action OnDetailCardUpdate { get; set; }

	public Action OnCardNumChange { get; set; }

	private bool IsAbleToCraft
	{
		get
		{
			if (PlayerStaticData.UserRedEtherCount >= CardData.UseRedEther && !CardData.IsFoil)
			{
				if (GetPossessionCardNum(isIncludingSpotCard: true) >= 3)
				{
					return GetPossessionCardNum() == 0;
				}
				return true;
			}
			return false;
		}
	}

	private bool IsAbleToDestruct => GetPossessionCardNum() > 0;

	public bool IsShowFlavorTextButton { get; set; }

	public bool IsShowFavoriteButton { get; set; }

	public bool IsShowVoiceButton { get; set; }

	public bool IsShowEvolutionButton { get; set; }

	public bool IsShowCraftButtons { get; set; }

	public bool IsShowPremiumCardConversionButton { get; set; }

	public bool IsPopularityVote { get; set; }

	public bool IsCardTextDialogLayerSet
	{
		get
		{
			return _isCardTextDialogLayerSet;
		}
		set
		{
			_isCardTextDialogLayerSet = value;
		}
	}

	public bool IsOwnCardNum
	{
		get
		{
			return _isOwnCardNum;
		}
		set
		{
			_isOwnCardNum = value;
		}
	}

	public bool IsShortageUI { get; set; }

	public bool IsRelationCardViewing => RelationWrapperObj.activeSelf;

	public bool LeftButtonVisible
	{
		set
		{
			LeftButton.SetActive(value);
		}
	}

	public bool RightButtonVisible
	{
		set
		{
			RightButton.SetActive(value);
		}
	}

	public bool IsEvolCard => _isEvolCard;

	public bool IsEnableShowDetail
	{
		get
		{
			if (IsAnimationPlaying)
			{
				return false;
			}
			return true;
		}
	}

	private void OnDisable()
	{
		if (isCardViewMode)
		{
			RemoveCardViewMode();
		}
		isDetailOn = false;
	}

	public void Hide()
	{
		base.gameObject.SetActive(value: false);
		if (_keyWordDialog != null)
		{
			_keyWordDialog.Close();
		}
		if (IsAnimationPlaying)
		{
			iTween.Stop(UnitCardObject);
			iTween.Stop(SpellCardObject);
			iTween.Stop(FieldCardObject);
			OnAnimationOver();
		}
		DestroyDialogObject();
	}

	protected override void OnDestroy()
	{
		Toolbox.ResourcesManager.RemoveAssetGroup(_assetPathList);
		_assetPathList.Clear();
		Toolbox.ResourcesManager.RemoveAssetGroup(_assetTokenPathList);
		_assetTokenPathList.Clear();
		float unloadWaitTime = _cardVoiceManager.Stop();
		_cardVoiceManager.UnloadAll(unloadWaitTime);
		if (_keyWordDialog != null)
		{
			_keyWordDialog.Close();
		}
		if (_cardMaterial != null)
		{
			UnityEngine.Object.Destroy(_cardMaterial);
		}
		DestroyDialogObject();
		base.OnDestroy();
	}

	private void DestroyDialogObject()
	{
		if (_dialogForClose != null)
		{
			UnityEngine.Object.Destroy(_dialogForClose.gameObject);
			_dialogForClose = null;
		}
	}

	public void Initialize(int DetailLayer, CardMaster.CardMasterId cardMasterId, IFormatBehavior formatBehaviorForCardPoolChange = null)
	{
		_formatBehaviorForCardPoolChange = formatBehaviorForCardPoolChange;
		ChangeCardMaster(cardMasterId);
		LayerDetail = DetailLayer;
		base.gameObject.layer = LayerDetail;
		InitializeCard();
		SetButtonEvent();
		SetDisableArrowButton();
		_enableButtonList = GetComponentsInChildren<UIButton>(includeInactive: true);
	}

	public void ChangeCardMaster(CardMaster.CardMasterId cardMasterId)
	{
		_cardMasterId = cardMasterId;
	}

	private void InitializeCard()
	{
		InitializeCardObject();
		InitializeCardMesh();
		InitializeCardDecoration();
	}

	private void InitializeCardObject()
	{
		UnitCardObject = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("Unit", ResourcesManager.AssetLoadPathType.HandCard, isfetch: true)) as GameObject;
		SpellCardObject = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("Spell", ResourcesManager.AssetLoadPathType.HandCard, isfetch: true)) as GameObject;
		FieldCardObject = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("Field", ResourcesManager.AssetLoadPathType.HandCard, isfetch: true)) as GameObject;
		UnitCardObject = NGUITools.AddChild(CardTexture, UnitCardObject);
		UnitCardObject.SetActive(value: false);
		SpellCardObject = NGUITools.AddChild(CardTexture, SpellCardObject);
		SpellCardObject.SetActive(value: false);
		FieldCardObject = NGUITools.AddChild(CardTexture, FieldCardObject);
		FieldCardObject.SetActive(value: false);
		Transform obj = SpellCardObject.transform;
		Vector3 localPosition = (FieldCardObject.transform.localPosition = new Vector3(0f, 0f, -500f));
		obj.localPosition = localPosition;
		UIManager.GetInstance().SetLayerRecursive(UnitCardObject.transform, LayerDetail);
		UIManager.GetInstance().SetLayerRecursive(SpellCardObject.transform, LayerDetail);
		UIManager.GetInstance().SetLayerRecursive(FieldCardObject.transform, LayerDetail);
		UnitCardCollider = UnitCardObject.AddComponent<BoxCollider>();
		SpellCardCollider = SpellCardObject.AddComponent<BoxCollider>();
		FieldCardCollider = FieldCardObject.AddComponent<BoxCollider>();
		BoxCollider unitCardCollider = UnitCardCollider;
		BoxCollider spellCardCollider = SpellCardCollider;
		Vector3 vector2 = (FieldCardCollider.size = new Vector3(3.6f, 5.5f, 1f));
		localPosition = (spellCardCollider.size = vector2);
		unitCardCollider.size = localPosition;
		UIWidget uIWidget = UnitCardObject.AddComponent<UIWidget>();
		UIWidget uIWidget2 = SpellCardObject.AddComponent<UIWidget>();
		UIWidget uIWidget3 = FieldCardObject.AddComponent<UIWidget>();
		int num = (uIWidget3.depth = 1);
		int depth = (uIWidget2.depth = num);
		uIWidget.depth = depth;
		GameObject prefab = Resources.Load("Prefab/CardDeco/RotationOnlyIcon") as GameObject;
		_rotationOnlyIconSpell = NGUITools.AddChild(SpellCardObject, prefab);
		_rotationOnlyIconFollower = NGUITools.AddChild(UnitCardObject, prefab);
		_rotationOnlyIconAmulet = NGUITools.AddChild(FieldCardObject, prefab);
	}

	private void InitializeCardMesh()
	{
		MeshFilter[] componentsInChildren = UnitCardObject.GetComponentsInChildren<MeshFilter>();
		Mesh sharedMesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_unit", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		Mesh sharedMesh2 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_unit_low", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		componentsInChildren[0].sharedMesh = sharedMesh;
		componentsInChildren[1].sharedMesh = sharedMesh2;
		Quaternion quaternion = Quaternion.Euler(0f, componentsInChildren[0].transform.rotation.y + 180f, 0f);
		Transform obj = componentsInChildren[0].transform;
		Quaternion rotation = (componentsInChildren[1].transform.rotation = quaternion);
		obj.rotation = rotation;
		MeshFilter[] componentsInChildren2 = SpellCardObject.GetComponentsInChildren<MeshFilter>();
		Mesh sharedMesh3 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		Mesh sharedMesh4 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell_low", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		componentsInChildren2[0].sharedMesh = sharedMesh3;
		componentsInChildren2[1].sharedMesh = sharedMesh4;
		Quaternion quaternion3 = Quaternion.Euler(0f, componentsInChildren2[0].transform.rotation.y + 180f, 0f);
		Transform obj2 = componentsInChildren2[0].transform;
		rotation = (componentsInChildren2[1].transform.rotation = quaternion3);
		obj2.rotation = rotation;
		MeshFilter[] componentsInChildren3 = FieldCardObject.GetComponentsInChildren<MeshFilter>();
		Mesh sharedMesh5 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_field", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		Mesh sharedMesh6 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_field_low", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		componentsInChildren3[0].sharedMesh = sharedMesh5;
		componentsInChildren3[1].sharedMesh = sharedMesh6;
		Quaternion quaternion5 = Quaternion.Euler(0f, componentsInChildren3[0].transform.rotation.y + 180f, 0f);
		Transform obj3 = componentsInChildren3[0].transform;
		rotation = (componentsInChildren3[1].transform.rotation = quaternion5);
		obj3.rotation = rotation;
	}

	private void InitializeCardDecoration()
	{
		GameObject prefab = Resources.Load("Prefab/CardDeco/Cost") as GameObject;
		GameObject prefab2 = Resources.Load("Prefab/CardDeco/Atk") as GameObject;
		GameObject prefab3 = Resources.Load("Prefab/CardDeco/Life") as GameObject;
		GameObject prefab4 = Resources.Load("Prefab/CardDeco/Name") as GameObject;
		GameObject gameObject = NGUITools.AddChild(UnitCardObject, prefab);
		GameObject gameObject2 = NGUITools.AddChild(UnitCardObject, prefab2);
		GameObject gameObject3 = NGUITools.AddChild(UnitCardObject, prefab3);
		GameObject gameObject4 = NGUITools.AddChild(UnitCardObject, prefab4);
		GameObject gameObject5 = NGUITools.AddChild(SpellCardObject, prefab);
		GameObject gameObject6 = NGUITools.AddChild(SpellCardObject, prefab4);
		GameObject gameObject7 = NGUITools.AddChild(FieldCardObject, prefab);
		GameObject gameObject8 = NGUITools.AddChild(FieldCardObject, prefab4);
		Transform obj = gameObject.transform;
		Transform obj2 = gameObject5.transform;
		Vector3 vector = (gameObject7.transform.localPosition = Global.POSITION_COST_ICON);
		Vector3 localPosition = (obj2.localPosition = vector);
		obj.localPosition = localPosition;
		Transform obj3 = gameObject.transform;
		Transform obj4 = gameObject5.transform;
		vector = (gameObject7.transform.localScale = Global.SCALE_CARD_ICON);
		localPosition = (obj4.localScale = vector);
		obj3.localScale = localPosition;
		Transform obj5 = gameObject4.transform;
		Transform obj6 = gameObject6.transform;
		vector = (gameObject8.transform.localPosition = Global.POSITION_NAME_TEXT);
		localPosition = (obj6.localPosition = vector);
		obj5.localPosition = localPosition;
		Transform obj7 = gameObject4.transform;
		Transform obj8 = gameObject6.transform;
		vector = (gameObject8.transform.localScale = Global.SCALE_NAME_TEXT);
		localPosition = (obj8.localScale = vector);
		obj7.localScale = localPosition;
		gameObject2.transform.localPosition = Global.POSITION_ATK_ICON;
		gameObject3.transform.localPosition = Global.POSITION_LIFE_ICON;
		Transform obj9 = gameObject2.transform;
		localPosition = (gameObject3.transform.localScale = Global.SCALE_CARD_ICON);
		obj9.localScale = localPosition;
		UnitCost = gameObject.transform.Find("CostLabel").GetComponent<UILabel>();
		UnitAtk = gameObject2.transform.Find("AtkLabel").GetComponent<UILabel>();
		UnitLife = gameObject3.transform.Find("LifeLabel").GetComponent<UILabel>();
		UnitName = gameObject4.transform.Find("NameLabel").GetComponent<UILabel>();
		SpellCost = gameObject5.transform.Find("CostLabel").GetComponent<UILabel>();
		SpellName = gameObject6.transform.Find("NameLabel").GetComponent<UILabel>();
		FieldCost = gameObject7.transform.Find("CostLabel").GetComponent<UILabel>();
		FieldName = gameObject8.transform.Find("NameLabel").GetComponent<UILabel>();
	}

	private void SetButtonEvent()
	{
		UIEventListener uIEventListener = UIEventListener.Get(ReturnButton);
		uIEventListener.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener.onClick, new UIEventListener.VoidDelegate(OnPushCardDetailOn));
		UIEventListener uIEventListener2 = UIEventListener.Get(_blankColliderButton.gameObject);
		uIEventListener2.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener2.onClick, new UIEventListener.VoidDelegate(OnPushCardDetailOn));
		UIEventListener uIEventListener3 = UIEventListener.Get(DarkPanel.gameObject);
		uIEventListener3.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener3.onClick, new UIEventListener.VoidDelegate(OnPushCardDetailOn));
		UIEventListener uIEventListener4 = UIEventListener.Get(Frame.gameObject);
		uIEventListener4.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener4.onClick, new UIEventListener.VoidDelegate(OnPushCardDetailOn));
		UIEventListener uIEventListener5 = UIEventListener.Get(CardIntroductionButton);
		uIEventListener5.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener5.onClick, new UIEventListener.VoidDelegate(OnClickChangeCardTextTypeButton));
		UIEventListener uIEventListener6 = UIEventListener.Get(CardViewBG);
		uIEventListener6.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener6.onClick, new UIEventListener.VoidDelegate(OnCloseCardViewMode));
		UIEventListener uIEventListener7 = UIEventListener.Get(UnitCardObject);
		uIEventListener7.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener7.onClick, new UIEventListener.VoidDelegate(OnOpenCardViewMode));
		UIEventListener uIEventListener8 = UIEventListener.Get(SpellCardObject);
		uIEventListener8.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener8.onClick, new UIEventListener.VoidDelegate(OnOpenCardViewMode));
		UIEventListener uIEventListener9 = UIEventListener.Get(FieldCardObject);
		uIEventListener9.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener9.onClick, new UIEventListener.VoidDelegate(OnOpenCardViewMode));
		UIEventListener uIEventListener10 = UIEventListener.Get(_favoriteButton.gameObject);
		uIEventListener10.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener10.onClick, new UIEventListener.VoidDelegate(OnClickFavoriteButton));
		UIEventListener uIEventListener11 = UIEventListener.Get(_voiceButton.gameObject);
		uIEventListener11.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener11.onClick, new UIEventListener.VoidDelegate(OnClickVoiceButton));
		UIEventListener uIEventListener12 = UIEventListener.Get(_premiumCardConversionButton.gameObject);
		uIEventListener12.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener12.onClick, new UIEventListener.VoidDelegate(OnClickPremiumCardConversionButton));
		UIEventListener uIEventListener13 = UIEventListener.Get(CardEvolButton);
		uIEventListener13.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener13.onClick, new UIEventListener.VoidDelegate(OnClickEvolutionButton));
		UIEventListener uIEventListener14 = UIEventListener.Get(UnitCardObject);
		uIEventListener14.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener14.onDrag, new UIEventListener.VectorDelegate(OnSwipeCard));
		UIEventListener uIEventListener15 = UIEventListener.Get(SpellCardObject);
		uIEventListener15.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener15.onDrag, new UIEventListener.VectorDelegate(OnSwipeCard));
		UIEventListener uIEventListener16 = UIEventListener.Get(FieldCardObject);
		uIEventListener16.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener16.onDrag, new UIEventListener.VectorDelegate(OnSwipeCard));
		UIEventListener uIEventListener17 = UIEventListener.Get(Frame);
		uIEventListener17.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener17.onDrag, new UIEventListener.VectorDelegate(OnSwipeCard));
		UIEventListener uIEventListener18 = UIEventListener.Get(CardText);
		uIEventListener18.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener18.onDrag, new UIEventListener.VectorDelegate(OnSwipeCard));
		UIEventListener uIEventListener19 = UIEventListener.Get(QuestionMark);
		uIEventListener19.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener19.onDrag, new UIEventListener.VectorDelegate(OnSwipeCard));
		UIEventListener uIEventListener20 = UIEventListener.Get(RelationCardButton);
		uIEventListener20.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener20.onClick, new UIEventListener.VoidDelegate(OnPushRelationCardButton));
		UIEventListener uIEventListener21 = UIEventListener.Get(RelationBackButton);
		uIEventListener21.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener21.onClick, new UIEventListener.VoidDelegate(OnPushRelationBackButton));
		UIEventListener uIEventListener22 = UIEventListener.Get(RightButton);
		uIEventListener22.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener22.onClick, new UIEventListener.VoidDelegate(OnPushRightButton));
		UIEventListener uIEventListener23 = UIEventListener.Get(LeftButton);
		uIEventListener23.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener23.onClick, new UIEventListener.VoidDelegate(OnPushLeftButton));
		Action onClickDestructBtn = delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			CreateDialog(StartCardDestruct, buy: false);
		};
		Action onClickCreateBtn = delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			CreateDialog(StartCardCraft, buy: true);
		};
		_craftPanel.Init(onClickCreateBtn, onClickDestructBtn);
		UIEventListener.Get(QuestionMark).onClick = delegate
		{
			if (_isAbleTapDialogObject)
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
				UILabel keyWordLabel = GetKeyWordLabel();
				string empty = string.Empty;
				empty = ((!CardData.IsEvolveChoiceCard) ? (CardData.ConvertedSkillDescription + CardData.ConvertedEvoSkillDescription) : CardData.ConvertedEvoSkillDescription);
				_keyWordDialog = BattlePlayerView.CreateKeyPanel(empty, keyWordLabel, _cardMasterId);
				UIManager.ViewScene currentScene = UIManager.GetInstance().GetCurrentScene();
				if ((currentScene == UIManager.ViewScene.Battle || currentScene == UIManager.ViewScene.LoginBonus || currentScene == UIManager.ViewScene.Colosseum || currentScene == UIManager.ViewScene.LotteryPage || currentScene == UIManager.ViewScene.QuestSelectionPage) && IsCardTextDialogLayerSet)
				{
					_keyWordDialog.SetPanelDepth(120);
					Vector3 localPosition = _keyWordDialog.gameObject.transform.localPosition;
					localPosition.z = -5f;
					localPosition.y = 0f;
					_keyWordDialog.gameObject.transform.localPosition = localPosition;
					ChangeLayer(_keyWordDialog.gameObject, LayerDetail);
					_keyWordDialog.SetBackViewLayer(LayerDetail);
					_keyWordDialog.SetBackViewPosition(KEYWORD_DIALOG_BACK_VIEW_POSITION);
					UIPanel[] componentsInChildren = _keyWordDialog.InsideObject.GetComponentsInChildren<UIPanel>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].depth += 120;
					}
				}
			}
		};
		UIEventListener uIEventListener24 = UIEventListener.Get(QuestionMark);
		uIEventListener24.onPress = (UIEventListener.BoolDelegate)Delegate.Combine(uIEventListener24.onPress, (UIEventListener.BoolDelegate)delegate(GameObject g, bool b)
		{
			UILabel keyWordLabel = GetKeyWordLabel();
			if (keyWordLabel != null)
			{
				BattlePlayerView.PressKeyWordColorChange(keyWordLabel, b);
			}
		});
		UIEventListener uIEventListener25 = UIEventListener.Get(QuestionMark);
		uIEventListener25.onDragStart = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener25.onDragStart, (UIEventListener.VoidDelegate)delegate
		{
			if (UnitCardTextScrollView.gameObject.activeInHierarchy)
			{
				BattlePlayerView.SetKeyWordLabelColor(UnitCardSkill);
				BattlePlayerView.SetKeyWordLabelColor(UnitCardEvoSkill);
			}
			else
			{
				UILabel keyWordLabel = GetKeyWordLabel();
				if (keyWordLabel != null)
				{
					BattlePlayerView.SetKeyWordLabelColor(keyWordLabel);
				}
			}
		});
	}

	private void AddAtlasOverrider(DialogBase dialog)
	{
		UIAtlas component = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("dummy", ResourcesManager.AssetLoadPathType.QuestAtlas, isfetch: true)).GetComponent<UIAtlas>();
		UISpriteAtlasOverwriter.TargetObject[] targetObjects = new UISpriteAtlasOverwriter.TargetObject[1]
		{
			new UISpriteAtlasOverwriter.TargetObject(dialog.gameObject, includeChildren: true)
		};
		dialog.gameObject.AddMissingComponent<UISpriteAtlasOverwriter>().Init(component, targetObjects);
	}

	private UILabel GetKeyWordLabel()
	{
		if (UnitCardTextScrollView.gameObject.activeInHierarchy)
		{
			Transform parent = UnitCardSkill.transform.parent;
			UnitCardSkill.transform.SetParent(base.transform);
			Vector3 vector = UnitCardSkill.transform.localPosition - new Vector3(0f, UnitCardSkill.printedSize.y, 0f);
			UnitCardSkill.transform.SetParent(parent);
			Vector3 vector2 = base.transform.InverseTransformPoint(UICamera.lastHit.point);
			if (vector.y < vector2.y)
			{
				if (!string.IsNullOrEmpty(UnitCardSkill.text) && UnitCardSkill.text != " ")
				{
					return UnitCardSkill;
				}
				if (!string.IsNullOrEmpty(UnitCardEvoSkill.text) && UnitCardEvoSkill.text != " ")
				{
					return UnitCardEvoSkill;
				}
			}
			else
			{
				if (!string.IsNullOrEmpty(UnitCardEvoSkill.text) && UnitCardEvoSkill.text != " ")
				{
					return UnitCardEvoSkill;
				}
				if (!string.IsNullOrEmpty(UnitCardSkill.text) && UnitCardSkill.text != " ")
				{
					return UnitCardSkill;
				}
			}
		}
		else
		{
			if (SpellCardTextScrollView.gameObject.activeInHierarchy)
			{
				return SpellCardSkill;
			}
			if (SettingCardTextScrollView.gameObject.activeInHierarchy)
			{
				return SettingCardSkill;
			}
		}
		return null;
	}

	public void OnPushCardDetailOn(GameObject g)
	{
		if (_isAbleTapDialogObject && ShowCardDetail(g))
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_CARD_INFO);
		}
	}

	public bool ShowCardDetail(GameObject g)
	{
		if (isDetailOn)
		{
			CloseDefault(playSe: true);
			return false;
		}
		if (!IsEnableShowDetail)
		{
			return false;
		}
		CharIdx component = g.GetComponent<CharIdx>();
		if (!component)
		{
			return false;
		}
		isDetailOn = true;
		IsAnimationPlaying = true;
		base.gameObject.SetActive(value: true);
		DarkPanel.SetActive(value: true);
		DestroyDialogObject();
		_dialogForClose = UIManager.GetInstance().DialogManager.CreateDialogBaseOpenCardDetail(this);
		SetCardDetail(component.GetCardId(), g);
		OpenCardAnimation();
		return true;
	}

	private void OpenCardAnimation()
	{
		iTween.Stop(CardNum.gameObject);
		if (GetPossessionCardNum(isIncludingSpotCard: true) > 0)
		{
			CardNum.transform.localScale = new Vector3(0.01f, 0.01f, 1f);
			iTween.ScaleTo(CardNum.gameObject, iTween.Hash("scale", new Vector3(1f, 1f, 1f), "time", 0.3f));
		}
		else
		{
			CardNum.transform.localScale = new Vector3(1f, 1f, 1f);
		}
		GameObject gameObject = null;
		CardBasePrm.CharaType charType = CardData.CharType;
		gameObject = (CardBasePrm.IsFollowerCard(charType) ? UnitCardObject : ((!CardBasePrm.IsSpellCard(charType)) ? FieldCardObject : SpellCardObject));
		gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
		iTween.Stop(gameObject);
		iTween.ScaleTo(gameObject, iTween.Hash("islocal", true, "scale", new Vector3(kCARD_SCALE, kCARD_SCALE, 1f), "time", 0.3f, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(gameObject, iTween.Hash("islocal", true, "x", 0f, "y", 0f, "z", kCARD_POS_Z, "time", 0.3f, "oncompletetarget", base.gameObject, "oncomplete", "OnAnimationOver", "easetype", iTween.EaseType.easeOutExpo));
	}

	private void OnAnimationOver()
	{
		IsAnimationPlaying = false;
		BoxCollider unitCardCollider = UnitCardCollider;
		BoxCollider spellCardCollider = SpellCardCollider;
		Vector3 vector = (FieldCardCollider.size = new Vector3(3.6f, 5.5f, 1f));
		Vector3 size = (spellCardCollider.size = vector);
		unitCardCollider.size = size;
	}

	public void CloseDefault(bool playSe)
	{
		if (!isDetailOn || isAnimation || IsAnimationPlaying)
		{
			return;
		}
		if (isCardViewMode)
		{
			OnCloseCardViewMode();
			return;
		}
		isDetailOn = false;
		DarkPanel.SetActive(value: false);
		if (base.gameObject.activeSelf && playSe)
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL);
		}
		base.gameObject.SetActive(value: false);
		if (_evolEffect != null)
		{
			UnityEngine.Object.Destroy(_evolEffect.gameObject);
		}
		Toolbox.ResourcesManager.RemoveAssetGroup(_assetPathList);
		Toolbox.ResourcesManager.RemoveAssetGroup(_assetTokenPathList);
		_assetTokenPathList.Clear();
		DestroyDialogObject();
		OnClose.Call();
	}

	private void SetCardDetail(int cardId, GameObject card2dObj = null, bool isUpdateRelation = true)
	{
		CardData = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(cardId);
		if (isUpdateRelation)
		{
			RelationWrapperObj.SetActive(value: false);
		}
		iTween.Stop(base.gameObject);
		_isEvolCard = CardData.IsEvolveChoiceCard;
		_isShowCardAblityText = true;
		UpdateCardImage();
		SystemText systemText = Data.SystemText;
		_nameValueLabel.text = CardData.CardName;
		string key = "Common_01" + ((int)(4 + CardData.Clan)).ToString("00");
		_classValueLabel.text = systemText.Get(key);
		_typeValueLabel.text = CardData.TribeName;
		if (_typeValueLabel.text == "ALL")
		{
			_typeValueLabel.text = "-";
		}
		UpdateCardText();
		_isFavoriteButtonEnabled = true;
		UpdateButtonState();
		UpdateCreateLiquefyButton();
		if (isUpdateRelation)
		{
			UpdateRelation(cardId);
			DialogTitleLabel.text = Data.SystemText.Get("Card_0135");
		}
		UpdateCardNum(card2dObj);
		if (!IsRelationCardViewing)
		{
			_relationCardBaseGameObject = card2dObj;
			OnDetailCardUpdate.Call();
		}
	}

	private void UpdateRelation(int cardId)
	{
		_relationCardIds.Clear();
		_relationCardParentDict.Clear();
		_relationIndex = 0;
		_originalCardId = cardId;
		if (RELATION_CARD_BUTTON_DISABLE_CARD_IDS.Contains(cardId))
		{
			RelationCardButton.SetActive(value: false);
			return;
		}
		CardMaster instance = CardMaster.GetInstance(_cardMasterId);
		if (instance != null)
		{
			List<CardParameter> allParams = new List<CardParameter>(instance.GetAllParameters());
			ParseIdsFunc(allParams, cardId);
		}
		IDictionary<int, List<int>> relationCardSortDic = Data.Master.RelationCardSortDic;
		CardParameter cardParameterFromId = CardMaster.GetInstanceForBattle().GetCardParameterFromId(cardId);
		if (relationCardSortDic.ContainsKey(cardParameterFromId.NormalCardId))
		{
			_relationCardIds = new List<int>(relationCardSortDic[cardParameterFromId.NormalCardId]);
		}
		else
		{
			_relationCardIds = SortRelationCardByKeyWordTextOrder(_relationCardIds);
		}
		bool flag = false;
		foreach (int relationCardId in _relationCardIds)
		{
			if (relationCardSortDic.ContainsKey(relationCardId))
			{
				flag = true;
				break;
			}
		}
		if (!relationCardSortDic.ContainsKey(cardParameterFromId.NormalCardId) && flag)
		{
			_relationCardIds = SortPartOfRelationCard(_relationCardIds, cardParameterFromId.NormalCardId);
		}
	}

	private static List<int> SortPartOfRelationCard(List<int> originalList, int cardId)
	{
		List<int> list = new List<int>();
		list.AddRange(originalList);
		IDictionary<int, List<int>> relationCardSortDic = Data.Master.RelationCardSortDic;
		foreach (int original in originalList)
		{
			if (!relationCardSortDic.TryGetValue(original, out var value))
			{
				continue;
			}
			List<int> list2 = new List<int>();
			for (int i = 0; i < value.Count; i++)
			{
				int num = value[i];
				for (int j = 0; j < originalList.Count; j++)
				{
					if (originalList[j] == num)
					{
						list2.Add(j);
						break;
					}
				}
			}
			list2.Sort();
			for (int k = 0; k < list2.Count; k++)
			{
				int index = list2[k];
				list[index] = value[k];
			}
		}
		return list;
	}

	private List<int> SortRelationCardByKeyWordTextOrder(List<int> originalList)
	{
		if (originalList.Count < 2)
		{
			return originalList;
		}
		List<int> sortedCardIdList = new List<int>();
		List<string> keywordListInCard = GetKeywordListInCard(CardData.CardId);
		for (int i = 0; i < keywordListInCard.Count; i++)
		{
			List<int> cardIdsInKeyword = GetCardIdsInKeyword(keywordListInCard[i]);
			if (cardIdsInKeyword.Count == 0)
			{
				continue;
			}
			int num = cardIdsInKeyword[0];
			if (!originalList.Contains(num))
			{
				continue;
			}
			if (!sortedCardIdList.Contains(num))
			{
				sortedCardIdList.Add(num);
			}
			List<string> keywordListInCard2 = GetKeywordListInCard(num);
			for (int j = 0; j < keywordListInCard2.Count; j++)
			{
				List<int> cardIdsInKeyword2 = GetCardIdsInKeyword(keywordListInCard2[j]);
				if (cardIdsInKeyword2.Count == 0)
				{
					continue;
				}
				for (int k = 0; k < cardIdsInKeyword2.Count; k++)
				{
					int num2 = cardIdsInKeyword2[k];
					if (originalList.Contains(num2) && !sortedCardIdList.Contains(num2))
					{
						sortedCardIdList.Add(num2);
					}
					if (k > 0)
					{
						AddNonAppearedRelationCardId(num2, ref sortedCardIdList);
					}
				}
				AddNonAppearedRelationCardId(cardIdsInKeyword2[0], ref sortedCardIdList);
			}
			AddNonAppearedRelationCardId(num, ref sortedCardIdList);
		}
		foreach (int original in originalList)
		{
			if (!sortedCardIdList.Contains(original))
			{
				sortedCardIdList.Add(original);
			}
		}
		return sortedCardIdList;
	}

	private void AddNonAppearedRelationCardId(int parentCardId, ref List<int> sortedCardIdList)
	{
		if (!_relationCardParentDict.TryGetValue(parentCardId, out var value))
		{
			return;
		}
		foreach (int item in value)
		{
			if (!sortedCardIdList.Contains(item))
			{
				sortedCardIdList.Add(item);
			}
		}
	}

	private List<string> GetKeywordListInCard(int cardId)
	{
		CardParameter cardParameterFromId = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(cardId);
		List<string> list = BattleKeywordInfoListMgr.GetKeywords(cardParameterFromId.ConvertedSkillDescription).ToList();
		if (CardBasePrm.IsFollowerCard(CardData.CharType))
		{
			list.AddRange(BattleKeywordInfoListMgr.GetKeywords(cardParameterFromId.ConvertedEvoSkillDescription).ToList());
		}
		return list;
	}

	private List<int> GetCardIdsInKeyword(string keyword)
	{
		List<int> list = new List<int>();
		if (Data.Master.BattleKeyWordDic.ContainsKey(keyword))
		{
			list.AddRange(BattleKeywordInfoListMgr.GetCardIdsInDesc(Data.Master.BattleKeyWordDic[keyword]));
		}
		return list;
	}

	private void UpdateCardImage()
	{
		CardMaster instance = CardMaster.GetInstance(_cardMasterId);
		int cardId = CardData.CardId;
		CardParameter cardParameterFromId = instance.GetCardParameterFromId(cardId);
		int resourceCardId = cardParameterFromId.ResourceCardId;
		int rarity = CardData.Rarity;
		CardBasePrm.CharaType charType = CardData.CharType;
		GameObject gameObject = null;
		Material material = null;
		bool flag = CardBasePrm.IsFollowerCard(charType);
		bool flag2 = CardBasePrm.IsSpellCard(charType);
		bool flag3 = CardBasePrm.IsAmuletCard(charType);
		UnitCardObject.SetActive(flag && !flag2 && !flag3);
		SpellCardObject.SetActive(!flag && flag2 && !flag3);
		FieldCardObject.SetActive(!flag && !flag2 && flag3);
		if (flag2)
		{
			gameObject = SpellCardObject;
			try
			{
				material = Toolbox.ResourcesManager.FindCardMaterial(resourceCardId, ResourcesManager.AssetLoadPathType.SpellCardMaterial, isEvol: false, CardMaster.IsMutationCardCheck(instance.GetCardParameterFromId(cardId).BaseCardId), instance.GetCardParameterFromId(resourceCardId).CharType);
				CardShaderDefine.ReplaceShader(material);
			}
			catch (Exception ex)
			{
				Debug.LogError(ex.ToString());
				LocalLog.AccumulateTraceLog(ex.ToString());
			}
			_rotationOnlyIconSpell.SetActive(cardParameterFromId.IsResurgentCard);
			SpellCost.text = CardData.Cost.ToString();
			SpellName.text = CardData.CardName;
			Global.SetRepositionNameLabel(SpellName, CardData.CardName, is2D: false);
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(SpellCost, CardData.IsFoil);
			UIManager.GetInstance().getUIBase_CardManager().SetNameLabelStyle(SpellName, CardData.IsFoil);
		}
		else if (flag3)
		{
			gameObject = FieldCardObject;
			try
			{
				material = Toolbox.ResourcesManager.FindCardMaterial(resourceCardId, ResourcesManager.AssetLoadPathType.SpellCardMaterial, isEvol: false, CardMaster.IsMutationCardCheck(instance.GetCardParameterFromId(cardId).BaseCardId), instance.GetCardParameterFromId(resourceCardId).CharType);
				CardShaderDefine.ReplaceShader(material);
			}
			catch (Exception ex2)
			{
				Debug.LogError(ex2.ToString());
				LocalLog.AccumulateTraceLog(ex2.ToString());
			}
			_rotationOnlyIconAmulet.SetActive(cardParameterFromId.IsResurgentCard);
			FieldCost.text = CardData.Cost.ToString();
			FieldName.text = CardData.CardName;
			Global.SetRepositionNameLabel(FieldName, CardData.CardName, is2D: false);
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(FieldCost, CardData.IsFoil);
			UIManager.GetInstance().getUIBase_CardManager().SetNameLabelStyle(FieldName, CardData.IsFoil);
		}
		else if (flag)
		{
			gameObject = UnitCardObject;
			try
			{
				material = Toolbox.ResourcesManager.FindCardMaterial(resourceCardId, ResourcesManager.AssetLoadPathType.UnitCardMaterial, _isEvolCard);
				CardShaderDefine.ReplaceShader(material);
			}
			catch (Exception ex3)
			{
				Debug.LogError(ex3.ToString());
				LocalLog.AccumulateTraceLog(ex3.ToString());
			}
			_rotationOnlyIconFollower.SetActive(cardParameterFromId.IsResurgentCard);
			UnitCost.text = CardData.Cost.ToString();
			UnitAtk.text = (_isEvolCard ? CardData.EvoAtk.ToString() : CardData.Atk.ToString());
			UnitLife.text = (_isEvolCard ? CardData.EvoLife.ToString() : CardData.Life.ToString());
			UnitName.text = CardData.CardName;
			Global.SetRepositionNameLabel(UnitName, CardData.CardName, is2D: false);
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(UnitCost, CardData.IsFoil);
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(UnitAtk, CardData.IsFoil);
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(UnitLife, CardData.IsFoil);
			UIManager.GetInstance().getUIBase_CardManager().SetNameLabelStyle(UnitName, CardData.IsFoil);
		}
		if (material != null)
		{
			if (cardParameterFromId.IsFoil)
			{
				if (_premiumShader == null)
				{
					_premiumShader = Shader.Find("Wizard/VariantCardShader");
				}
				if (material.shader != _premiumShader)
				{
					material.shader = _premiumShader;
					material.color = Color.white;
				}
			}
			else
			{
				if (_normalShader == null)
				{
					_normalShader = Shader.Find("Wizard/Card/Basic_Front0_Back0_Normal");
				}
				if (material.shader != _normalShader)
				{
					material.shader = _normalShader;
					material.color = Color.white;
				}
			}
		}
		if (_cardMaterial != null)
		{
			UnityEngine.Object.Destroy(_cardMaterial);
		}
		Material cardMaterial = ((material != null) ? UnityEngine.Object.Instantiate(material) : null);
		Material[] sharedMaterials = new Material[3]
		{
			UIManager.GetInstance().getUIBase_CardManager()._3dCardFrameManager.GetFrameMaterial(cardParameterFromId.IsPhantomCard, charType, rarity),
			_cardMaterial = cardMaterial,
			CardCreatorBase.GetSharedClassIconMaterial(CardData.Clan)
		};
		LOD[] lODs = gameObject.GetComponent<LODGroup>().GetLODs();
		for (int i = 0; i < lODs.Length; i++)
		{
			lODs[i].renderers[0].sharedMaterials = sharedMaterials;
		}
		AttachShadow(gameObject, CardShadow.gameObject);
		bool active = UIManager.GetInstance().GetCurrentScene() == UIManager.ViewScene.CardAllList && GetPossessionCardNum(isIncludingSpotCard: true) <= 0;
		CardShadow.SetActive(active);
	}

	private static void AttachShadow(GameObject parentObj, GameObject shadowObj)
	{
		Transform parent = parentObj.transform;
		Transform obj = shadowObj.transform;
		obj.parent = parent;
		obj.localPosition = new Vector3(0f, 0f, kCARD_POS_Z - 1f);
		obj.localRotation = Quaternion.identity;
		obj.localScale = new Vector3(1f / kCARD_SCALE, 1f / kCARD_SCALE, 1f);
		shadowObj.layer = parentObj.layer;
	}

	private void UpdateCardNum(GameObject card2dObj = null)
	{
		DataMgr dataMgr = GameMgr.GetIns().GetDataMgr();
		if (_isOwnCardNum || card2dObj == null)
		{
			int possessionCardNum = GetPossessionCardNum();
			if (dataMgr.SpotCardData.ExistsSpotCard(CardData.CardId))
			{
				int spotCardNum = dataMgr.SpotCardData.GetSpotCardNum(CardData.CardId);
				SetCardNumLabel(possessionCardNum, spotCardNum);
			}
			else
			{
				SetCardNumLabel(possessionCardNum);
			}
			return;
		}
		CardListTemplate component = card2dObj.GetComponent<CardListTemplate>();
		if (component != null && component.IsShowNum())
		{
			if (component.IsIncludingSpotCard)
			{
				SetCardNumLabel(component.GetNum(), component.GetSpotCardNum());
			}
			else
			{
				SetCardNumLabel(component.GetNum());
			}
		}
		else
		{
			SetCardNumLabel(0);
		}
	}

	private static bool IsTokenId(int cardId)
	{
		return cardId / 100000000 == 9;
	}

	private int GetPossessionCardNumOnRelationCard(bool isIncludingSpotCard)
	{
		if (IsTokenId(CardData.CardId))
		{
			return GetPosessionCardNum(_originalCardId, isIncludingSpotCard);
		}
		int posessionCardNum = GetPosessionCardNum(_originalCardId, isIncludingSpotCard);
		int posessionCardNum2 = GetPosessionCardNum(CardData.CardId, isIncludingSpotCard);
		if (posessionCardNum > 0 || posessionCardNum2 > 0)
		{
			return 1;
		}
		return 0;
	}

	private int GetPosessionCardNum(int cardId, bool isIncludingSpotCard)
	{
		if (_formatBehaviorForCardPoolChange != null)
		{
			return _formatBehaviorForCardPoolChange.GetPossessionCardNum(cardId, isIncludingSpotCard);
		}
		return GameMgr.GetIns().GetDataMgr().GetPossessionCardNum(cardId, isIncludingSpotCard);
	}

	private int GetPossessionCardNum(bool isIncludingSpotCard = false)
	{
		if (IsRelationCardViewing)
		{
			return GetPossessionCardNumOnRelationCard(isIncludingSpotCard);
		}
		return GetPosessionCardNum(CardData.CardId, isIncludingSpotCard);
	}

	private void SetCardNumLabel(int num)
	{
		SetCardNumActive(num > 0);
		_cardNumLabel.text = num.ToString();
	}

	private void SetCardNumLabel(int cardNum, int spotCardNum)
	{
		SetCardNumActive(cardNum + spotCardNum > 0);
		_cardNumLabel.text = $"{cardNum}[fcd24a]+{spotCardNum}";
	}

	private void SetCardNumActive(bool isEnabled)
	{
		if (IsRelationCardViewing)
		{
			CardNum.SetActive(value: false);
		}
		else
		{
			CardNum.SetActive(isEnabled);
		}
	}

	private void UpdateCardText()
	{
		if (_isShowCardAblityText)
		{
			UpdateCardAbilityText();
			StartCoroutine(DelayResetScrollViewPosition());
			_shouldResetTextScrollView = true;
		}
		else
		{
			UpdateCardFlavorText();
			if (_shouldResetTextScrollView)
			{
				ResetScrollViewPosition();
				_shouldResetTextScrollView = false;
			}
		}
		CardBasePrm.CharaType charType = CardData.CharType;
		bool flag = CardBasePrm.IsFollowerCard(charType);
		bool flag2 = CardBasePrm.IsSpellCard(charType);
		bool flag3 = CardBasePrm.IsAmuletCard(charType);
		UnitCardTextScrollView.gameObject.SetActive(flag && !flag2 && !flag3);
		if (UnitCardTextScrollView.gameObject.activeSelf)
		{
			UnitCardStatusObj.gameObject.SetActive(_isShowCardAblityText);
			UnitCardIntroductionObj.gameObject.SetActive(!_isShowCardAblityText);
		}
		SpellCardTextScrollView.gameObject.SetActive(!flag && flag2 && !flag3);
		if (SpellCardTextScrollView.gameObject.activeSelf)
		{
			SpellCardStatusObj.gameObject.SetActive(_isShowCardAblityText);
			SpellCardIntroductionObj.gameObject.SetActive(!_isShowCardAblityText);
		}
		SettingCardTextScrollView.gameObject.SetActive(!flag && !flag2 && flag3);
		if (SettingCardTextScrollView.gameObject.activeSelf)
		{
			SettingCardStatusObj.gameObject.SetActive(_isShowCardAblityText);
			SettingCardIntroductionObj.gameObject.SetActive(!_isShowCardAblityText);
		}
		_cardVoiceLabelRoot.gameObject.SetActive(!_isShowCardAblityText && CardData.CardVoice != string.Empty);
		_cardSetLabelRoot.gameObject.SetActive(!_isShowCardAblityText);
	}

	private void UpdateCardAbilityText()
	{
		CardBasePrm.CharaType charType = CardData.CharType;
		string convertedSkillDescription = CardData.ConvertedSkillDescription;
		if (CardBasePrm.IsFollowerCard(charType))
		{
			FollowerCardAbilityTexActive();
		}
		else if (CardBasePrm.IsSpellCard(charType))
		{
			SpellCardSkill.SetWrapText(convertedSkillDescription);
			SpellCardSkill.gameObject.SetActive(value: false);
			SpellCardSkill.gameObject.SetActive(value: true);
			_cardSpellTextLineCreater.ShowLines(GetLineNumber(SpellCardSkill), isOriginalActive: true);
		}
		else if (CardBasePrm.IsAmuletCard(charType))
		{
			SettingCardSkill.SetWrapText(convertedSkillDescription);
			SettingCardSkill.gameObject.SetActive(value: false);
			SettingCardSkill.gameObject.SetActive(value: true);
			_cardAmuletTextLineCreater.ShowLines(GetLineNumber(SettingCardSkill), isOriginalActive: true);
		}
	}

	private void FollowerCardAbilityTexActive()
	{
		bool isEvolveChoiceCard = CardData.IsEvolveChoiceCard;
		UILabel normalTitleLavel = _normalTitleLavel;
		string text3;
		if (!isEvolveChoiceCard)
		{
			string text = (_normalTitleLavel.text = Data.SystemText.Get("Card_0037"));
			text3 = text;
		}
		else
		{
			text3 = Data.SystemText.Get("Card_0038");
		}
		normalTitleLavel.text = text3;
		_evolveInfoObjectRoot.gameObject.SetActive(!isEvolveChoiceCard);
		UnitCardSkill.SetWrapText(isEvolveChoiceCard ? CardData.ConvertedEvoSkillDescription : CardData.ConvertedSkillDescription);
		UnitCardEvoSkill.SetWrapText(isEvolveChoiceCard ? string.Empty : CardData.ConvertedEvoSkillDescription);
		UnitCardAtkRight.text = (isEvolveChoiceCard ? CardData.EvoAtk.ToString() : CardData.Atk.ToString());
		UnitCardLifeRight.text = (isEvolveChoiceCard ? CardData.EvoLife.ToString() : CardData.Life.ToString());
		UnitCardEvoAtkRight.text = (isEvolveChoiceCard ? string.Empty : CardData.EvoAtk.ToString());
		UnitCardEvoLifeRight.text = (isEvolveChoiceCard ? string.Empty : CardData.EvoLife.ToString());
		UnitCardSkill.gameObject.SetActive(value: false);
		UnitCardSkill.gameObject.SetActive(value: true);
		UnitCardEvoSkill.gameObject.SetActive(value: false);
		UnitCardEvoSkill.gameObject.SetActive(!isEvolveChoiceCard);
		_cardSkillTextLineCreater.ShowLines(GetLineNumber(UnitCardSkill));
		_cardEvoSkillTextLineCreater.ShowLines(GetLineNumber(UnitCardEvoSkill));
	}

	private int GetLineNumber(UILabel uILabel)
	{
		return Global.GetTextLineCount(uILabel.text);
	}

	private void UpdateCardFlavorText()
	{
		string wrapText = "???";
		NGUIText.Alignment alignment = NGUIText.Alignment.Center;
		if (IsPopularityVote || GetPossessionCardNum(isIncludingSpotCard: true) > 0)
		{
			wrapText = (_isEvolCard ? CardData.EvoDescription : CardData.Description);
			alignment = NGUIText.Alignment.Left;
		}
		CardBasePrm.CharaType charType = CardData.CharType;
		UILabel uILabel = null;
		if (CardBasePrm.IsFollowerCard(charType))
		{
			uILabel = UnitCardIntroduction;
		}
		else if (CardBasePrm.IsSpellCard(charType))
		{
			uILabel = SpellCardIntroduction;
		}
		else if (CardBasePrm.IsAmuletCard(charType))
		{
			uILabel = SettingCardIntroduction;
		}
		uILabel.SetWrapText(wrapText);
		uILabel.alignment = alignment;
		_cardVoiceValueLabel.text = CardData.CardVoice;
		_cardSetValueLabel.text = Data.Master.CardSetNameMgr.Get(CardData.CardSetId).LongName;
	}

	private void UpdateButtonState()
	{
		UpdateFavoriteButton();
		UpdateVoiceButton();
		CardIntroductionButton.SetActive(IsShowFlavorTextButton);
		UpdateEvolutionButton();
		UpdatePremiumCardConversionButton();
		QuestionMark.SetActive(_isShowCardAblityText && BattlePlayerView.HasKeyword(CardData));
	}

	private void OnSwipeCard(GameObject g, Vector2 dir)
	{
		if (IsRelationCardViewing)
		{
			if (_relationCardIds.Count > 1)
			{
				if (dir.x >= 70f)
				{
					OnPushLeftButton(LeftButton);
				}
				if (dir.x <= -70f)
				{
					OnPushRightButton(RightButton);
				}
			}
		}
		else if (!IsAnimationPlaying && (!(_craftDialog != null) || !_craftDialog.IsOpen()))
		{
			OnDragCard.Call(dir);
		}
	}

	private void ParseIdsFunc(List<CardParameter> allParams, int cardId)
	{
		foreach (CardParameter allParam in allParams)
		{
			if (allParam.CardId == cardId)
			{
				ParseIds(allParams, allParam.Skill, cardId);
				ParseIds(allParams, allParam.SkillCondition, cardId);
				ParseIds(allParams, allParam.SkillOption, cardId, RELATION_CARD_SKILLOPTION_EXCLUDED_OPTIONS, RELATION_CARD_SKILLOPTION_SEPARATORS);
				ParseIds(allParams, allParam.SkillPreprocess, cardId);
				ParseIds(allParams, allParam.SkillTarget, cardId);
				break;
			}
		}
	}

	private void ParseIds(List<CardParameter> allParams, string str, int cardId, List<string> excludedOptions = null, char[] separators = null)
	{
		CardParameter cardParameterFromId = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(cardId);
		string normalSkillText = Global.ConvertToWithoutBBCode(cardParameterFromId.SkillDescription);
		string evolSkillText = Global.ConvertToWithoutBBCode(cardParameterFromId.EvoSkillDescription);
		if (excludedOptions != null && separators != null)
		{
			string[] sub = str.Split(separators, StringSplitOptions.RemoveEmptyEntries);
			int i;
			for (i = 0; i < sub.Length; i++)
			{
				if (excludedOptions.Any((string x) => sub[i].Contains(x)))
				{
					continue;
				}
				foreach (Match item in Regex.Matches(sub[i], "\\d{9}"))
				{
					int validateCardId = int.Parse(item.Value);
					ValidateAddId(validateCardId, cardParameterFromId, normalSkillText, evolSkillText, allParams);
				}
			}
		}
		else
		{
			foreach (Match item2 in Regex.Matches(str, "\\d{9}"))
			{
				int validateCardId2 = int.Parse(item2.Value);
				ValidateAddId(validateCardId2, cardParameterFromId, normalSkillText, evolSkillText, allParams);
			}
		}
		if (_relationCardIds.Count > 0)
		{
			RelationCardButton.SetActive(value: true);
			UpdateRelationCount();
		}
		else
		{
			RelationCardButton.SetActive(value: false);
		}
	}

	private void ValidateAddId(int validateCardId, CardParameter refRootCardParam, string normalSkillText, string evolSkillText, List<CardParameter> allParams)
	{
		CardParameter cardParameterFromId = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(_originalCardId);
		CardParameter cardParameterFromId2 = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(validateCardId);
		int validateBaseCardId = cardParameterFromId2.BaseCardId;
		if ((validateBaseCardId == cardParameterFromId.BaseCardId && !cardParameterFromId2.IsEvolveChoiceCard) || validateCardId == 0 || _relationCardIds.Contains(validateCardId) || validateCardId == refRootCardParam.CardId || validateCardId == refRootCardParam.NormalCardId)
		{
			return;
		}
		if (refRootCardParam.CardId != _originalCardId)
		{
			int num = _relationCardIds.FindIndex((int cardId) => CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(cardId).BaseCardId == validateBaseCardId);
			if (num >= 0)
			{
				CardParameter cardParameterFromId3 = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(_relationCardIds[num]);
				if (cardParameterFromId3.BaseCardId == cardParameterFromId3.CardId || validateBaseCardId != validateCardId)
				{
					return;
				}
				_relationCardIds.RemoveAt(num);
			}
		}
		if (validateCardId == 100011010)
		{
			string value = Global.ConvertToWithoutBBCode(CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(validateCardId).CardName);
			if (!normalSkillText.Contains(value) && !evolSkillText.Contains(value))
			{
				return;
			}
		}
		if (!validateCardId.ToString().StartsWith(RELATION_CARD_DISABLE_CARD_ID_HEADER, StringComparison.Ordinal))
		{
			_relationCardIds.Add(validateCardId);
			if (!_relationCardParentDict.TryGetValue(refRootCardParam.CardId, out var value2))
			{
				value2 = new List<int>();
				_relationCardParentDict.Add(refRootCardParam.CardId, value2);
			}
			value2.Add(validateCardId);
		}
		ParseIdsFunc(allParams, validateCardId);
	}

	private void OnPushRelationCardButton(GameObject g)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
		if (!IsAnimationPlaying)
		{
			IsAnimationPlaying = true;
			RelationCardButton.SetActive(value: false);
			RelationWrapperObj.SetActive(value: true);
			_relationIndex = 0;
			RereshRelation(g);
		}
	}

	private void OnPushRelationBackButton(GameObject g)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_SWITCH_MENU);
		if (!IsAnimationPlaying)
		{
			RelationWrapperObj.SetActive(value: false);
			IsAnimationPlaying = true;
			_relationIndex = 0;
			SetCardDetail(_originalCardId, _relationCardBaseGameObject);
			OpenCardAnimation();
			DialogTitleLabel.text = Data.SystemText.Get("Card_0135");
		}
	}

	private void OnPushRightButton(GameObject g)
	{
		if (IsRelationCardViewing)
		{
			if (!IsAnimationPlaying)
			{
				IsAnimationPlaying = true;
				_relationIndex++;
				if (_relationIndex >= _relationCardIds.Count)
				{
					_relationIndex = 0;
				}
				RereshRelation(g);
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_SLIDE_BTN);
			}
		}
		else
		{
			OnDragCard.Call(new Vector2(-70f, 0f));
		}
	}

	private void OnPushLeftButton(GameObject g)
	{
		if (IsRelationCardViewing)
		{
			if (!IsAnimationPlaying)
			{
				IsAnimationPlaying = true;
				_relationIndex--;
				if (_relationIndex < 0)
				{
					_relationIndex = _relationCardIds.Count - 1;
				}
				RereshRelation(g);
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_SLIDE_BTN);
			}
		}
		else
		{
			OnDragCard.Call(new Vector2(70f, 0f));
		}
	}

	private void UpdateRelationCount()
	{
		CardParameter cardParameterFromId = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(_originalCardId);
		DialogTitleLabel.text = string.Format(Data.SystemText.Get("Card_0217") + "\u3000({1}/{2})", cardParameterFromId.CardName, _relationIndex + 1, _relationCardIds.Count);
	}

	private void RereshRelation(GameObject g)
	{
		UpdateRelationCount();
		if (IsRelationCardViewing)
		{
			bool active = _relationCardIds.Count > 1;
			RightButton.SetActive(active);
			LeftButton.SetActive(active);
		}
		Toolbox.ResourcesManager.RemoveAssetGroup(_assetTokenPathList);
		_assetTokenPathList.Clear();
		CardParameter cardParameterFromId = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(_originalCardId);
		int id = _relationCardIds[_relationIndex];
		CardParameter cardParameterFromId2 = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(id);
		if (cardParameterFromId.IsFoil)
		{
			id = cardParameterFromId2.FoilCardId;
		}
		AddResourceList(cardParameterFromId2);
		CardTexture.SetActive(value: false);
		SetEnableButtons(isEnable: false);
		Toolbox.ResourcesManager.StartCoroutine_LoadAssetGroupAsync(_assetTokenPathList, delegate
		{
			CardTexture.SetActive(value: true);
			SetCardDetail(id, g, isUpdateRelation: false);
			OpenCardAnimation();
			SetEnableButtons(isEnable: true);
		});
	}

	private void AddResourceList(CardParameter CardPrm)
	{
		int resourceCardId = CardMaster.GetInstance(_cardMasterId).GetCardParameterFromId(CardPrm.NormalCardId).ResourceCardId;
		switch (CardPrm.CharType)
		{
		case CardBasePrm.CharaType.NORMAL:
		{
			string assetTypePath3 = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.UnitCardMaterial);
			_assetTokenPathList.Add(assetTypePath3);
			break;
		}
		case CardBasePrm.CharaType.SPELL:
		{
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.SpellCardMaterial);
			_assetTokenPathList.Add(assetTypePath2);
			break;
		}
		default:
		{
			string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.SpellCardMaterial);
			_assetTokenPathList.Add(assetTypePath);
			break;
		}
		}
	}

	private void OnOpenCardViewMode(GameObject g)
	{
		if (_isAbleTapDialogObject && !IsAnimationPlaying && !isAnimation && !isCardViewMode && (UIManager.GetInstance().GetCurrentScene() != UIManager.ViewScene.CardAllList || GetPossessionCardNum(isIncludingSpotCard: true) > 0))
		{
			isCardViewMode = true;
			IsAnimationPlaying = true;
			CardViewBG.SetActive(value: true);
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_CARD_INFO);
			CardBasePrm.CharaType charType = CardData.CharType;
			if (CardBasePrm.IsSpellCard(charType))
			{
				ViewCardObject = NGUITools.AddChild(base.gameObject, SpellCardObject);
			}
			else if (CardBasePrm.IsAmuletCard(charType))
			{
				ViewCardObject = NGUITools.AddChild(base.gameObject, FieldCardObject);
			}
			else if (CardBasePrm.IsFollowerCard(charType))
			{
				ViewCardObject = NGUITools.AddChild(base.gameObject, UnitCardObject);
			}
			iTween.ScaleTo(ViewCardObject, iTween.Hash("Scale", CardViewScale, "time", 0.3f));
			iTween.RotateTo(ViewCardObject, iTween.Hash("z", 0f, "time", 0.3f, "oncompletetarget", base.gameObject, "oncomplete", "OnAnimationOver"));
			ViewCardObject.transform.localPosition = new Vector3(0f, 0f, -100f);
		}
	}

	private void OnCloseCardViewMode()
	{
		if (!IsAnimationPlaying && isCardViewMode)
		{
			IsAnimationPlaying = true;
			RemoveCardViewMode();
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL);
			CardBasePrm.CharaType charType = CardData.CharType;
			GameObject target = null;
			if (CardBasePrm.IsSpellCard(charType))
			{
				target = SpellCardObject;
			}
			else if (CardBasePrm.IsAmuletCard(charType))
			{
				target = FieldCardObject;
			}
			else if (CardBasePrm.IsFollowerCard(charType))
			{
				target = UnitCardObject;
			}
			iTween.MoveTo(target, iTween.Hash("islocal", true, "z", kCARD_POS_Z, "time", 0.3f, "oncompletetarget", base.gameObject, "oncomplete", "OnAnimationOver"));
		}
	}

	private void RemoveCardViewMode()
	{
		if (isCardViewMode)
		{
			UnityEngine.Object.Destroy(ViewCardObject);
			CardViewBG.SetActive(value: false);
			isCardViewMode = false;
		}
	}

	private void OnCloseCardViewMode(GameObject g)
	{
		OnCloseCardViewMode();
	}

	private void UpdateFavoriteButton()
	{
		_isFavorite = GameMgr.GetIns().GetDataMgr().FavoriteCardList.Contains(CardData.CardId);
		_favoriteButton.gameObject.SetActive(IsShowFavoriteButton && GetPossessionCardNum() > 0 && CardData.IsEnableFavorite && !IsRelationCardViewing);
		SetFavoriteButtonSprite(_isFavorite);
	}

	private void SetFavoriteButtonSprite(bool isFavorite)
	{
		string text = "btn_favorite_";
		string text2 = "off";
		string text3 = "on";
		_favoriteButton.normalSprite = text + (isFavorite ? text3 : text2);
		_favoriteButton.pressedSprite = text + (isFavorite ? text2 : text3);
	}

	private void OnClickFavoriteButton(GameObject g)
	{
		if (_isFavoriteButtonEnabled && GetPossessionCardNum() > 0)
		{
			_isFavoriteButtonEnabled = false;
			StartCoroutine(Timer.DelayMethod(0.9f, delegate
			{
				_isFavoriteButtonEnabled = true;
			}));
			bool flag = !_isFavorite;
			GameMgr.GetIns().GetSoundMgr().PlaySe(flag ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
			ChangeFavoriteState();
		}
	}

	private void ChangeFavoriteState()
	{
		bool is_protected = !_isFavorite;
		CardProtectTask cardProtectTask = new CardProtectTask();
		cardProtectTask.SetParameter(CardData.CardId, is_protected);
		StartCoroutine(Toolbox.NetworkManager.Connect(cardProtectTask, OnSuccessProtectCard, null, OnErrorProtectCard));
	}

	private void OnSuccessProtectCard(NetworkTask.ResultCode code)
	{
		UpdateButtonState();
		UpdateCreateLiquefyButton();
		OnChangeCardFavoriteState.Call();
	}

	private void OnErrorProtectCard(int code)
	{
		UpdateButtonState();
		UpdateCreateLiquefyButton();
	}

	private void UpdateVoiceButton()
	{
		CardVoiceData cardVoiceData = new CardVoiceData(CardData, _cardMasterId);
		bool flag = (!_isEvolCard && cardVoiceData._voiceListBeforeEvo.Count > 0) || (_isEvolCard && cardVoiceData._voiceListAfterEvo.Count > 0);
		_voiceButton.gameObject.SetActive(flag && IsShowVoiceButton && (IsPopularityVote || GetPossessionCardNum(isIncludingSpotCard: true) > 0));
	}

	private void OnClickVoiceButton(GameObject g)
	{
		_cardVoiceManager.SequentiallyPlay(CardData, _isEvolCard, _cardMasterId);
	}

	private void OnClickChangeCardTextTypeButton(GameObject g)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
		_isShowCardAblityText = !_isShowCardAblityText;
		UpdateCardText();
		UpdateButtonState();
	}

	private void UpdateEvolutionButton()
	{
		if (CardBasePrm.IsFollowerCard(CardData.CharType) && !CardData.IsEvolveChoiceCard)
		{
			CardEvolButton.gameObject.SetActive(IsShowEvolutionButton && (IsPopularityVote || GetPossessionCardNum(isIncludingSpotCard: true) > 0));
			_evolutionButtonLabel.text = Data.SystemText.Get(_isEvolCard ? "Card_0067" : "Card_0030");
		}
		else
		{
			CardEvolButton.gameObject.SetActive(value: false);
		}
	}

	private void OnClickEvolutionButton(GameObject g)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_MYPAGE_EVOLVE);
		_isEvolCard = !_isEvolCard;
		UpdateCardImage();
		UpdateCardText();
		UpdateButtonState();
		_cardVoiceManager.Stop();
		if (_evolEffect != null)
		{
			_evolEffect.Play();
			return;
		}
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("cmn_deckedit_evo_1", ResourcesManager.AssetLoadPathType.Effect2D);
		_assetPathList.Add(assetTypePath);
		StartCoroutine(Toolbox.ResourcesManager.LoadAssetAsync(assetTypePath, delegate
		{
			GameObject gameObject = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("cmn_deckedit_evo_1", ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true)) as GameObject;
			if (gameObject != null)
			{
				ParticleSystem component = gameObject.GetComponent<ParticleSystem>();
				ParticleSystem.MainModule main = component.main;
				main.playOnAwake = false;
				_evolEffect = UnityEngine.Object.Instantiate(component);
				_evolEffect.transform.parent = CardTexture.transform;
				_evolEffect.transform.localPosition = Vector3.back * 10f;
				_evolEffect.transform.localRotation = Quaternion.identity;
				_evolEffect.transform.localScale = Vector3.one * 600f;
				_evolEffect.gameObject.layer = base.gameObject.layer;
				Transform[] componentsInChildren = _evolEffect.GetComponentsInChildren<Transform>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].gameObject.layer = base.gameObject.layer;
				}
				GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(new List<GameObject> { _evolEffect.gameObject }, delegate
				{
					if ((bool)_evolEffect)
					{
						_evolEffect.gameObject.SetActive(value: true);
						_evolEffect.Play();
					}
				}, isBattle: true);
			}
		}));
	}

	private void UpdatePremiumCardConversionButton()
	{
		GameObject gameObject = _premiumCardConversionButton.gameObject;
		UIManager.SetObjectToGrey(gameObject, PlayerStaticData.UserOrbNum <= 0);
		if (!IsShowPremiumCardConversionButton || IsRelationCardViewing || GetPossessionCardNum() <= 0 || CardData.IsFoil || (CardData.IsNotCraftDestruct && !CardData.IsPreReleaseCard))
		{
			gameObject.SetActive(value: false);
		}
		else
		{
			gameObject.SetActive(value: true);
		}
	}

	private void OnClickPremiumCardConversionButton(GameObject g)
	{
		if (GetPossessionCardNum() <= 0)
		{
			return;
		}
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		if (isAnimation)
		{
			return;
		}
		SystemText systemText = Data.SystemText;
		if (PlayerStaticData.UserOrbNum <= 0)
		{
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetTitleLabel(systemText.Get("Card_0163_1"));
			dialogBase.SetText(systemText.Get("Card_0163_2"));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		}
		else if (GameMgr.GetIns().GetDataMgr().GetPossessionCardNum(CardData.FoilCardId, isIncludingSpotCard: true) >= 3)
		{
			DialogBase dialogBase2 = UIManager.GetInstance().CreateDialogClose();
			dialogBase2.SetTitleLabel(systemText.Get("Card_0164_1"));
			dialogBase2.SetText(systemText.Get("Card_0164_2"));
			dialogBase2.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		}
		else if (_isFavorite)
		{
			DialogBase dialogBase3 = UIManager.GetInstance().CreateDialogClose();
			dialogBase3.SetTitleLabel(systemText.Get("Card_0165_1"));
			dialogBase3.SetText(systemText.Get("Card_0165_2"));
			dialogBase3.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
			dialogBase3.SetButtonText(systemText.Get("Card_0165_3"));
			dialogBase3.onPushButton1 = delegate
			{
				CreatePremiumCardConversionDialog();
			};
		}
		else
		{
			CreatePremiumCardConversionDialog();
		}
	}

	private void CreatePremiumCardConversionDialog()
	{
		SystemText systemText = Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		PremiumCardConversionDialogParts premiumCardConversionDialogParts = UnityEngine.Object.Instantiate(_premiumCardConversionDialogPrefab);
		premiumCardConversionDialogParts.Initialize(CardData);
		dialogBase.SetObj(premiumCardConversionDialogParts.gameObject);
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(systemText.Get("Card_0162_1"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetButtonText(systemText.Get("Card_0162_7"));
		dialogBase.onPushButton1 = delegate
		{
			if (!_isFavorite)
			{
				ConvertPremiumCard();
			}
			else
			{
				ChangeFavoriteState();
				OnChangeCardFavoriteState = (Action)Delegate.Combine(OnChangeCardFavoriteState, new Action(ConvertPremiumCard));
			}
		};
	}

	private void ConvertPremiumCard()
	{
		OnChangeCardFavoriteState = (Action)Delegate.Remove(OnChangeCardFavoriteState, new Action(ConvertPremiumCard));
		PremiumCardConversionTask premiumCardConversionTask = new PremiumCardConversionTask();
		premiumCardConversionTask.SetParameter(CardData.CardId, GetPossessionCardNum());
		StartCoroutine(Toolbox.NetworkManager.Connect(premiumCardConversionTask, OnSuccessPremiumCardConversion));
	}

	private void OnSuccessPremiumCardConversion(NetworkTask.ResultCode code)
	{
		OnConvertedPremiumCard.Call(CardData);
		StartCoroutine(StartPremiumCardConversionAnimation());
	}

	private IEnumerator StartPremiumCardConversionAnimation()
	{
		isAnimation = true;
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_USE_RED_ETHER);
		yield return StartCoroutine(PlayCardCreateEffect(PREMIUM_CARD_CONVERSION_PARTICLE_COLOR, _premiumCardConversionButton.transform.position, _cardNumLabel.transform.position, 4));
		SetCardDetail(CardData.FoilCardId);
		isAnimation = false;
	}

	private void UpdateCreateLiquefyButton(bool isUpdateHaveRedether = true)
	{
		if (IsShowCraftButtons && !IsRelationCardViewing)
		{
			_craftPanel.gameObject.SetActive(value: true);
			_craftPanel.UpdateCraftPanel(CardData, isUpdateHaveRedether);
		}
		else
		{
			_craftPanel.gameObject.SetActive(value: false);
		}
	}

	private void StartCardDestruct()
	{
		if (!IsAbleToDestruct)
		{
			return;
		}
		CardMake component = base.gameObject.GetComponent<CardMake>();
		component.OnCardSell = delegate
		{
			if (GetPossessionCardNum() <= 0)
			{
				OnLiquefyAllCard.Call(CardData);
			}
			StartCoroutine(RunCardDestruct());
		};
		component.StartCardDestruct(CardData.CardId);
	}

	private IEnumerator RunCardDestruct()
	{
		isAnimation = true;
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_GET_RED_ETHER);
		yield return StartCoroutine(PlayCardLiquefyEffect(CARD_LIQUEFY_PARTICLE_COLOR, _cardNumLabel.transform.position, RedEtherIcon.transform.position, CardData.Rarity));
		iTween.ValueTo(base.gameObject, iTween.Hash("from", int.Parse(_redEtherHaveValueLabel.text), "to", PlayerStaticData.UserRedEtherCount, "time", 0.5f, "onupdate", "OnUpdateRedEther", "oncomplete", "OnCompleteRedEther", "easetype", iTween.EaseType.easeOutQuad));
		UpdateCardNum();
		CardShadow.gameObject.SetActive(GetPossessionCardNum(isIncludingSpotCard: true) <= 0 && !IsShortageUI);
		UpdateCardText();
		UpdateButtonState();
		OnCardNumChange.Call();
		UpdateCreateLiquefyButton(isUpdateHaveRedether: false);
		OnCardSellId.Call(CardData.CardId);
		yield return new WaitForSeconds(0.2f);
		isAnimation = false;
	}

	private IEnumerator PlayCardLiquefyEffect(Color particleColor, Vector3 particleStartPos, Vector3 particleEndPos, int particleNum)
	{
		particleStartPos += CARD_DESTROY_PARTICLE_OFFSET;
		particleEndPos += CARD_DESTROY_PARTICLE_OFFSET;
		EffectMgr effectMgr = GameMgr.GetIns().GetEffectMgr();
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_CARD_1);
		for (int i = 0; i < CardData.Rarity; i++)
		{
			effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_TRACK_1);
		}
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_ICON_1);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_1);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_2);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_3);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_4);
		effectMgr.Start(EffectMgr.EffectType.CMN_CRAFT_CARD_1, CardTexture.transform.position).ChangeParticleColor(particleColor);
		for (int j = 0; j < particleNum; j++)
		{
			Effect effect = effectMgr.Start(EffectMgr.EffectType.CMN_CRAFT_TRACK_1, particleStartPos);
			effect.ChangeParticleColor(particleColor);
			Vector3 vector = new Vector3(UnityEngine.Random.value * 3f - 1.5f, UnityEngine.Random.value * 3f - 1.5f, -1f);
			Vector3[] bezierQuad = MotionUtils.GetBezierQuad(particleStartPos, particleStartPos + vector, particleEndPos, 10);
			iTween.MoveTo(effect.GetGameObjIns(), iTween.Hash("path", bezierQuad, "time", 0.5f, "movetopath", false, "easetype", iTween.EaseType.linear));
		}
		yield return new WaitForSeconds(0.5f);
		effectMgr.Start(EffectMgr.EffectType.CMN_CRAFT_ICON_1, particleEndPos).ChangeParticleColor(particleColor);
		EffectMgr.EffectType type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_1;
		switch (particleNum)
		{
		case 1:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_1;
			break;
		case 2:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_2;
			break;
		case 3:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_3;
			break;
		case 4:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_4;
			break;
		}
		effectMgr.Start(type, particleEndPos).ChangeParticleColor(particleColor);
	}

	private void StartCardCraft()
	{
		if (!IsAbleToCraft)
		{
			return;
		}
		CardMake component = base.gameObject.GetComponent<CardMake>();
		component.OnCardBuy = delegate
		{
			if (GetPossessionCardNum(isIncludingSpotCard: true) == 1)
			{
				OnCreateFirstCard.Call();
			}
			StartCoroutine(RunCardCraft());
		};
		component.StartCardCraft(CardData.CardId);
	}

	private IEnumerator RunCardCraft()
	{
		isAnimation = true;
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_USE_RED_ETHER);
		yield return StartCoroutine(PlayCardCreateEffect(CARD_CREATE_PARTICLE_COLOR, RedEtherIcon.transform.position, _cardNumLabel.transform.position, CardData.Rarity));
		iTween.ValueTo(base.gameObject, iTween.Hash("from", int.Parse(_redEtherHaveValueLabel.text), "to", PlayerStaticData.UserRedEtherCount, "time", 0.5f, "onupdate", "OnUpdateRedEther", "oncomplete", "OnCompleteRedEther", "easetype", iTween.EaseType.easeOutQuad));
		UpdateCardNum();
		CardShadow.gameObject.SetActive(value: false);
		UpdateCardText();
		UpdateButtonState();
		UpdateCreateLiquefyButton(isUpdateHaveRedether: false);
		OnCardNumChange.Call();
		OnCardBuy.Call();
		yield return new WaitForSeconds(0.2f);
		isAnimation = false;
	}

	private IEnumerator PlayCardCreateEffect(Color particleColor, Vector3 particleStartPos, Vector3 particleEndPos, int particleNum)
	{
		EffectMgr effectMgr = GameMgr.GetIns().GetEffectMgr();
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_ICON_1);
		for (int i = 0; i < particleNum; i++)
		{
			effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_TRACK_1);
		}
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_CARD_2);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_1);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_2);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_3);
		effectMgr.Stop(EffectMgr.EffectType.CMN_CRAFT_SPLASH_4);
		effectMgr.Start(EffectMgr.EffectType.CMN_CRAFT_ICON_1, particleStartPos).ChangeParticleColor(particleColor);
		for (int j = 0; j < particleNum; j++)
		{
			Effect effect = effectMgr.Start(EffectMgr.EffectType.CMN_CRAFT_TRACK_1, particleStartPos);
			effect.ChangeParticleColor(particleColor);
			Vector3 vector = new Vector3(UnityEngine.Random.value * 3f - 1.5f, UnityEngine.Random.value * 3f - 1.5f, -1f);
			Vector3[] bezierQuad = MotionUtils.GetBezierQuad(particleStartPos, particleStartPos + vector, particleEndPos, 10);
			iTween.MoveTo(effect.GetGameObjIns(), iTween.Hash("path", bezierQuad, "time", 0.5f, "movetopath", false, "easetype", iTween.EaseType.linear));
		}
		yield return new WaitForSeconds(0.5f);
		effectMgr.Start(EffectMgr.EffectType.CMN_CRAFT_CARD_2, CardTexture.transform.position + Vector3.back);
		EffectMgr.EffectType type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_1;
		switch (particleNum)
		{
		case 1:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_1;
			break;
		case 2:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_2;
			break;
		case 3:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_3;
			break;
		case 4:
			type = EffectMgr.EffectType.CMN_CRAFT_SPLASH_4;
			break;
		}
		effectMgr.Start(type, particleEndPos).ChangeParticleColor(particleColor);
	}

	private void OnUpdateRedEther(int value)
	{
		_redEtherHaveValueLabel.text = value.ToString();
	}

	private void OnCompleteRedEther()
	{
		_redEtherHaveValueLabel.text = PlayerStaticData.UserRedEtherCount.ToString();
	}

	private void CreateDialog(Action onOk, bool buy)
	{
		if (!isAnimation)
		{
			_craftDialog = UIManager.GetInstance().CreateDialogClose();
			_craftDialog.onPushButton1 = onOk;
			PurchaseConfirm purchaseConfirm = UnityEngine.Object.Instantiate(PurchaseConfirmPrefab);
			_craftDialog.SetObj(purchaseConfirm.gameObject);
			int userRedEtherCount = PlayerStaticData.UserRedEtherCount;
			SystemText systemText = Data.SystemText;
			if (buy)
			{
				_craftDialog.SetTitleLabel(systemText.Get("Card_0081"));
				_craftDialog.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
				_craftDialog.SetButtonText(systemText.Get("Dia_CardList_003_Button"));
				int useRedEther = CardData.UseRedEther;
				purchaseConfirm.SetCardBuy(systemText.Get("Common_0205"), userRedEtherCount, useRedEther, CardData);
			}
			else
			{
				_craftDialog.SetTitleLabel(systemText.Get("Card_0080"));
				_craftDialog.SetButtonLayout(DialogBase.ButtonLayout.RedBtn_CancelBtn);
				_craftDialog.SetButtonText(systemText.Get("Dia_CardList_002_Button"));
				int getRedEther = CardData.GetRedEther;
				purchaseConfirm.SetCardSell(systemText.Get("Common_0205"), userRedEtherCount, getRedEther, CardData.CardName, CardData.IsFoil);
			}
		}
	}

	private IEnumerator DelayResetScrollViewPosition()
	{
		yield return null;
		ResetScrollViewPosition();
	}

	private void ResetScrollViewPosition()
	{
		UnitCardTextScrollView.ResetPosition();
		SpellCardTextScrollView.ResetPosition();
		SettingCardTextScrollView.ResetPosition();
		UnitCardTextScrollView.UpdateScrollbars(recalculateBounds: true);
		SpellCardTextScrollView.UpdateScrollbars(recalculateBounds: true);
		SettingCardTextScrollView.UpdateScrollbars(recalculateBounds: true);
	}

	private void ChangeLayer(GameObject o, int layer)
	{
		o.layer = layer;
		for (int i = 0; i < o.transform.childCount; i++)
		{
			ChangeLayer(o.transform.GetChild(i).gameObject, layer);
		}
	}

	public bool GetIsDetailOn()
	{
		return isDetailOn;
	}

	public void SetDisableArrowButton()
	{
		OnDetailCardUpdate = delegate
		{
			RightButtonVisible = false;
			LeftButtonVisible = false;
		};
	}

	public void SetEnableButtons(bool isEnable)
	{
		for (int i = 0; i < _enableButtonList.Length; i++)
		{
			_enableButtonList[i].isEnabled = isEnable;
		}
		_isAbleTapDialogObject = isEnable;
		if (isEnable)
		{
			UpdateButtonState();
			UpdateCreateLiquefyButton();
		}
	}

	private void LateUpdate()
	{
		if (!UIManager.GetInstance().IsCurrentScene(UIManager.ViewScene.QuestSelectionPage))
		{
			return;
		}
		for (int i = 0; i < base.transform.childCount; i++)
		{
			Transform child = base.transform.GetChild(i);
			if (child.name != "CardTexture" && child.name != "CardText")
			{
				AllLabelColorChanger.ChangeAllLabel(child.gameObject, AllLabelColorChanger.COLOR_TABLE_DETAIL);
			}
		}
	}

	public void SetSortOrder(int sortOrder)
	{
		for (int i = 0; i < _allPanel.Length; i++)
		{
			_allPanel[i].sortingOrder = sortOrder + i;
		}
	}
}
