using System.Collections;
using System.Collections.Generic;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.Scripts.Network.Data.TableData.Arena.TwoPick;
using Wizard.Scripts.Network.Data.TaskData.Arena.TwoPick;

public abstract class TwoPickCardSelectBase : MonoBehaviour
{
	public enum MoveType
	{
		LEFT,
		RIGHT,
		UP,
		DOWN
	}

	public enum PICK_SIDE
	{
		LEFT,
		RIGHT
	}

	private class CardPosXInfo
	{
		public Transform Transform { get; private set; }

		public float PosX { get; private set; }

		public CardPosXInfo(Transform t, float posX)
		{
			Transform = t;
			PosX = posX;
		}
	}

	public const int PICK_SIDE_NUM = 2;

	public const int PICK_CARD_NUM = 2;

	protected TwoPickCardSelectView _viewData;

	private int scene_layer = 24;

	private const int maxDrawCard = 4;

	private const float CARD_IN_ANIMATION_TIME = 0.5f;

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

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

	private List<UIBase_CardManager.CardObjData> cardObjList = new List<UIBase_CardManager.CardObjData>();

	private List<UIBase_CardManager.CardObjData> cardObjListSpell = new List<UIBase_CardManager.CardObjData>();

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

	protected List<int> _selectedCardList = new List<int>();

	private bool _bOnDestory;

	private int _lastTimeCardNum;

	protected int _followerNum;

	protected int _amuletNum;

	protected int _spellNum;

	private List<GameObject> _tweenObjectList = new List<GameObject>();

	private List<CardPosXInfo> cardPosXInfoList = new List<CardPosXInfo>();

	private bool isCardSetFirst = true;

	private const int DECK_INFO_ICON = 0;

	private const int DECK_INFO_CLASS_NAME = 0;

	private const int DECK_INFO_CARD_NUM = 1;

	private const int DECK_INFO_CARD_MAX = 2;

	private const int DECK_INFO_FOLLOWER_NUM = 3;

	private const int DECK_INFO_SPELL_NUM = 4;

	private const int DECK_INFO_AMULET_NUM = 5;

	private const float DECK_INFO_TWEEN_Y = -151f;

	private readonly Color EFFECT_COLOR_BLUE = new Color(0.2509804f, 0.5019608f, 1f);

	private readonly Color EFFECT_COLOR_ORANGE = new Color(1f, 32f / 85f, 0f);

	private List<Effect> _effects = new List<Effect>();

	public UICardList UiCardList { get; set; }

	public CardDetailUI UiCardDetail { get; set; }

	public int SelectedClassId { get; set; }

	public bool IsButtonEnable { get; set; }

	public bool IsTitleEnable { get; set; }

	public bool IsFirstCardDisp { get; set; }

	protected virtual void Awake()
	{
		IsButtonEnable = true;
		IsTitleEnable = true;
		IsFirstCardDisp = false;
	}

