using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Cute;
using UnityEngine;
using Wizard;

public class UIBase_CardManager : MonoBehaviour
{
	public enum LOAD_KIND
	{
		MYPAGE_HOME_DEFAULT_DECK_DATA,
		SELECT_DATA,
		SELECT_DATA_GACHA,
		MYPAGE_HOME_CUSTOM_DECK
	}

	public enum ScrollType
	{
		HORIZONTAL,
		VERTICAL
	}

	private enum AddCardResult
	{
		ADDED,
		NOT_ADDED,
		END
	}

	public class CardObjData
	{
		public GameObject CardObj;

		public string Cost;

		public int CostNum;

		public int mainCardNum;

		public int subCardNum;

		public int ids;

		public string lifes;

		public int LifesNum;

		public string Atks;

		public int AtksNum;

		public string Names;

		public string Skills;

		public string Evo_Costs;

		public string Evo_lifes;

		public string Evo_Atks;

		public string Evo_Names;

		public string Evo_Skills;

		public bool EvolOk;

		public CardBasePrm.ClanType clan;

		public List<CardBasePrm.TribeType> tribe;

		public CardBasePrm.CharaType cardType;

		public bool isPremiere;

		public bool off;

		public int TotalCardNum => mainCardNum + subCardNum;
	}

	public class CardPrefabs
	{
		public GameObject SpellGameObj;

		public GameObject SpellGameObj_LG;

		public GameObject SpellSpecGameObj;

		public GameObject FieldGameObj;

		public GameObject FieldSpecGameObj;

		public GameObject UnitGameObj;

		public GameObject UnitSpecGameObj;

		public GameObject UnitGameObj_SR;

		public GameObject UnitGameObj_LG;

		public GameObject m_CardBase;

		public GameObject m_EPIcon;

		public GameObject m_AtkIcon;

		public GameObject m_LifeIcon;

		public GameObject m_CostIcon;

		public GameObject m_NameIcon;

		public Material BaseTexBase;

		public Material SpecularMaterial;

		public GameObject RotationOnlyIcon { get; set; }
	}

	public class LoadCondition
	{
		public Dictionary<int, int> CurrentIds;

		public int MaxCards;

		public int MaxSameCard;

		public LoadCondition(Dictionary<int, int> currentids, int maxCards, int maxSameCard)
		{
			CurrentIds = currentids;
			MaxCards = maxCards;
			MaxSameCard = maxSameCard;
		}

		public LoadCondition()
		{
			CurrentIds = new Dictionary<int, int>();
			MaxCards = 99999999;
			MaxSameCard = 9999999;
		}
	}

	public class ComparableCard : IComparable<ComparableCard>
	{
		private CardParameter prm;

		public ComparableCard(int id, CardMaster.CardMasterId cardMasterId)
		{
			prm = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(id);
		}

		public int CompareTo(ComparableCard other)
		{
			return prm.SortIndex.CompareTo(other.prm.SortIndex);
		}
	}

	public class FilterParameter
	{
		public enum LookBit
		{
			ALL,
			NORMAL,
			PREMIUM
		}

		public enum FavoriteBit
		{
			ALL,
			NORMAL,
			FAVORITE
		}

		public enum SpotBit
		{
			ALL,
			NORMAL,
			SPOT
		}

		public const int FILTER_COST_MAX = 8;

		public const int FILTER_ATTACK_MAX = 8;

		public const int FILTER_LIFE_MAX = 8;

		public int Cost;

		public int Class;

		public int Foil;

		public int Type;

		public int Rarity;

		public int Favorite;

		public int Spot;

		public int Own;

		public int Craftable;

		public int Attack;

		public int Life;

		public string Word;

		public Format FormatState = Format.Max;

		public MyRotationInfo MyRotationInfoForFormatAvailable;

		public List<string> KeyWordList;

		public List<CardBasePrm.TribeType> TypeFilter;

		public List<string> CardSetIdList;

		public List<string> DisableCardSetidList = new List<string>();

		public List<string> CardSetIdList2 = new List<string>();

		public bool IsEnabledPrizeCard;

		public bool IsEnabledPhantomCard;

		public string CharacterVoice;

		public bool IsEnableResurgentCard = true;

		public ClassSet FixedClassSet;

		public FilterParameter(FilterParameter param)
		{
			Cost = param.Cost;
			Class = param.Class;
			Foil = param.Foil;
			Type = param.Type;
			Rarity = param.Rarity;
			Favorite = param.Favorite;
			Spot = param.Spot;
			Own = param.Own;
			Craftable = param.Craftable;
			Attack = param.Attack;
			Life = param.Life;
			Word = param.Word;
			FormatState = param.FormatState;
			KeyWordList = param.KeyWordList;
			TypeFilter = param.TypeFilter;
			CardSetIdList = param.CardSetIdList;
			DisableCardSetidList = param.DisableCardSetidList;
			CardSetIdList2 = param.CardSetIdList2;
			IsEnabledPrizeCard = param.IsEnabledPrizeCard;
			IsEnabledPhantomCard = param.IsEnabledPhantomCard;
			CharacterVoice = param.CharacterVoice;
			IsEnableResurgentCard = param.IsEnableResurgentCard;
			FixedClassSet = param.FixedClassSet;
		}

		public FilterParameter()
		{
			CardSetIdList = new List<string>();
		}

		public bool IsLookState(LookBit bit)
		{
			if (bit == LookBit.ALL)
			{
				if (Foil != 0)
				{
					if (IsLookState(LookBit.NORMAL))
					{
						return IsLookState(LookBit.PREMIUM);
					}
					return false;
				}
				return true;
			}
			return ((uint)Foil & (uint)bit) != 0;
		}

		public bool IsFavoriteState(FavoriteBit bit)
		{
			if (bit == FavoriteBit.ALL)
			{
				if (Favorite != 0)
				{
					if (IsFavoriteState(FavoriteBit.NORMAL))
					{
						return IsFavoriteState(FavoriteBit.FAVORITE);
					}
					return false;
				}
				return true;
			}
			return ((uint)Favorite & (uint)bit) != 0;
		}

		public bool IsSpotState(SpotBit bit)
		{
			if (bit == SpotBit.ALL)
			{
				if (Spot != 0)
				{
					if (IsSpotState(SpotBit.NORMAL))
					{
						return IsSpotState(SpotBit.SPOT);
					}
					return false;
				}
				return true;
			}
			return ((uint)Spot & (uint)bit) != 0;
		}

		public static bool operator ==(FilterParameter lhs, FilterParameter rhs)
		{
			FieldInfo[] fields = typeof(FilterParameter).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo obj in fields)
			{
				object value = obj.GetValue(lhs);
				object value2 = obj.GetValue(rhs);
				if ((value == null) ^ (value2 == null))
				{
					return false;
				}
				if (value != null && !value.Equals(value2))
				{
					return false;
				}
			}
			return true;
		}

		public static bool operator !=(FilterParameter lhs, FilterParameter rhs)
		{
			return !(lhs == rhs);
		}

		public override bool Equals(object obj)
		{
			return base.Equals(obj);
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
	}

	private readonly Vector3 NormalScale = new Vector3(70f, 70f, 2f);

	private readonly Vector3 ZoomedScale = new Vector3(80f, 80f, 1f);

	private readonly Vector3 DetailScale = new Vector3(200f, 200f, 100f);

	public const string SPECULAR_UNIT_0 = "tx_Card_Unit_a_4";

	public const string SPECULAR_UNIT_1 = "tx_Card_Unit_n_4";

	public const string SPECULAR_SPELL_0 = "tx_Card_Spell_a_3";

	public const string SPECULAR_SPELL_1 = "tx_Card_Spell_n_3";

	public const string SPECULAR_AMULET_0 = "tx_Card_Field_a_3";

	public const string SPECULAR_AMULET_1 = "tx_Card_Field_n_3";

	public const string ROTATION_ONLY_ICON_NAME = "RotationOnlyIcon";

	private static readonly Color32 PREMIERE_GRADIENT_TOP_COLOR = new Color32(byte.MaxValue, 243, 176, byte.MaxValue);

	private static readonly Color32 PREMIERE_GRADIENT_BOTTOM_COLOR = new Color32(186, 150, 0, byte.MaxValue);

	private static readonly Color32 EFFECT_COLOR = new Color32(92, 56, 3, byte.MaxValue);

	private LOAD_KIND loadKind;

	private List<GameObject> normalCards;

	private List<GameObject> evoCards;

	private bool CreateEndFlag;

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

	private List<CardObjData> CardListObjs;

	private List<CardObjData> SelectCardListObjs;

	private List<CardObjData> CardList2DObjs;

	private List<CardObjData> AllCardList2DObjs;

	private IList<int> SelectedCardIDList;

	private List<CardObjData> SelectedCardList2DObjs;

	private List<Texture> CardList2DTextures;

	private IDictionary<int, int> CardList2DDict;

	private NetworkManager networkManager;

	private Transform ScrollViewHorGrid;

	private int loadCnt;