	public void Init()
	{
		isCardSetFirst = true;
		_viewData = base.transform.GetComponent<TwoPickCardSelectView>();
		_viewData.TitlePanel.gameObject.SetActive(IsTitleEnable);
		_viewData.CostCurveClass.Initialize(FormatBehaviorManager.GetDefaultBehaviour(Format.Max).CardMasterId);
		_viewData.DeckBtnObj.labels[0].text = Data.SystemText.Get("Arena_0009");
		_viewData.SelectBtnObjs[0].labels[0].text = Data.SystemText.Get("Arena_0029");
		_viewData.SelectBtnObjs[1].labels[0].text = Data.SystemText.Get("Arena_0029");
		for (int i = 0; i < 2; i++)
		{
			_viewData.SelectBtnObjs[i].buttons[0].onClick.Clear();
			_viewData.SelectBtnObjs[i].buttons[0].onClick.Add(new EventDelegate(delegate
			{
				OnClickSelectBtn();
			}));
		}
		_viewData.DeckBtnObj.buttons[0].onClick.Clear();
		_viewData.DeckBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
		{
			DeckViewOpen();
		}));
		UiCardList.SetClan(GetSelectedClassId());
		CardBasePrm.ClanType selectedClassId = GetSelectedClassId();
		_viewData.DeckInfoObjs.sprites[0].spriteName = ClassCharaPrm.GetIconSpriteName(selectedClassId);
		_viewData.DeckInfoObjs.labels[0].text = ClassCharaPrm.GetNameText(selectedClassId);
		ClassCharaPrm.SetClassLabelSetting(_viewData.DeckInfoObjs.labels[0], selectedClassId);
		_viewData.DeckTypeNameLabel.gameObject.SetActive(value: false);
		if (GetDeckInfo().cardIds.Length == 0)
		{
			_viewData.DeckInfoObjs.labels[1].text = "0";
			_viewData.DeckInfoObjs.labels[2].text = "/" + 30;
			_viewData.DeckInfoObjs.labels[3].text = "0";
			_viewData.DeckInfoObjs.labels[4].text = "0";
			_viewData.DeckInfoObjs.labels[5].text = "0";
		}
		_viewData.TitlePanel.alpha = 0f;
		_viewData.DeckInfoObjs.GetComponent<UIPanel>().alpha = 0f;
		TweenAlpha.Begin(base.gameObject, 0f, 1f);
		LeftObjs = new List<GameObject>();
		RightObjs = new List<GameObject>();
		Deck deckInfo = GetDeckInfo();
		_selectedCardList = new List<int>();
		if (deckInfo.cardIds.Length != 0)
		{
			_selectedCardList.AddRange(deckInfo.cardIds);
		}
		for (int num = 0; num < _selectedCardList.Count; num++)
		{
			DeckInfoCardNumUpdate(_selectedCardList.Count, 30, _selectedCardList[num]);
		}
		if (_selectedCardList.Count == 0)
		{
			_viewData.DeckBtnObj.buttons[0].isEnabled = false;
			_viewData.DeckBtnObj.labels[0].color = LabelDefine.TEXT_COLOR_BUTTON_DISABLE;
		}
		else
		{
			_viewData.DeckBtnObj.buttons[0].isEnabled = true;
			_viewData.DeckBtnObj.labels[0].color = LabelDefine.TEXT_COLOR_BUTTON_ENABLE;
		}
		StartCoroutine(cardChoosePost_NonTask());
		_viewData.SelectBtnObjs[0].gameObject.SetActive(value: false);
		_viewData.SelectBtnObjs[1].gameObject.SetActive(value: false);
		_viewData.CardContainer[0].SetActive(value: false);
		_viewData.CardContainer[1].SetActive(value: false);
		TweenAlpha.Begin(_viewData.BaseObj, 0f, 0f);
		_loadAssetList.Add(Toolbox.ResourcesManager.GetAssetTypePath(GetSelectedSkinId().ToString("00"), ResourcesManager.AssetLoadPathType.ClassCharaBase));
		_viewData.ClassObj.textures[0].mainTexture = null;
		UIManager.GetInstance().createInSceneCenterLoading();
		UIManager.GetInstance().StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(_loadAssetList, delegate
		{
			UIManager.GetInstance().closeInSceneCenterLoading();
			if (!_bOnDestory)
			{
				Texture mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(GetSelectedSkinId().ToString("00"), ResourcesManager.AssetLoadPathType.ClassCharaBase, isfetch: true)) as Texture;
				UITexture obj = _viewData.ClassObj.textures[0];
				obj.mainTexture = mainTexture;
				obj.material = null;
				TweenAlpha.Begin(_viewData.BaseObj, 0f, 1f);
			}
		}));
		_viewData.TitlePanel.alpha = 0f;
		TweenAlpha.Begin(_viewData.TitlePanel.transform.parent.gameObject, 0.5f, 1f);
		StartCoroutine(ForceSetCardPosX());
	}

	public void SetDeckTypeName(string name)
	{
		_viewData.DeckTypeNameLabel.gameObject.SetActive(value: true);
		_viewData.DeckTypeNameLabel.text = name;
		ClassCharaPrm.SetClassLabelSetting(_viewData.DeckTypeNameLabel, GetSelectedClassId());
		_viewData.DeckInfoObjs.sprites[0].gameObject.SetActive(value: false);
		_viewData.DeckInfoObjs.labels[0].gameObject.SetActive(value: false);
	}

	public virtual void StartDestory()
	{
		Object.Destroy(base.gameObject);
	}

	protected virtual void OnDestroy()
	{
		GameMgr.GetIns().GetEffectMgr().Stop(EffectMgr.EffectType.CMN_ARENA_ARCANE_1);
		GameMgr.GetIns().GetEffectMgr().Stop(EffectMgr.EffectType.CMN_ARENA_ARCANE_2);
		foreach (Effect effect in _effects)
		{
			effect.Stop();
		}
		_effects.Clear();
		_bOnDestory = true;
		UIManager.GetInstance().closeInSceneCenterLoading();
	}

	public void RemoveData()
	{
		for (int i = 0; i < LeftObjs.Count; i++)
		{
			Object.Destroy(LeftObjs[i]);
		}
		LeftObjs.Clear();
		for (int j = 0; j < RightObjs.Count; j++)
		{
			Object.Destroy(RightObjs[j]);
		}
		RightObjs.Clear();
		cardObjList.Clear();
		cardObjListSpell.Clear();
		Toolbox.ResourcesManager.RemoveAssetGroup(_loadAssetList);
		_loadAssetList.Clear();
	}

	private IEnumerator cardChoosePost(int selectedId)
	{
		UIManager.GetInstance().createInSceneCenterLoading();
		yield return new WaitForSeconds(0.5f);
		ConnectTask(selectedId);
	}

	public void NextCardSelect(PICK_SIDE inPickSide)
	{
		_selectedCardList.Clear();
		_selectedCardList.AddRange(Data.RoomTwoPickInfo.deckData.cardIds);
		_followerNum = 0;
		_amuletNum = 0;
		_spellNum = 0;
		_viewData.CostCurveClass.Refresh();
		for (int i = 0; i < Data.RoomTwoPickInfo.deckData.cardIds.Length; i++)
		{
			DeckInfoCardNumUpdate(_selectedCardList.Count, 30, Data.RoomTwoPickInfo.deckData.cardIds[i]);
		}
		CardDecide(inPickSide, isCardListUpdate: false);
	}

	private IEnumerator cardChoosePost_NonTask()
	{
		yield return new WaitForSeconds(0.5f);
		returnPost();
	}

	private void returnPost()
	{
		UIManager.GetInstance().closeInSceneCenterLoading();
		StartCoroutine(CardSet());
	}

	private IEnumerator CardSet()
	{
		try
		{
			for (int i = 0; i < _tweenObjectList.Count; i++)
			{
				if (_tweenObjectList[i] != null)
				{
					iTween.Stop(_tweenObjectList[i]);
				}
			}
			_tweenObjectList.Clear();
		}
		catch
		{
		}
		if (_selectedCardList.Count >= 30)
		{
			StartCoroutine(RunSceneNext());
			yield break;
		}
		LeftObjs.Clear();
		RightObjs.Clear();
		_viewData.CardContainer[0].SetActive(value: true);
		_viewData.CardContainer[1].SetActive(value: true);
		if (isCardSetFirst)
		{
			isCardSetFirst = false;
			iTween.MoveTo(_viewData.DeckInfoObjs.gameObject, iTween.Hash("y", -151f, "time", 0.25f, "islocal", true, "easetype", iTween.EaseType.easeOutQuad));
			TweenAlpha.Begin(_viewData.DeckInfoObjs.gameObject, 0.25f, 1f);
			_tweenObjectList.Add(_viewData.DeckInfoObjs.gameObject);
		}
		for (int j = 0; j < cardObjList.Count; j++)
		{
			Object.Destroy(cardObjList[j].CardObj);
		}
		cardObjList.Clear();
		for (int k = 0; k < cardObjListSpell.Count; k++)
		{
			Object.Destroy(cardObjListSpell[k].CardObj);
		}
		cardObjListSpell.Clear();
		cardPosXInfoList.Clear();
		int[] downloadList = new int[4]
		{
			GetCardInfo().candidateCards[0].cardId1,
			GetCardInfo().candidateCards[0].cardId2,
			GetCardInfo().candidateCards[1].cardId1,
			GetCardInfo().candidateCards[1].cardId2
		};
		UIManager.GetInstance().CardLoadSelect(base.gameObject, downloadList, scene_layer, is2D: false);
		while (!UIManager.GetInstance().getUIBase_CardManager().getCreateEndFlag() || !UIManager.GetInstance().getUIBase_CardManager().isAssetAllReady)
		{
			yield return null;
		}
		cardObjList = UIManager.GetInstance().getSelectCardListObjs();
		_loadAssetList.AddRange(Toolbox.ResourcesManager.CardListAssetPathList);
		Toolbox.ResourcesManager.CardListAssetPathList.Clear();
		for (int l = 0; l < 4; l++)
		{
			GameObject cardObj = cardObjList[l].CardObj;
			cardObj.transform.parent = base.transform;
			cardObj.GetComponent<CharIdx>().SetCardId(downloadList[l]);
			switch (l)
			{
			case 0:
			case 1:
				cardObj.transform.parent = _viewData.CardContainer[0].transform;
				LeftObjs.Add(cardObj);
				break;
			case 2:
			case 3:
				cardObj.transform.parent = _viewData.CardContainer[1].transform;
				RightObjs.Add(cardObj);
				break;
			}
			cardObj.transform.localPosition = Vector3.up * 100f;
			cardObj.transform.localRotation = Quaternion.Euler(Vector3.up * 90f);
			cardObj.transform.localScale = new Vector3(50f, 50f, 50f);
			cardObj.transform.Find("CardBase").gameObject.AddComponent<UIButton>().onClick.Add(CreateCardDetailEvent(cardObj));
			cardObj.SetActive(value: false);
		}
		StartCoroutine(RunCardIn());
	}

	private EventDelegate CreateCardDetailEvent(GameObject cardObject)
	{
		return new EventDelegate(delegate
		{
			UiCardDetail.OnPushCardDetailOn(cardObject);
		});
	}

	private IEnumerator RunCardIn()
	{
		Vector3[] posList = new Vector3[4]
		{
			new Vector3(-100f, 200f, 0f),
			new Vector3(110f, 160f, 100f),
			new Vector3(110f, 200f, 0f),
			new Vector3(-100f, 160f, 100f)
		};
		Vector3[] rotList = new Vector3[4]
		{
			new Vector3(0f, 0f, 5f),
			new Vector3(0f, 0f, -5f),
			new Vector3(0f, 0f, -5f),
			new Vector3(0f, 0f, 5f)
		};
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_DL_CARD_APPEAR);
		GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_ARCANE_1, _viewData.CardContainer[0].transform.position);
		GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_ARCANE_2, _viewData.CardContainer[1].transform.position);
		int i = 0;
		while (i < 4 && LeftObjs.Count != 0 && RightObjs.Count != 0)
		{
			GameObject gameObject;
			Color color;
			if (i < 2)
			{
				gameObject = LeftObjs[i];
				color = EFFECT_COLOR_BLUE;
			}
			else
			{
				gameObject = RightObjs[i % 2];
				color = EFFECT_COLOR_ORANGE;
			}
			gameObject.SetActive(value: true);
			iTween.MoveTo(gameObject, iTween.Hash("position", posList[i], "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
			iTween.RotateTo(gameObject, iTween.Hash("rotation", rotList[i], "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo, "oncomplete", ""));
			iTween.MoveAdd(gameObject, iTween.Hash("y", Random.value * 0.03f + 0.03f, "time", Random.value * 2f + 2f, "looptype", iTween.LoopType.pingPong, "easetype", iTween.EaseType.easeInOutQuad));
			StartCoroutine(CardInAnimationEndAction(gameObject, posList[i], rotList[i]));
			Effect effect = ((cardObjList[i].cardType == CardBasePrm.CharaType.NORMAL) ? GameMgr.GetIns().GetEffectMgr().StartBuff(EffectMgr.EffectType.CMN_ARENA_FRAME_1, gameObject) : ((cardObjList[i].cardType != CardBasePrm.CharaType.SPELL) ? GameMgr.GetIns().GetEffectMgr().StartBuff(EffectMgr.EffectType.CMN_ARENA_FRAME_2, gameObject) : GameMgr.GetIns().GetEffectMgr().StartBuff(EffectMgr.EffectType.CMN_ARENA_FRAME_3, gameObject)));
			if (effect == null)
			{
				break;
			}
			effect.ChangeParticleColor(color);
			_effects.Add(effect);
			if (i % 2 == 0)
			{
				yield return new WaitForSeconds(0.1f);
			}
			int num = i + 1;
			i = num;
		}
		_viewData.SelectBtnObjs[0].gameObject.SetActive(IsButtonEnable);
		_viewData.SelectBtnObjs[1].gameObject.SetActive(IsButtonEnable);
		IsFirstCardDisp = true;
	}

	private IEnumerator CardInAnimationEndAction(GameObject cardObject, Vector3 position, Vector3 rotation)
	{
		yield return new WaitForSeconds(0.5f);
		if (cardObject != null)
		{
			cardObject.transform.localPosition = position;
			TweenRotation tweenRotation = cardObject.AddComponent<TweenRotation>();
			tweenRotation.from = rotation;
			float x = Random.value * 0.04f - 0.02f;
			float y = Random.value * 0.08f - 0.04f;
			float z = Random.value * 0.02f - 0.01f;
			tweenRotation.to = new Vector3(x, y, z);
			tweenRotation.style = UITweener.Style.PingPong;
			tweenRotation.method = UITweener.Method.EaseInOut;
			tweenRotation.duration = Random.value * 2f + 2f;
			_tweenObjectList.Add(cardObject);
			cardPosXInfoList.Add(new CardPosXInfo(cardObject.transform, position.x));
		}
	}

	private IEnumerator RunCardOut(bool isLeft)
	{
		if (LeftObjs.Count == 0 || RightObjs.Count == 0)
		{
			yield break;
		}
		GameMgr.GetIns().GetEffectMgr().Stop(EffectMgr.EffectType.CMN_ARENA_ARCANE_1);
		GameMgr.GetIns().GetEffectMgr().Stop(EffectMgr.EffectType.CMN_ARENA_ARCANE_2);
		foreach (Effect effect in _effects)
		{
			effect.Stop();
		}
		_effects.Clear();
		int i = 0;
		while (i < 2)
		{
			if (i != 0)
			{
				yield return new WaitForSeconds(0.1f);
			}
			if (LeftObjs.Count == 0 || RightObjs.Count == 0)
			{
				break;
			}
			if (isLeft)
			{
				_viewData.CardTweenTarget[i].transform.SetParent(LeftObjs[i].transform.parent);
				_viewData.CardTweenTarget[i].transform.localPosition = LeftObjs[i].transform.localPosition;
				_viewData.CardTweenTarget[i].transform.rotation = LeftObjs[i].transform.rotation;
				GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECIDE_1, _viewData.CardTweenTarget[i].transform.localPosition, _viewData.CardTweenTarget[i]);
				GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECIDE_3, LeftObjs[i].transform.position);
				GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECIDE_2, RightObjs[i].transform.position);
			}
			else
			{
				_viewData.CardTweenTarget[i].transform.SetParent(RightObjs[i].transform.parent);
				_viewData.CardTweenTarget[i].transform.localPosition = RightObjs[i].transform.localPosition;
				_viewData.CardTweenTarget[i].transform.rotation = RightObjs[i].transform.rotation;
				GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECIDE_2, LeftObjs[i].transform.position);
				GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECIDE_1, _viewData.CardTweenTarget[i].transform.localPosition, _viewData.CardTweenTarget[i]);
				GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECIDE_3, RightObjs[i].transform.position);
			}
			LeftObjs[i].SetActive(value: false);
			RightObjs[i].SetActive(value: false);
			int num = i + 1;
			i = num;
		}
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_2PICK_SELECT);
		try
		{
			for (int j = 0; j < _tweenObjectList.Count; j++)
			{
				if (_tweenObjectList[j] != null)
				{
					iTween.Stop(_tweenObjectList[j]);
				}
			}
			_tweenObjectList.Clear();
		}
		catch
		{
		}
		Vector3 vector = new Vector3(100f, 100f, 0f);
		Vector3 p = new Vector3(340f, 140f, 0f);
		if (!isLeft)
		{
			vector.x *= -1f;
			p.x *= -1f;
		}
		for (int k = 0; k < 2; k++)
		{
			Vector3[] bezierQuad = MotionUtils.GetBezierQuad(_viewData.CardTweenTarget[k].transform.localPosition, _viewData.CardTweenTarget[k].transform.localPosition + vector, p, 10);
			iTween.MoveTo(_viewData.CardTweenTarget[k], iTween.Hash("path", bezierQuad, "time", 0.25f, "islocal", true, "movetopath", false, "easetype", iTween.EaseType.linear));
			iTween.RotateTo(_viewData.CardTweenTarget[k], iTween.Hash("z", -180f, "time", 0.25f, "islocal", true, "easetype", iTween.EaseType.linear));
			_tweenObjectList.Add(_viewData.CardTweenTarget[k]);
		}
		GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_ARENA_DECK_1, _viewData.DeckInfoObjs.transform.position);
	}

	private IEnumerator RunSceneNext()
	{
		SetUiCardList();
		TweenAlpha.Begin(base.gameObject, 0.5f, 0f);
		yield return new WaitForSeconds(0.5f);
		base.gameObject.SetActive(value: false);
		CardSelectEndAction();
	}

	public void DeckInfoCardNumUpdate(int deckNow, int deckMax, int inCardId)
	{
		_viewData.DeckInfoObjs.labels[1].text = deckNow.ToString();
		_viewData.DeckInfoObjs.labels[2].text = "/" + deckMax;
		switch (CardMaster.GetInstance(CardMaster.CardMasterId.Default).GetCardParameterFromId(inCardId).CharType)
		{
		case CardBasePrm.CharaType.NORMAL:
			_followerNum++;
			break;
		case CardBasePrm.CharaType.FIELD:
		case CardBasePrm.CharaType.CHANT_FIELD:
			_amuletNum++;
			break;
		default:
			_spellNum++;
			break;
		}
		_viewData.DeckInfoObjs.labels[3].text = _followerNum.ToString();
		_viewData.DeckInfoObjs.labels[4].text = _spellNum.ToString();
		_viewData.DeckInfoObjs.labels[5].text = _amuletNum.ToString();
		_viewData.CostCurveClass.Add(inCardId, withAnim: false);
	}

	private void OnClickSelectBtn()
	{
		if (IsButtonEnable)
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			PICK_SIDE inPickSide = ((!(UIButton.current.name == "SelectBtn0")) ? PICK_SIDE.RIGHT : PICK_SIDE.LEFT);
			CardDecide(inPickSide, isCardListUpdate: true);
		}
	}

	protected void CardDecide(PICK_SIDE inPickSide, bool isCardListUpdate)
	{
		int num = 0;
		int num2 = 0;
		switch (inPickSide)
		{
		case PICK_SIDE.LEFT:
			num = GetCardInfo().candidateCards[0].cardId1;
			num2 = GetCardInfo().candidateCards[0].cardId2;
			StartCoroutine(RunCardOut(isLeft: true));
			StartCoroutine(cardChoosePost(GetCardInfo().candidateCards[0].id));
			break;
		case PICK_SIDE.RIGHT:
			num = GetCardInfo().candidateCards[1].cardId1;
			num2 = GetCardInfo().candidateCards[1].cardId2;
			StartCoroutine(RunCardOut(isLeft: false));
			StartCoroutine(cardChoosePost(GetCardInfo().candidateCards[1].id));
			break;
		}
		if (isCardListUpdate)
		{
			_selectedCardList.Add(num);
			_selectedCardList.Add(num2);
			DeckInfoCardNumUpdate(_selectedCardList.Count, 30, num);
			DeckInfoCardNumUpdate(_selectedCardList.Count, 30, num2);
		}
		_viewData.SelectBtnObjs[0].gameObject.SetActive(value: false);
		_viewData.SelectBtnObjs[1].gameObject.SetActive(value: false);
		_viewData.DeckBtnObj.buttons[0].isEnabled = true;
		_viewData.DeckBtnObj.labels[0].color = LabelDefine.TEXT_COLOR_BUTTON_ENABLE;
	}

	private IEnumerator ForceSetCardPosX()
	{
		while (true)
		{
			for (int i = 0; i < cardPosXInfoList.Count; i++)
			{
				CardPosXInfo cardPosXInfo = cardPosXInfoList[i];
				Transform transform = cardPosXInfo.Transform;
				if (!(transform == null))
				{
					Vector3 localPosition = transform.localPosition;
					localPosition.x = cardPosXInfo.PosX;
					transform.localPosition = localPosition;
				}
			}
			yield return null;
		}
	}

	protected abstract CardBasePrm.ClanType GetSelectedClassId();

	protected abstract int GetSelectedSkinId();

	protected void DeckViewOpen()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		UiCardList.SetActive(in_Active: true);
		SetUiCardList();
		UiCardList.ResetScroll();
	}

	protected void SetUiCardList()
	{
		if (_lastTimeCardNum != _selectedCardList.Count)
		{
			if (_selectedCardList.Count != 0)
			{
				UiCardList.RemoveData();
			}
			_selectedCardList = UIManager.GetInstance().getUIBase_CardManager().SortIDList(_selectedCardList, CardMaster.CardMasterId.Default);
			for (int i = 0; i < _selectedCardList.Count; i++)
			{
				UiCardList.addScrollItem(_selectedCardList[i]);
			}
			_lastTimeCardNum = _selectedCardList.Count;
		}
	}

	protected abstract Deck GetDeckInfo();

	protected abstract CandidateCardInfo GetCardInfo();

	protected abstract void CardSelectEndAction();

	protected abstract void ConnectTask(int selectedCardId);
}