	[SerializeField]
	private UIFont _NormalCardFont;

	[SerializeField]
	private UIFont _PremiereCardFont;

	private long SleeveId = 3000011L;

	private Material DeckBaseTexBase;

	private DeckData _myPageHomeDeck;

	private IList<TweenScale> m_CardList = new List<TweenScale>();

	private IList<GameObject> m_DCardList = new List<GameObject>();

	private bool _wizardSetUpFinish;

	private IList<int> loadSelectIds;

	private IDictionary<int, CardParameter> DetailBasePrmList;

	public bool isAssetAllReady;

	private bool isReadyTemplate;

	private CardKeyWordCommonCache _keyWordCommonCache;

	private CardKeyWordCache _keyWordCache;

	private CardKeyWordCache _cardNameKeyWordCache;

	private CardKeyWordCache _cardNameKeyWordHiraganaCache;

	public const string BBCodePattern = "(\\[[a-zA-Z0-9\\/\\-]*(rub\\<[^\\>]*\\>)*\\])";

	public _3dCardFrameManager _3dCardFrameManager { get; private set; } = new _3dCardFrameManager();

	private void DisposeAllCardListData()
	{
		ScrollViewHorGrid = null;
		networkManager = null;
		m_CardList = null;
		m_DCardList = null;
	}

	private void Start()
	{
		StartCoroutine(WaitCallBack());
	}

	private IEnumerator WaitCallBack()
	{
		while (!Global.IS_LOAD_ALLDONE)
		{
			yield return null;
		}
		SetNetWorkManager();
		Init();
	}

	private void SetNetWorkManager()
	{
		if (networkManager == null)
		{
			networkManager = Toolbox.NetworkManager;
		}
	}

	private void Init()
	{
		GameMgr.GetIns().GetGameObjMgr().GetUIContainer()
			.SetActive(value: true);
		_wizardSetUpFinish = true;
	}

	public bool IsWizardSetupFinish()
	{
		return _wizardSetUpFinish;
	}

	public bool getCreateEndFlag()
	{
		return CreateEndFlag;
	}

	private List<string> GetAddUnitPathList()
	{
		return new List<string>
		{
			Toolbox.ResourcesManager.GetAssetTypePath("Unit", ResourcesManager.AssetLoadPathType.HandCard),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_unit", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_unit_low", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_unit_specular", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("UnitCardFrameSpecularMat", ResourcesManager.AssetLoadPathType.CardFrameMaterialPlus),
			Toolbox.ResourcesManager.GetAssetTypePath("SpecularUnit", ResourcesManager.AssetLoadPathType.HandCardSpecular),
			Toolbox.ResourcesManager.GetAssetTypePath("tx_Card_Unit_a_4", ResourcesManager.AssetLoadPathType.CardFrameTextureCommon),
			Toolbox.ResourcesManager.GetAssetTypePath("tx_Card_Unit_n_4", ResourcesManager.AssetLoadPathType.CardFrameTextureCommon)
		};
	}

	private List<string> GetAddSpellPathList()
	{
		return new List<string>
		{
			Toolbox.ResourcesManager.GetAssetTypePath("Spell", ResourcesManager.AssetLoadPathType.HandCard),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell_low", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell_specular", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("SpellCardFrameSpecularMat", ResourcesManager.AssetLoadPathType.CardFrameMaterialPlus),
			Toolbox.ResourcesManager.GetAssetTypePath("SpecularSpell", ResourcesManager.AssetLoadPathType.HandCardSpecular),
			Toolbox.ResourcesManager.GetAssetTypePath("tx_Card_Spell_a_3", ResourcesManager.AssetLoadPathType.CardFrameTextureCommon),
			Toolbox.ResourcesManager.GetAssetTypePath("tx_Card_Spell_n_3", ResourcesManager.AssetLoadPathType.CardFrameTextureCommon)
		};
	}

	private List<string> GetAddFieldPathList()
	{
		return new List<string>
		{
			Toolbox.ResourcesManager.GetAssetTypePath("Field", ResourcesManager.AssetLoadPathType.HandCard),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_field", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_field_low", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("md_card_field_specular", ResourcesManager.AssetLoadPathType.CardFrameMesh),
			Toolbox.ResourcesManager.GetAssetTypePath("FieldCardFrameSpecularMat", ResourcesManager.AssetLoadPathType.CardFrameMaterialPlus),
			Toolbox.ResourcesManager.GetAssetTypePath("SpecularField", ResourcesManager.AssetLoadPathType.HandCardSpecular),
			Toolbox.ResourcesManager.GetAssetTypePath("tx_Card_Field_a_3", ResourcesManager.AssetLoadPathType.CardFrameTextureCommon),
			Toolbox.ResourcesManager.GetAssetTypePath("tx_Card_Field_n_3", ResourcesManager.AssetLoadPathType.CardFrameTextureCommon)
		};
	}

	public List<string> AddAssetPath(List<int> List, bool is2D, CardMaster.CardMasterId cardMasterId, bool isAddSleeve = true, long sleeveId = 3000011L)
	{
		List<string> list = new List<string>();
		for (int i = 0; i < List.Count; i++)
		{
			CardParameter cardParameterFromId = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(List[i]);
			int resourceCardId = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(cardParameterFromId.NormalCardId).ResourceCardId;
			if (cardParameterFromId.CharType == CardBasePrm.CharaType.NORMAL)
			{
				string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.UnitCardMaterial);
				if (!list.Contains(assetTypePath))
				{
					list.Add(assetTypePath);
				}
				continue;
			}
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.SpellCardMaterial);
			if (CardMaster.IsMutationCardCheck(cardParameterFromId.BaseCardId))
			{
				assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.UnitCardMaterial);
			}
			if (!list.Contains(assetTypePath2))
			{
				list.Add(assetTypePath2);
			}
		}
		if (isAddSleeve)
		{
			SleeveId = Toolbox.ResourcesManager.GetExistingSleeveId(sleeveId);
			string assetTypePath3 = Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial);
			if (!list.Contains(assetTypePath3))
			{
				list.Add(assetTypePath3);
				list.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture));
				if (Data.Master.SleeveMgr.Get(SleeveId).IsPremiumSleeve)
				{
					list.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureMask));
				}
			}
		}
		return list;
	}

	private void AddCardAssetPath(List<int> List, int page, int perPage, CardMaster.CardMasterId cardMasterId, bool is2D = false, bool isAddSleeve = true)
	{
		for (int i = 0; i < List.Count; i++)
		{
			if ((i < page * perPage || i >= Mathf.Abs((page + 1) * perPage)) && page != -1)
			{
				continue;
			}
			CardParameter cardParameterFromId = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(List[i]);
			int resourceCardId = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(cardParameterFromId.NormalCardId).ResourceCardId;
			if (cardParameterFromId.CharType == CardBasePrm.CharaType.NORMAL)
			{
				string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.UnitCardMaterial);
				Toolbox.ResourcesManager.CardListAssetPathList.Add(assetTypePath);
				continue;
			}
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.SpellCardMaterial);
			if (CardMaster.IsMutationCardCheck(cardParameterFromId.BaseCardId))
			{
				assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(resourceCardId.ToString(), ResourcesManager.AssetLoadPathType.UnitCardMaterial);
			}
			Toolbox.ResourcesManager.CardListAssetPathList.Add(assetTypePath2);
		}
		if (!is2D && isAddSleeve)
		{
			DeckData myPageHomeDeck = _myPageHomeDeck;
			SleeveId = ((myPageHomeDeck == null) ? 3000011 : Toolbox.ResourcesManager.GetExistingSleeveId(myPageHomeDeck.GetDeckSleeveID()));
			string assetTypePath3 = Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial);
			if (!Toolbox.ResourcesManager.CardListAssetPathList.Contains(assetTypePath3))
			{
				Toolbox.ResourcesManager.CardListAssetPathList.Add(assetTypePath3);
				Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture));
			}
		}
	}

	public bool MyPageHomeCreateCustomDeckCard(GameObject returnObj, DeckData deckData, int layer, bool is2D, Action onFinish = null)
	{
		isAssetAllReady = false;
		isReadyTemplate = false;
		_myPageHomeDeck = deckData;
		return MyPageCreateDeckCard(returnObj, deckData, layer, is2D, onFinish);
	}

	private bool MyPageCreateDeckCard(GameObject returnObj, DeckData deck, int layer, bool is2D, Action onFinish)
	{
		if (is2D)
		{
			Toolbox.ResourcesManager.RemoveAssetGroup(Toolbox.ResourcesManager.Card2DAssetPathList);
			Toolbox.ResourcesManager.Card2DAssetPathList.Clear();
			if (CardList2DDict == null)
			{
				CardList2DDict = new Dictionary<int, int>();
			}
			else
			{
				CardList2DDict.Clear();
			}
		}
		else
		{
			Toolbox.ResourcesManager.RemoveAssetGroup(Toolbox.ResourcesManager.Card2DAssetPathList);
			Toolbox.ResourcesManager.Card2DAssetPathList.Clear();
			Toolbox.ResourcesManager.RemoveAssetGroup(Toolbox.ResourcesManager.Card3DAssetPathList);
			Toolbox.ResourcesManager.Card3DAssetPathList.Clear();
		}
		CreateEndFlag = false;
		if (!deck.IsNoCard())
		{
			GameMgr.GetIns().GetDataMgr().SetCurrentDeckData(deck.GetCardIdList());
			List<string> list;
			if (is2D)
			{
				list = Toolbox.ResourcesManager.Card2DAssetPathList;
			}
			else
			{
				list = Toolbox.ResourcesManager.Card3DAssetPathList;
				if (DetailBasePrmList == null)
				{
					DetailBasePrmList = new Dictionary<int, CardParameter>();
				}
				else
				{
					DetailBasePrmList.Clear();
				}
			}
			if (deck.IsDefaultDeck())
			{
				list.AddRange(AddAssetPath(deck.GetCardIdList(), is2D, CardMaster.CardMasterId.Default, isAddSleeve: false, 3000011L));
			}
			else
			{
				list.AddRange(AddAssetPath(deck.GetCardIdList(), is2D, CardMaster.CardMasterId.Default, isAddSleeve: true, deck.GetDeckSleeveID()));
			}
			StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupSync(list, delegate
			{
				if (deck.IsDefaultDeck())
				{
					SleeveId = 3000011L;
					loadKind = LOAD_KIND.MYPAGE_HOME_DEFAULT_DECK_DATA;
				}
				else
				{
					if (SleeveId == 0L)
					{
						SleeveId = 3000011L;
					}
					loadKind = LOAD_KIND.MYPAGE_HOME_CUSTOM_DECK;
				}
				StartCoroutine(CreateDeckData(layer, is2D, CardMaster.CardMasterId.Default, CardBasePrm.ClanType.NONE, own: false, onFinish));
				isAssetAllReady = true;
			}));
			return true;
		}
		onFinish();
		isAssetAllReady = true;
		return false;
	}

	public IList<int> SelectCardIDInConditionMask(List<int> idList, FilterParameter filterParam, IFormatBehavior formatBehaviour, MyRotationInfo myRotationInfo, bool alreadySorted = false, bool isCraftMode = false, bool isDisableAllTribe = false)
	{
		CardMaster cardMaster = CardMaster.GetInstance(formatBehaviour.CardMasterId);
		if (_keyWordCache == null)
		{
			_keyWordCache = new CardKeyWordCache();
		}
		if (_cardNameKeyWordCache == null)
		{
			_cardNameKeyWordCache = new CardKeyWordCache(CardKeyWordCache.Option.OnlyCardNames);
		}
		if (_cardNameKeyWordHiraganaCache == null)
		{
			_cardNameKeyWordHiraganaCache = new CardKeyWordCache(CardKeyWordCache.Option.OnlyCardNamesHiranaga);
		}
		Func<CardParameter, FilterParameter, bool> filters = null;
		if (formatBehaviour.IsConventionMode)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => formatBehaviour.GetPossessionCardNum(card.CardId, isIncludingSpotCard: true) > 0));
		}
		else
		{
			if (filterParam.Own != 0)
			{
				filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
				{
					int possessionCardNum = formatBehaviour.GetPossessionCardNum(card.CardId, isIncludingSpotCard: true);
					return (param.Own & ((possessionCardNum > 0) ? 1 : 2)) != 0;
				});
			}
			if (filterParam.Craftable != 0)
			{
				filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
				{
					int possessionCardNum = formatBehaviour.GetPossessionCardNum(card.CardId, isIncludingSpotCard: true);
					int num = ((card.UseRedEther > 0) ? 1 : 2);
					return possessionCardNum > 0 || (param.Craftable & num) != 0;
				});
			}
		}
		if (filterParam.Class != 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => (param.Class & (1 << (int)card.Clan)) != 0));
		}
		if (filterParam.Cost != 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => (param.Cost & (1 << Mathf.Min(card.Cost, 8))) != 0));
		}
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.Attack != 0 && !CardBasePrm.IsFollowerCard(card.CharType))
			{
				return false;
			}
			return param.Attack == 0 || (param.Attack & (1 << Mathf.Min(card.Atk, 8))) != 0;
		});
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.Life != 0 && !CardBasePrm.IsFollowerCard(card.CharType))
			{
				return false;
			}
			return param.Life == 0 || (param.Life & (1 << Mathf.Min(card.Life, 8))) != 0;
		});
		if (filterParam.Foil != 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => (param.Foil & ((!card.IsFoil) ? 1 : 2)) != 0));
		}
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.Type == 0)
			{
				return true;
			}
			int num = 0;
			switch (card.CharType)
			{
			case CardBasePrm.CharaType.NORMAL:
			case CardBasePrm.CharaType.EVOLUTION:
				num = 1;
				break;
			case CardBasePrm.CharaType.SPELL:
				num = 2;
				break;
			case CardBasePrm.CharaType.FIELD:
			case CardBasePrm.CharaType.CHANT_FIELD:
				num = 4;
				break;
			default:
				return false;
			}
			return (param.Type & num) != 0;
		});
		if (filterParam.Rarity != 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => (param.Rarity & (1 << card.Rarity - 1)) != 0));
		}
		if (filterParam.DisableCardSetidList.Count > 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => !param.DisableCardSetidList.Contains(card.CardSetId)));
		}
		if (filterParam.CardSetIdList2.Count > 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
			{
				if (param.FormatState == Format.MyRotation)
				{
					if (card.IsPrizeCard)
					{
						card = cardMaster.GetCardParameterFromId(card.BaseCardId);
					}
					if (myRotationInfo.IsNotUseCard(card.BaseCardId))
					{
						return false;
					}
					if (myRotationInfo.IsRePrintCard(card.BaseCardId))
					{
						foreach (string item in param.CardSetIdList2)
						{
							if (myRotationInfo.IsRePrintCardAvailablePack(card.BaseCardId, item))
							{
								return true;
							}
						}
					}
				}
				return param.CardSetIdList2.Contains(card.CardSetId) ? true : false;
			});
		}
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.CardSetIdList.Count == 0 && !param.IsEnabledPrizeCard && !param.IsEnabledPhantomCard)
			{
				return true;
			}
			string cardSetId = card.CardSetId;
			if (card.IsCollaboCard)
			{
				cardSetId = CardMaster.GetInstance(formatBehaviour.CardMasterId).GetCardParameterFromId(card.BaseCardId).CardSetId;
			}
			if (param.CardSetIdList.Contains(cardSetId))
			{
				return true;
			}
			if (param.IsEnabledPrizeCard && card.IsPrizeCard)
			{
				return true;
			}
			return (param.IsEnabledPhantomCard && card.IsPhantomCard) ? true : false;
		});
		if (!filterParam.IsEnableResurgentCard)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => !card.IsResurgentCard));
		}
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.IsFavoriteState(FilterParameter.FavoriteBit.ALL))
			{
				return true;
			}
			bool flag = GameMgr.GetIns().GetDataMgr().FavoriteCardList.Contains(card.CardId);
			return (param.IsFavoriteState(FilterParameter.FavoriteBit.NORMAL) && !flag) || (param.IsFavoriteState(FilterParameter.FavoriteBit.FAVORITE) && flag);
		});
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.IsSpotState(FilterParameter.SpotBit.ALL) || (param.IsSpotState(FilterParameter.SpotBit.NORMAL) && param.IsSpotState(FilterParameter.SpotBit.SPOT)))
			{
				return true;
			}
			bool flag = GameMgr.GetIns().GetDataMgr().SpotCardData.ExistsSpotCard(card.CardId);
			if (isCraftMode)
			{
				if (param.IsSpotState(FilterParameter.SpotBit.SPOT))
				{
					return flag;
				}
				return true;
			}
			return param.IsSpotState(FilterParameter.SpotBit.SPOT) ? flag : (GameMgr.GetIns().GetDataMgr().GetPossessionCardNum(card.CardId, isIncludingSpotCard: false) > 0);
		});
		if (filterParam.MyRotationInfoForFormatAvailable != null)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
			{
				if (card.IsPrizeCard)
				{
					card = cardMaster.GetCardParameterFromId(card.BaseCardId);
				}
				ClassType classType = ClassUtil.GetClassType(card, param.FormatState, param.FixedClassSet);
				return card.IsAvailableFormat(param.FormatState, classType, myRotationInfo);
			});
		}
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.FormatState == Format.Unlimited || param.FormatState == Format.Rotation || param.FormatState == Format.PreRotation || param.FormatState == Format.Sealed || param.FormatState == Format.Crossover)
			{
				ClassType classType = ClassUtil.GetClassType(card, param.FormatState, param.FixedClassSet);
				return card.IsAvailableFormat(param.FormatState, classType, myRotationInfo);
			}
			return true;
		});
		if (filterParam.KeyWordList != null && filterParam.KeyWordList.Count > 0)
		{
			List<string> filterKeywordList = filterParam.KeyWordList;
			foreach (KeyValuePair<string, string> item2 in Data.Master.CardFilterKeywordReplaceDic)
			{
				if (filterKeywordList.Contains(item2.Value))
				{
					List<string> list = new List<string>(filterKeywordList.Count + 1);
					list.AddRange(filterKeywordList);
					list.Add(item2.Key);
					filterKeywordList = list;
				}
			}
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
			{
				IList<string> list2 = _keyWordCache.Get(card, _keyWordCommonCache);
				foreach (string item3 in filterKeywordList)
				{
					if (list2.Contains(item3))
					{
						return true;
					}
				}
				return false;
			});
		}
		if (filterParam.TypeFilter != null && filterParam.TypeFilter.Count > 0)
		{
			filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
			{
				if (isDisableAllTribe && card.IsTribeAll)
				{
					return false;
				}
				foreach (CardBasePrm.TribeType item4 in param.TypeFilter)
				{
					if (card.Tribe.Contains(item4))
					{
						return true;
					}
				}
				return false;
			});
		}
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)delegate(CardParameter card, FilterParameter param)
		{
			if (param.Word == null || param.Word.Length == 0)
			{
				return true;
			}
			List<string> list2 = new List<string> { CardBasePrm.GetCardTypeName(card.CharType) };
			if (!card.Tribe.Contains(CardBasePrm.TribeType.ALL))
			{
				if (card.IsTribeAll)
				{
					list2.AddRange(Data.Master.GetAllTribeNameList());
				}
				else
				{
					list2.Add(card.TribeName);
				}
			}
			list2.Add(Regex.Replace(card.ConvertedSkillDescription, "(\\[[a-zA-Z0-9\\/\\-]*(rub\\<[^\\>]*\\>)*\\])", ""));
			list2.Add(Regex.Replace(card.ConvertedEvoSkillDescription, "(\\[[a-zA-Z0-9\\/\\-]*(rub\\<[^\\>]*\\>)*\\])", ""));
			list2.Add(Regex.Replace(card.CardName, "(\\[[a-zA-Z0-9\\/\\-]*(rub\\<[^\\>]*\\>)*\\])", ""));
			string[] array = param.Word.Replace('\u3000', ' ').Split(' ');
			if (list2.Any((string src) => array.All((string req) => src.IndexOf(req, StringComparison.OrdinalIgnoreCase) >= 0)))
			{
				return true;
			}
			list2.Clear();
			CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo;
			return list2.Any((string src) => array.All((string req) => ci.IndexOf(src, req, CompareOptions.IgnoreKanaType) >= 0));
		});
		filters = (Func<CardParameter, FilterParameter, bool>)Delegate.Combine(filters, (Func<CardParameter, FilterParameter, bool>)((CardParameter card, FilterParameter param) => string.IsNullOrEmpty(param.CharacterVoice) || card.CardVoice.IndexOf(param.CharacterVoice, StringComparison.OrdinalIgnoreCase) >= 0));
		Func<CardParameter, FilterParameter, bool> callAllFilters = (CardParameter card, FilterParameter param) => filters.GetInvocationList().All((Delegate func) => ((Func<CardParameter, FilterParameter, bool>)func)(card, param));
		if (alreadySorted)
		{
			return (from id in idList
				let card = cardMaster.GetCardParameterFromId(id)
				where callAllFilters(card, filterParam)
				select id).ToList();
		}
		return (from id in idList
			let card = CardMaster.GetInstance(formatBehaviour.CardMasterId).GetCardParameterFromId(id)
			where callAllFilters(card, filterParam)
			orderby new ComparableCard(card.CardId, formatBehaviour.CardMasterId)
			select id).ToList();
	}

	public IList<int> SelectAllCardIDInConditionMask(FilterParameter filterParam, IFormatBehavior formatBehavior, MyRotationInfo myRotationInfo, bool isConventionMode, bool isCraftMode = false)
	{
		return SelectCardIDInConditionMask(formatBehavior.SortedDeckUsableCardList, filterParam, formatBehavior, myRotationInfo, alreadySorted: true, isCraftMode);
	}

	public List<int> SortIDList(IList<int> idList, CardMaster.CardMasterId cardMasterId)
	{
		return (from id in idList
			let card = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(id)
			orderby new ComparableCard(card.CardId, cardMasterId)
			select id).ToList();
	}

	public void CrateSelectCard(GameObject returnObj, IList<int> cardIds, int layer, bool is2D, Action onFinish = null, bool isDefaultSleeve = false, CardMaster.CardMasterId cardMasterId = CardMaster.CardMasterId.Default)
	{
		isAssetAllReady = false;
		if (is2D)
		{
			if (!UIManager.GetInstance().IsCurrentScene(UIManager.ViewScene.TwoPick))
			{
				Toolbox.ResourcesManager.RemoveAssetGroup(Toolbox.ResourcesManager.CardListAssetPathList);
				Toolbox.ResourcesManager.CardListAssetPathList.Clear();
			}
			if (CardList2DDict == null)
			{
				CardList2DDict = new Dictionary<int, int>();
			}
			else
			{
				CardList2DDict.Clear();
			}
		}
		SelectCardListObjs = null;
		AddCardAssetPath(cardIds.ToList(), -1, 0, cardMasterId, is2D, !isDefaultSleeve);
		bool preferSynchronousLoad = UIManager.GetInstance().IsLocked();
		StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroup(Toolbox.ResourcesManager.CardListAssetPathList, delegate
		{
			CreateEndFlag = false;
			if (isDefaultSleeve)
			{
				SleeveId = 3000011L;
			}
			else
			{
				SleeveId = ((_myPageHomeDeck == null) ? 3000011 : Toolbox.ResourcesManager.GetExistingSleeveId(_myPageHomeDeck.GetDeckSleeveID()));
			}
			loadKind = LOAD_KIND.SELECT_DATA;
			StartCoroutine(CreateDeckData(layer, is2D, cardMasterId, CardBasePrm.ClanType.MAX, own: false, onFinish));
			loadSelectIds = cardIds;
			isAssetAllReady = true;
		}, isProgress: true, preferSynchronousLoad));
	}

	public IEnumerator CreateGachaCardPack(GameObject returnObj, IList<int> cardIds, int layer, bool is2D, int sleeveId)
	{
		isAssetAllReady = false;
		if (is2D)
		{
			if (!UIManager.GetInstance().IsCurrentScene(UIManager.ViewScene.TwoPick))
			{
				Toolbox.ResourcesManager.RemoveAssetGroup(Toolbox.ResourcesManager.CardListAssetPathList);
				Toolbox.ResourcesManager.CardListAssetPathList.Clear();
			}
			if (CardList2DDict == null)
			{
				CardList2DDict = new Dictionary<int, int>();
			}
			else
			{
				CardList2DDict.Clear();
			}
		}
		SelectCardListObjs = null;
		Toolbox.ResourcesManager.CardListAssetPathList.Clear();
		AddCardAssetPath(cardIds.ToList(), -1, 0, CardMaster.CardMasterId.Default, is2D, isAddSleeve: false);
		SleeveId = Toolbox.ResourcesManager.GetExistingSleeveId(sleeveId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial);
		if (!Toolbox.ResourcesManager.CardListAssetPathList.Contains(assetTypePath))
		{
			Toolbox.ResourcesManager.CardListAssetPathList.Add(assetTypePath);
			Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture));
			Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureAORefSpec));
			Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_cardbase_s", ResourcesManager.AssetLoadPathType.SleeveSpecular));
			if (Toolbox.ResourcesManager.IsExistSleeveNormalMap(sleeveId))
			{
				Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureNormalMap));
			}
			else
			{
				Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_tx_general_n", ResourcesManager.AssetLoadPathType.SleeveTextureBasePath));
			}
			if (Data.Master.SleeveMgr.Get(SleeveId).IsPremiumSleeve)
			{
				Toolbox.ResourcesManager.CardListAssetPathList.Add(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureMask));
			}
		}
		bool isFinish = false;
		StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupSync(Toolbox.ResourcesManager.CardListAssetPathList, delegate
		{
			isFinish = true;
		}));
		while (!isFinish)
		{
			yield return null;
		}
		CreateEndFlag = false;
		loadKind = LOAD_KIND.SELECT_DATA_GACHA;
		StartCoroutine(CreateDeckData(layer, is2D, CardMaster.CardMasterId.Default));
		loadSelectIds = cardIds;
		isAssetAllReady = true;
	}

	public static void CardStatusIconOnOff(CardObjData st, bool onoff)
	{
		GameObject cardObj = st.CardObj;
		cardObj.transform.Find("Cost(Clone)").gameObject.SetActive(onoff);
		if (st.EvolOk)
		{
			cardObj.transform.Find("Atk(Clone)").gameObject.SetActive(onoff);
			cardObj.transform.Find("Life(Clone)").gameObject.SetActive(onoff);
		}
	}

	public static void CardStatusZPointArranged(CardObjData st)
	{
		GameObject cardObj = st.CardObj;
		GameObject obj = cardObj.transform.Find("Cost(Clone)").gameObject;
		Vector3 localPosition = obj.transform.localPosition;
		localPosition.z = -1f;
		obj.transform.localPosition = localPosition;
		GameObject obj2 = cardObj.transform.Find("Name(Clone)").gameObject;
		Vector3 localPosition2 = obj2.transform.localPosition;
		localPosition2.z = -1f;
		obj2.transform.localPosition = localPosition2;
		GameObject obj3 = cardObj.transform.Find("SkillDisc(Clone)").gameObject;
		Vector3 localPosition3 = obj3.transform.localPosition;
		obj3.transform.localPosition = localPosition3;
		GameObject obj4 = cardObj.transform.Find("CardBase").gameObject;
		obj4.transform.localScale = Global.CARD_BASE_SCALE;
		Vector3 localPosition4 = obj4.transform.localPosition;
		localPosition4.z = 1f;
		obj4.transform.localPosition = localPosition4;
		if (st.EvolOk)
		{
			GameObject obj5 = cardObj.transform.Find("Atk(Clone)").gameObject;
			Vector3 localPosition5 = obj5.transform.localPosition;
			localPosition5.z = -1f;
			obj5.transform.localPosition = localPosition5;
			GameObject obj6 = cardObj.transform.Find("Life(Clone)").gameObject;
			Vector3 localPosition6 = obj6.transform.localPosition;
			localPosition6.z = -1f;
			obj6.transform.localPosition = localPosition6;
		}
	}

	public static CardObjData cardDataCopy(CardObjData data, CardObjData data2)
	{
		data.Cost = data2.Cost;
		data.CostNum = data2.CostNum;
		data.lifes = data2.lifes;
		data.ids = data2.ids;
		data.Atks = data2.Atks;
		data.Names = data2.Names;
		data.Skills = data2.Skills;
		data.Evo_Costs = data2.Evo_Costs;
		data.Evo_lifes = data2.Evo_lifes;
		data.Evo_Atks = data2.Evo_Atks;
		data.Evo_Names = data2.Evo_Names;
		data.Evo_Skills = data2.Evo_Skills;
		data.EvolOk = data2.EvolOk;
		data.cardType = data2.cardType;
		data.isPremiere = data2.isPremiere;
		return data;
	}

	private IEnumerator Load2D(int scene_layer, Action<CardPrefabs> SetCardPrefab)
	{
		yield return StartCoroutine(GameMgr.GetIns().GetPrefabMgr().LoadAync("Prefab/Cards/CardListTemplate"));
		CardPrefabs cardPrefabs = new CardPrefabs();
		cardPrefabs.UnitGameObj = (cardPrefabs.SpellGameObj = GameMgr.GetIns().GetPrefabMgr().Get("Prefab/Cards/CardListTemplate"));
		GameObject spellGameObj = cardPrefabs.SpellGameObj;
		int layer = (cardPrefabs.UnitGameObj.layer = scene_layer);
		spellGameObj.layer = layer;
		SetCardPrefab(cardPrefabs);
		isReadyTemplate = true;
	}

	private IEnumerator Load3D(int scene_layer, Action<CardPrefabs> SetCardPrefab)
	{
		CardPrefabs cp = new CardPrefabs();
		yield return StartCoroutine(GameMgr.GetIns().GetPrefabMgr().LoadAync("Prefab/CardDeco/Name"));
		cp.m_NameIcon = GameMgr.GetIns().GetPrefabMgr().GetObj("Prefab/CardDeco/Name") as GameObject;
		cp.m_AtkIcon = Resources.Load("Prefab/CardDeco/Atk") as GameObject;
		cp.m_AtkIcon.layer = scene_layer;
		cp.m_AtkIcon.name = "Atk";
		cp.m_LifeIcon = Resources.Load("Prefab/CardDeco/Life") as GameObject;
		cp.m_LifeIcon.layer = scene_layer;
		cp.m_LifeIcon.name = "Life";
		cp.m_CostIcon = Resources.Load("Prefab/CardDeco/Cost") as GameObject;
		cp.m_CostIcon.layer = scene_layer;
		cp.m_CostIcon.name = "Cost";
		cp.RotationOnlyIcon = Resources.Load("Prefab/CardDeco/RotationOnlyIcon") as GameObject;
		cp.RotationOnlyIcon.layer = scene_layer;
		cp.RotationOnlyIcon.name = "RotationOnlyIcon";
		cp.m_CardBase = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_CardBase", ResourcesManager.AssetLoadPathType.CardDeco, isfetch: true));
		if (loadKind == LOAD_KIND.SELECT_DATA_GACHA)
		{
			Texture value = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureAORefSpec, isfetch: true)) as Texture;
			Material material = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_cardbase_s", ResourcesManager.AssetLoadPathType.SleeveSpecular, isfetch: true)) as Material;
			float value2 = 20f;
			Texture value3;
			if (Toolbox.ResourcesManager.IsExistSleeveNormalMap(SleeveId))
			{
				value3 = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureNormalMap, isfetch: true)) as Texture;
				value2 = 40f;
			}
			else
			{
				value3 = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_tx_general_n", ResourcesManager.AssetLoadPathType.SleeveTextureBasePath, isfetch: true)) as Texture;
			}
			material.SetTexture("_AOREFSPEC", value);
			material.SetTexture("_BumpMap", value3);
			material.SetFloat("_SpecPow", value2);
			cp.SpecularMaterial = material;
		}
		if (loadKind != LOAD_KIND.SELECT_DATA)
		{
			cp.BaseTexBase = Toolbox.ResourcesManager.LoadObject<Material>(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial, isfetch: true));
			cp.BaseTexBase.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture, isfetch: true));
			if (Data.Master.SleeveMgr.Get(SleeveId).IsPremiumSleeve)
			{
				Texture value4 = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(SleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureMask, isfetch: true));
				cp.BaseTexBase.SetTexture("_MaskTex", value4);
			}
			cp.BaseTexBase.shader = Shader.Find(cp.BaseTexBase.shader.name);
			DeckBaseTexBase = cp.BaseTexBase;
		}
		else
		{
			cp.BaseTexBase = Toolbox.ResourcesManager.LoadObject<Material>(Toolbox.ResourcesManager.GetAssetTypePath(3000011.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial, isfetch: true));
			cp.BaseTexBase.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(3000011.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture, isfetch: true));
			cp.BaseTexBase.shader = Shader.Find(cp.BaseTexBase.shader.name);
		}
		cp.m_CardBase.layer = scene_layer;
		cp.m_CardBase.name = "CardBase";
		cp.UnitGameObj = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("Unit", ResourcesManager.AssetLoadPathType.HandCard, isfetch: true));
		cp.UnitSpecGameObj = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("SpecularUnit", ResourcesManager.AssetLoadPathType.HandCardSpecular, isfetch: true));
		cp.UnitSpecGameObj.GetComponent<MeshFilter>().sharedMesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_unit_specular", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		cp.UnitGameObj.layer = scene_layer;
		cp.SpellGameObj = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("Spell", ResourcesManager.AssetLoadPathType.HandCard, isfetch: true));
		cp.SpellSpecGameObj = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("SpecularSpell", ResourcesManager.AssetLoadPathType.HandCardSpecular, isfetch: true));
		cp.SpellSpecGameObj.GetComponent<MeshFilter>().sharedMesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell_specular", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		cp.SpellGameObj.layer = scene_layer;
		cp.FieldGameObj = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("Field", ResourcesManager.AssetLoadPathType.HandCard, isfetch: true));
		cp.FieldSpecGameObj = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("SpecularField", ResourcesManager.AssetLoadPathType.HandCardSpecular, isfetch: true));
		cp.FieldSpecGameObj.GetComponent<MeshFilter>().sharedMesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_field_specular", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
		cp.FieldGameObj.layer = scene_layer;
		SetCardPrefab(cp);
		isReadyTemplate = true;
	}

	private int ClearAndGetCount(CardBasePrm.ClanType clantype, bool own)
	{
		int result = 0;
		if (loadKind == LOAD_KIND.SELECT_DATA || loadKind == LOAD_KIND.SELECT_DATA_GACHA)
		{
			SelectCardListObjs = new List<CardObjData>();
			result = loadSelectIds.Count;
		}
		else if (loadKind == LOAD_KIND.MYPAGE_HOME_CUSTOM_DECK || loadKind == LOAD_KIND.MYPAGE_HOME_DEFAULT_DECK_DATA)
		{
			result = _myPageHomeDeck.GetCardIdList().Count;
		}
		return result;
	}

	private IEnumerator CreateDeckData(int scene_layer, bool is2D, CardMaster.CardMasterId cardMasterId, CardBasePrm.ClanType clantype = CardBasePrm.ClanType.NONE, bool own = false, Action onFinish = null)
	{
		CardPrefabs cp = null;
		if (!is2D)
		{
			yield return StartCoroutine(Load3D(scene_layer, delegate(CardPrefabs v)
			{
				cp = v;
			}));
		}
		else
		{
			if (CardList2DDict == null)
			{
				CardList2DDict = new Dictionary<int, int>();
			}
			else
			{
				CardList2DDict.Clear();
			}
			yield return StartCoroutine(Load2D(scene_layer, delegate(CardPrefabs v)
			{
				cp = v;
			}));
		}
		while (!isAssetAllReady || !isReadyTemplate)
		{
			yield return null;
		}
		CardListObjs = new List<CardObjData>();
		CardList2DObjs = new List<CardObjData>();
		int num = ClearAndGetCount(clantype, own);
		for (int num2 = 0; num2 < num; num2++)
		{
			AddCardResult addCardResult = createCard(num2, is2D, clantype, scene_layer, own, cp, cardMasterId);
			if (addCardResult != AddCardResult.NOT_ADDED && addCardResult == AddCardResult.END)
			{
				break;
			}
		}
		UIManager.GetInstance().LoadingViewManager.UpdateLoadingNum(100);
		CreateEndFlag = true;
		onFinish?.Invoke();
	}

	private bool getCardBaseStatus(int cardIndex, CardMaster.CardMasterId cardMasterId, ref CardParameter baseStatus)
	{
		Func<int, CardParameter> func = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId;
		if (loadKind == LOAD_KIND.SELECT_DATA || loadKind == LOAD_KIND.SELECT_DATA_GACHA)
		{
			baseStatus = func(loadSelectIds[cardIndex]);
		}
		else if (loadKind == LOAD_KIND.MYPAGE_HOME_CUSTOM_DECK || loadKind == LOAD_KIND.MYPAGE_HOME_DEFAULT_DECK_DATA)
		{
			int arg = _myPageHomeDeck.GetCardIdList()[cardIndex];
			baseStatus = func(arg);
		}
		return true;
	}

	private AddCardResult createCard(int cardIndex, bool is2D, CardBasePrm.ClanType clantype, int scene_layer, bool own, CardPrefabs cp, CardMaster.CardMasterId cardMasterId)
	{
		CardObjData cardObjData = new CardObjData();
		CardParameter baseStatus = null;
		if (!getCardBaseStatus(cardIndex, cardMasterId, ref baseStatus))
		{
			return AddCardResult.END;
		}
		CardBasePrm.CharaType charaType = (cardObjData.cardType = baseStatus.CharType);
		if (charaType == CardBasePrm.CharaType.CLASS)
		{
			return AddCardResult.ADDED;
		}
		if (DetailBasePrmList == null)
		{
			DetailBasePrmList = new Dictionary<int, CardParameter>();
		}
		if (!DetailBasePrmList.ContainsKey(baseStatus.ResourceCardId))
		{
			DetailBasePrmList.Add(baseStatus.ResourceCardId, baseStatus);
		}
		if (charaType != CardBasePrm.CharaType.SPELL && charaType != CardBasePrm.CharaType.FIELD && charaType != CardBasePrm.CharaType.CHANT_FIELD)
		{
			cardObjData.Evo_lifes = baseStatus.EvoLife.ToString();
			cardObjData.Evo_Atks = baseStatus.EvoAtk.ToString();
			cardObjData.Evo_Costs = baseStatus.Cost.ToString();
			cardObjData.Evo_Names = baseStatus.CardName;
			cardObjData.Evo_Skills = baseStatus.EvoSkillDescription;
			cardObjData.Skills = baseStatus.SkillDescription;
			cardObjData.EvolOk = true;
		}
		else
		{
			cardObjData.Skills = baseStatus.SkillDescription;
			cardObjData.EvolOk = false;
		}
		cardObjData.lifes = baseStatus.Life.ToString();
		cardObjData.LifesNum = baseStatus.Life;
		cardObjData.Atks = baseStatus.Atk.ToString();
		cardObjData.AtksNum = baseStatus.Atk;
		cardObjData.Names = baseStatus.CardName;
		cardObjData.Cost = baseStatus.Cost.ToString();
		cardObjData.CostNum = baseStatus.Cost;
		cardObjData.clan = baseStatus.Clan;
		cardObjData.tribe = baseStatus.Tribe;
		cardObjData.isPremiere = baseStatus.IsFoil;
		cardObjData.ids = baseStatus.CardId;
		string text = baseStatus.ResourceCardId.ToString();
		int cardId = (cardObjData.ids = baseStatus.CardId);
		cardObjData.mainCardNum = 1;
		GameObject gameObject = null;
		if (!(text == ""))
		{
			gameObject = ((!is2D) ? createNot2DCard(baseStatus, text, cp, scene_layer) : create2DCard(baseStatus, text, cp));
		}
		if (scene_layer != 0)
		{
			gameObject.layer = scene_layer;
		}
		CharIdx charIdx = gameObject.AddComponent<CharIdx>();
		charIdx.SetIdx(loadCnt);
		charIdx.SetCardId(cardId);
		if (is2D)
		{
			CardSetUp2D(gameObject, baseStatus, cardObjData, cardIndex);
		}
		else
		{
			CardSetUp3D(gameObject, baseStatus, scene_layer, cardIndex, cp, cardObjData);
		}
		loadCnt++;
		return AddCardResult.ADDED;
	}

	private void CardSetUp2D(GameObject GameObj, CardParameter cardParameter, CardObjData cardObjData, int cardIndex)
	{
		CardListTemplate component = GameObj.GetComponent<CardListTemplate>();
		CardBasePrm.CharaType charType = cardParameter.CharType;
		UILabel nameLabel = component._nameLabel;
		nameLabel.text = cardParameter.CardName;
		SetNameLabelStyle(nameLabel, cardParameter.IsFoil);
		Global.SetRepositionNameLabel(nameLabel, cardParameter.CardName, is2D: true);
		component.RotationOnlyIconVisible = cardParameter.IsResurgentCard;
		if (GameMgr.GetIns().GetDataMgr().IsNewCard(cardParameter.CardId))
		{
			component._newLabel.gameObject.SetActive(value: true);
		}
		else
		{
			component._newLabel.gameObject.SetActive(value: false);
		}
		if (charType == CardBasePrm.CharaType.NORMAL)
		{
			component._atkLabel.text = cardParameter.Atk.ToString();
			component._lifeLabel.text = cardParameter.Life.ToString();
			SetNumberLabelStyle(component._atkLabel, cardParameter.IsFoil);
			SetNumberLabelStyle(component._lifeLabel, cardParameter.IsFoil);
		}
		component._costLabel.text = cardParameter.Cost.ToString();
		SetNumberLabelStyle(component._costLabel, cardParameter.IsFoil);
		cardObjData.CardObj = GameObj;
		CardList2DObjs.Add(cardObjData);
		cardObjData.CardObj.name = loadKind.ToString() + " " + cardIndex;
	}

	private void CardSetUp3D(GameObject GameObj, CardParameter cardParameter, int scene_layer, int cardIndex, CardPrefabs cp, CardObjData cardObjData)
	{
		CardBasePrm.CharaType charType = cardParameter.CharType;
		GameObject obj = GameMgr.GetIns().GetGameObjMgr().AddUIManagerChildPrefab(cp.m_CostIcon);
		obj.transform.parent = GameObj.transform;
		int cost = cardParameter.Cost;
		UILabel component = obj.transform.Find("CostLabel").GetComponent<UILabel>();
		component.text = cost.ToString();
		obj.SetActive(value: true);
		obj.transform.localPosition = Global.POSITION_COST_ICON;
		obj.transform.localScale = Global.SCALE_CARD_ICON;
		if (cardParameter.IsResurgentCard)
		{
			GameObject obj2 = GameMgr.GetIns().GetGameObjMgr().AddUIManagerChildPrefab(cp.RotationOnlyIcon);
			obj2.transform.parent = GameObj.transform;
			obj2.transform.localPosition = Vector3.zero;
			obj2.transform.localScale = Vector3.one;
			obj2.name = "RotationOnlyIcon";
		}
		SetNumberLabelStyle(component, cardParameter.IsFoil);
		obj.gameObject.layer = scene_layer;
		m_DCardList.Add(GameObj);
		GameObj.gameObject.name = cardIndex.ToString();
		GameObj.layer = scene_layer;
		GameObject gameObject = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab(cp.m_CardBase);
		gameObject.name = "CardBase";
		gameObject.GetComponent<MeshFilter>().sharedMesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_md_Card", ResourcesManager.AssetLoadPathType.SleeveMesh, isfetch: true));
		MeshRenderer component2 = gameObject.GetComponent<MeshRenderer>();
		component2.sharedMaterial = cp.BaseTexBase;
		component2.sharedMaterial.SetFloat("_CullMode", 2f);
		component2.sharedMaterial.SetFloat("_ZWriteMode", 1f);
		gameObject.transform.parent = GameObj.transform;
		gameObject.transform.localPosition = new Vector3(Global.CARD_BASE_POS.x, Global.CARD_BASE_POS.y, Global.CARD_BASE_POS.z);
		gameObject.transform.localRotation = Quaternion.Euler(Global.CARD_BASE_ROT.x, Global.CARD_BASE_ROT.y, Global.CARD_BASE_ROT.z);
		gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
		Transform transform = gameObject.transform.Find("CardBase_Specular");
		transform.GetComponent<MeshFilter>().sharedMesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_md_Card", ResourcesManager.AssetLoadPathType.SleeveMesh, isfetch: true));
		if (cp.SpecularMaterial != null)
		{
			transform.GetComponent<MeshRenderer>().sharedMaterial = cp.SpecularMaterial;
		}
		GameObj.tag = "Card";
		GameObj.layer = scene_layer;
		GameObj.transform.localScale = DetailScale;
		GameObj.AddComponent<UIDragScrollView>();
		TweenScale tweenScale = GameObj.AddComponent<TweenScale>();
		m_CardList.Add(GameObj.GetComponent<TweenScale>());
		tweenScale.from = NormalScale;
		tweenScale.to = ZoomedScale;
		tweenScale.duration = 0.2f;
		tweenScale.enabled = false;
		GameObj.transform.parent = ScrollViewHorGrid;
		GameObj.gameObject.SetActive(value: false);
		if (charType != CardBasePrm.CharaType.SPELL && charType != CardBasePrm.CharaType.FIELD && charType != CardBasePrm.CharaType.CHANT_FIELD)
		{
			GameObject gameObject2 = GameMgr.GetIns().GetGameObjMgr().AddUIManagerChildPrefab(cp.m_LifeIcon);
			UILabel component3 = gameObject2.transform.Find("LifeLabel").GetComponent<UILabel>();
			gameObject2.transform.parent = GameObj.transform;
			component3.text = cardParameter.Life.ToString();
			gameObject2.transform.localPosition = Global.POSITION_LIFE_ICON;
			SetNumberLabelStyle(component3, cardParameter.IsFoil);
			GameObject gameObject3 = GameMgr.GetIns().GetGameObjMgr().AddUIManagerChildPrefab(cp.m_AtkIcon);
			UILabel component4 = gameObject3.transform.Find("AtkLabel").GetComponent<UILabel>();
			gameObject3.transform.parent = GameObj.transform;
			component4.text = cardParameter.Atk.ToString();
			gameObject3.transform.localPosition = Global.POSITION_ATK_ICON;
			SetNumberLabelStyle(component4, cardParameter.IsFoil);
			Transform obj3 = gameObject2.transform;
			Vector3 localScale = (gameObject3.transform.localScale = Global.SCALE_CARD_ICON);
			obj3.localScale = localScale;
			if (scene_layer != 0)
			{
				gameObject3.layer = scene_layer;
				gameObject2.layer = scene_layer;
			}
			gameObject3.SetActive(value: true);
			gameObject2.SetActive(value: true);
		}
		GameObject gameObject4 = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab(cp.m_NameIcon);
		gameObject4.transform.parent = GameObj.transform;
		UILabel component5 = gameObject4.transform.Find("NameLabel").GetComponent<UILabel>();
		component5.text = cardParameter.CardName;
		SetNameLabelStyle(component5, cardParameter.IsFoil);
		Global.SetRepositionNameLabel(component5, cardParameter.CardName, is2D: false);
		gameObject4.transform.localScale = Global.SCALE_NAME_TEXT;
		gameObject4.transform.localPosition = Global.POSITION_NAME_TEXT;
		if (scene_layer != 0)
		{
			gameObject4.layer = scene_layer;
			gameObject.layer = scene_layer;
		}
		cardObjData.CardObj = GameObj;
		if (loadKind == LOAD_KIND.SELECT_DATA || loadKind == LOAD_KIND.SELECT_DATA_GACHA)
		{
			SelectCardListObjs.Add(cardObjData);
		}
		else
		{
			CardListObjs.Add(cardObjData);
		}
	}

	private GameObject create2DCard(CardParameter prm, string PrefabPath, CardPrefabs cp)
	{
		GameObject gameObject = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab((prm.CharType == CardBasePrm.CharaType.NORMAL) ? cp.UnitGameObj : cp.SpellGameObj);
		Material material = Get2dCardMaterial(prm);
		if (material != null)
		{
			material.shader = Shader.Find(material.shader.name);
		}
		SetCardTexture(gameObject, material, prm);
		return gameObject;
	}

	public static Material Get2dCardMaterial(CardParameter param)
	{
		ResourcesManager.AssetLoadPathType type;
		switch (param.CharType)
		{
		case CardBasePrm.CharaType.NORMAL:
			type = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
			break;
		case CardBasePrm.CharaType.FIELD:
		case CardBasePrm.CharaType.CHANT_FIELD:
		case CardBasePrm.CharaType.SPELL:
			type = (CardMaster.IsMutationCardCheck(param.BaseCardId) ? ResourcesManager.AssetLoadPathType.UnitCardMaterial : ResourcesManager.AssetLoadPathType.SpellCardMaterial);
			break;
		default:
			type = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
			break;
		}
		return Toolbox.ResourcesManager.FindCardMaterial(param.ResourceCardId, type);
	}

	private void SetCardTexture(GameObject GameObj, Material material, CardParameter prm)
	{
		CardListTemplate component = GameObj.GetComponent<CardListTemplate>();
		component._cardTexture.material = material;
		component._cardTexture.uvRect = Global.CARD_2D_UV_RECT;
		component.SetFrame(prm);
		SetupClassIcon(component, prm);
	}

	private void SetupClassIcon(CardListTemplate obj, CardParameter prm)
	{
		obj._classIconTexture.mainTexture = ClassCharaPrm.GetClassIconTexture((int)prm.Clan);
	}

	private GameObject createNot2DCard(CardParameter prm, string PrefabPath, CardPrefabs cp, int scene_layer)
	{
		GameObject gameObject = null;
		ResourcesManager.AssetLoadPathType type = ResourcesManager.AssetLoadPathType.SpellCardMaterial;
		Mesh mesh = null;
		Mesh mesh2 = null;
		MeshFilter[] componentsInChildren;
		if (prm.CharType == CardBasePrm.CharaType.SPELL)
		{
			gameObject = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab(cp.SpellGameObj);
			gameObject.name = "Spell";
			NGUITools.AddChild(gameObject, cp.SpellSpecGameObj).name = "SpecularSpell";
			componentsInChildren = gameObject.GetComponentsInChildren<MeshFilter>();
			mesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
			mesh2 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_spell_low", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
			if (CardMaster.IsMutationCardCheck(prm.BaseCardId))
			{
				type = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
			}
		}
		else
		{
			if (prm.CharType != CardBasePrm.CharaType.FIELD && prm.CharType != CardBasePrm.CharaType.CHANT_FIELD)
			{
				return create3DFollowerCard(prm, cp, scene_layer);
			}
			gameObject = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab(cp.FieldGameObj);
			gameObject.name = "Field";
			NGUITools.AddChild(gameObject, cp.FieldSpecGameObj).name = "SpecularField";
			componentsInChildren = gameObject.GetComponentsInChildren<MeshFilter>();
			mesh = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_field", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
			mesh2 = Toolbox.ResourcesManager.LoadObject<Mesh>(Toolbox.ResourcesManager.GetAssetTypePath("md_card_field_low", ResourcesManager.AssetLoadPathType.CardFrameMesh, isfetch: true));
			if (CardMaster.IsMutationCardCheck(prm.BaseCardId))
			{
				type = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
			}
		}
		componentsInChildren[0].sharedMesh = mesh;
		componentsInChildren[1].sharedMesh = mesh2;
		Transform obj = componentsInChildren[0].transform;
		Quaternion rotation = (componentsInChildren[1].transform.rotation = Quaternion.Euler(componentsInChildren[0].transform.rotation.x, componentsInChildren[0].transform.rotation.y + 180f, componentsInChildren[0].transform.rotation.z));
		obj.rotation = rotation;
		gameObject.transform.localScale = new Vector3(gameObject.transform.localScale.x, gameObject.transform.localScale.y, 1f);
		Material material = Toolbox.ResourcesManager.FindCardMaterial(prm.ResourceCardId, type);
		if (material != null)
		{
			CardShaderDefine.ReplaceBaseShader(material, prm.IsFoil);
		}
		Material[] sharedMaterials = new Material[3]
		{
			_3dCardFrameManager.GetFrameMaterial(prm.IsPhantomCard, prm.CharType, prm.Rarity),
			material,
			CardCreatorBase.GetSharedClassIconMaterial(prm.Clan)
		};
		LOD[] lODs = gameObject.GetComponent<LODGroup>().GetLODs();
		for (int i = 0; i < lODs.Length; i++)
		{
			lODs[i].renderers[0].sharedMaterials = sharedMaterials;
		}
		UIManager.GetInstance().SetLayerRecursive(gameObject.transform, scene_layer);
		return gameObject;
	}

	private GameObject create3DFollowerCard(CardParameter prm, CardPrefabs cp, int scene_layer)
	{
		GameObject gameObject = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab(cp.UnitGameObj);
		gameObject.name = "Unit";
		NGUITools.AddChild(gameObject, cp.UnitSpecGameObj).name = "SpecularUnit";
		Material material = Toolbox.ResourcesManager.FindCardMaterial(prm.ResourceCardId, ResourcesManager.AssetLoadPathType.UnitCardMaterial);
		Material material2 = Toolbox.ResourcesManager.FindCardMaterial(prm.ResourceCardId, ResourcesManager.AssetLoadPathType.UnitCardMaterial, isEvol: true);
		if (material != null && material2 != null)
		{
			CardShaderDefine.ReplaceBaseShader(material, prm.IsFoil);
			CardShaderDefine.ReplaceBaseShader(material2, prm.IsFoil);
		}
		gameObject.transform.localScale = new Vector3(gameObject.transform.localScale.x, gameObject.transform.localScale.y, 1f);
		MeshFilter[] componentsInChildren = gameObject.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;
		Transform obj = componentsInChildren[0].transform;
		Quaternion rotation = (componentsInChildren[1].transform.rotation = Quaternion.Euler(componentsInChildren[0].transform.rotation.x, componentsInChildren[0].transform.rotation.y + 180f, componentsInChildren[0].transform.rotation.z));
		obj.rotation = rotation;
		Material[] sharedMaterials = new Material[3]
		{
			_3dCardFrameManager.GetFrameMaterial(prm.IsPhantomCard, prm.CharType, prm.Rarity),
			material,
			CardCreatorBase.GetSharedClassIconMaterial(prm.Clan)
		};
		LOD[] lODs = gameObject.GetComponent<LODGroup>().GetLODs();
		for (int i = 0; i < lODs.Length; i++)
		{
			lODs[i].renderers[0].sharedMaterials = sharedMaterials;
		}
		UIManager.GetInstance().SetLayerRecursive(gameObject.transform, scene_layer);
		return gameObject;
	}

	public List<CardObjData> getCardListObjs()
	{
		return CardListObjs;
	}

	public List<CardObjData> getCardList2DObjs()
	{
		return CardList2DObjs;
	}

	public List<CardObjData> getAllCardList2DObjs()
	{
		return AllCardList2DObjs;
	}

	public List<CardObjData> getSelectedCardList2DObjs()
	{
		return SelectedCardList2DObjs;
	}

	public IList<int> getSelectedCardIDList()
	{
		return SelectedCardIDList;
	}

	public List<CardObjData> getSelectCardListObjs()
	{
		return SelectCardListObjs;
	}

	public Material GetUIBaseSleeveTexture()
	{
		if (DeckBaseTexBase == null)
		{
			DeckBaseTexBase = Toolbox.ResourcesManager.LoadObject<Material>(Toolbox.ResourcesManager.GetAssetTypePath(3000011.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial, isfetch: true));
		}
		return DeckBaseTexBase;
	}

	public IEnumerator LoadResident()
	{
		_loadList.AddRange(_3dCardFrameManager.GetCommonLoadAssetList());
		_loadList.AddRange(_3dCardFrameManager.GetLoadAssetList(_3dCardFrameManager.eFrameKind.Normal));
		_loadList.AddRange(GetAddUnitPathList());
		_loadList.AddRange(GetAddSpellPathList());
		_loadList.AddRange(GetAddFieldPathList());
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath("CardFrameClassIcon", ResourcesManager.AssetLoadPathType.CardFrameMaterialPlus));
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_CardBase", ResourcesManager.AssetLoadPathType.CardDeco));
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_md_Card", ResourcesManager.AssetLoadPathType.SleeveMesh));
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath("sleeve_cardbase_d", ResourcesManager.AssetLoadPathType.SleeveSpecular));
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath("foiltextures", ResourcesManager.AssetLoadPathType.FoilTextures));
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath(3000011.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial));
		_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath(3000011.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture));
		for (int i = 0; i < 9; i++)
		{
			_loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath("class_card_" + i.ToString("00"), ResourcesManager.AssetLoadPathType.CardFrameClassIcon));
		}
		_loadList.Add(UIManager.GetInstance().GetSceneAssetPath(UIAtlasManager.AssetBundleNames.CardFrame));
		yield return StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupSync(_loadList, delegate
		{
			UIManager.GetInstance().AddResidentAtlas(UIAtlasManager.AssetBundleNames.CardFrame);
			_3dCardFrameManager.InitFrameMaterials(_3dCardFrameManager.eFrameKind.Normal);
		}));
	}

	public void SetNumberLabelStyle(UILabel inLabel, bool inIsPremiere)
	{
		UIFont bitmapFont;
		Material material;
		if (inIsPremiere)
		{
			bitmapFont = _PremiereCardFont;
			material = _PremiereCardFont.material;
		}
		else
		{
			bitmapFont = _NormalCardFont;
			material = _NormalCardFont.material;
		}
		inLabel.bitmapFont = bitmapFont;
		inLabel.applyGradient = false;
		if (inLabel.material.name != material.name)
		{
			inLabel.material = material;
		}
	}

	public void SetNameLabelStyle(UILabel inLabel, bool inIsPremiere)
	{
		if (inIsPremiere)
		{
			inLabel.applyGradient = true;
			inLabel.gradientTop = PREMIERE_GRADIENT_TOP_COLOR;
			inLabel.gradientBottom = PREMIERE_GRADIENT_BOTTOM_COLOR;
			inLabel.effectStyle = UILabel.Effect.Outline8;
			inLabel.effectDistance = new Vector2(2f, 2f);
			inLabel.effectColor = EFFECT_COLOR;
		}
		else
		{
			inLabel.applyGradient = false;
			inLabel.effectStyle = UILabel.Effect.None;
		}
	}

	public void SetSleeveTexture(UITexture inTargetTexture, long inSleeveId)
	{
		SetSleeveTextureSub(inTargetTexture, inSleeveId, enablePremiumSleeve: true);
	}

	public void SetSleeveTextureWithoutPremium(UITexture inTargetTexture, long inSleeveId)
	{
		SetSleeveTextureSub(inTargetTexture, inSleeveId, enablePremiumSleeve: false);
	}

	private void SetSleeveTextureSub(UITexture inTargetTexture, long inSleeveId, bool enablePremiumSleeve)
	{
		inSleeveId = Toolbox.ResourcesManager.GetExistingSleeveId(inSleeveId);
		Sleeve sleeve = Data.Master.SleeveMgr.Get(inSleeveId);
		Texture texture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(inSleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture, isfetch: true)) as Texture;
		if (sleeve.IsPremiumSleeve && enablePremiumSleeve)
		{
			inTargetTexture.mainTexture = null;
			inTargetTexture.material = Toolbox.ResourcesManager.LoadObject<Material>(Toolbox.ResourcesManager.GetAssetTypePath(inSleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial, isfetch: true));
			inTargetTexture.material.SetTexture("_MainTex", texture);
			Texture value = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(inSleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureMask, isfetch: true));
			inTargetTexture.material.SetTexture("_MaskTex", value);
		}
		else
		{
			inTargetTexture.mainTexture = texture;
			inTargetTexture.material = null;
		}
	}

	public void AddPremireSleevePath(ref List<string> loadPath, Sleeve sleeveData)
	{
		loadPath.Add(Toolbox.ResourcesManager.GetAssetTypePath(sleeveData.sleeve_id.ToString(), ResourcesManager.AssetLoadPathType.SleeveTextureMask));
		loadPath.Add(Toolbox.ResourcesManager.GetAssetTypePath(sleeveData.sleeve_id.ToString(), ResourcesManager.AssetLoadPathType.SleeveMaterial));
	}

	public void AddKeyWordCache(List<int> cardPool, CardMaster.CardMasterId cardMasterId)
	{
		if (_keyWordCache == null)
		{
			_keyWordCache = new CardKeyWordCache();
		}
		if (_cardNameKeyWordCache == null)
		{
			_cardNameKeyWordCache = new CardKeyWordCache(CardKeyWordCache.Option.OnlyCardNames);
		}
		if (_cardNameKeyWordHiraganaCache == null)
		{
			_cardNameKeyWordHiraganaCache = new CardKeyWordCache(CardKeyWordCache.Option.OnlyCardNamesHiranaga);
		}
		if (_keyWordCommonCache == null)
		{
			_keyWordCommonCache = new CardKeyWordCommonCache();
		}
		CardMaster instance = CardMaster.GetInstance(cardMasterId);
		foreach (int item in cardPool)
		{
			_keyWordCommonCache.CacheKeyWord(instance.GetCardParameterFromId(item));
		}
	}

	public void ClearKeyWordCache()
	{
		_keyWordCache = null;
		_cardNameKeyWordCache = null;
		_cardNameKeyWordHiraganaCache = null;
		_keyWordCommonCache = null;
	}

	public IList<string> GetKeyword(CardParameter param)
	{
		if (_keyWordCommonCache != null)
		{
			return _keyWordCommonCache.GetCloneList(param);
		}
		return BattleKeywordInfoListMgr.GetKeywords(param);
	}
}
