using System.Collections.Generic;
using Wizard;
using Wizard.Battle;
using Wizard.Battle.UI;
using Wizard.Battle.View;
using Wizard.Battle.View.Vfx;

public class ReplayBattleEnemy : BattleEnemy
{
	private NewReplayBattleMgr _replayBattleMgr;

	public ReplayBattleEnemy(BattleManagerBase battleMgr, BattleCamera battleCamera, BackGroundBase backGround, IInnerOptionsBuilder innerOptionsBuilder)
		: base(battleMgr, battleCamera, backGround, innerOptionsBuilder)
	{
		_replayBattleMgr = battleMgr as NewReplayBattleMgr;
	}

	public override VfxBase StartTurnControl(string log = "")
	{
		Turn++;
		base.IsEpEvolveThisTurn = false;
		SequentialVfxPlayer sequentialVfxPlayer = TurnEvolveControl(BattleView.EpIcon);
		VfxBase vfx = TurnStart();
		sequentialVfxPlayer.Register(vfx);
		return sequentialVfxPlayer;
	}

	public override VfxBase TurnStart()
	{
		_opponentBattlePlayer.IsSelfTurn = false;
		_replayBattleMgr.TurnStart(this);
		base.IsAlreadyChoiceBraveInThisTurn = false;
		return NullVfx.GetInstance();
	}

	public VfxBase TurnStartFinish()
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		sequentialVfxPlayer.Register(InstantVfx.Create(SetActive));
		sequentialVfxPlayer.Register(CreateThinkingVfx(base.BattleMgr));
		return sequentialVfxPlayer;
	}

	public VfxBase AddPpTotal(BattleCardBase ownerCard, int addPpTotalCount, int pp)
	{
		return _replayBattleMgr.AddPpTotal(ownerCard, this, addPpTotalCount, pp);
	}

	public VfxBase AddPp(BattleCardBase ownerCard, int addPpCount)
	{
		return _replayBattleMgr.AddPp(ownerCard, this, addPpCount);
	}

	public VfxBase AddBp(BattleCardBase ownerCard, int addBpCount)
	{
		return _replayBattleMgr.AddBp(ownerCard, this, addBpCount, isSelf: false);
	}

	public VfxBase AddEp(BattleCardBase ownerCard, int addEpCount, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.EpModifier(ownerCard, this, addEpCount, isAdd: true, effectInfo);
	}

	public VfxBase SetEp(BattleCardBase ownerCard, int addEpCount, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.EpModifier(ownerCard, this, addEpCount, isAdd: false, effectInfo);
	}

	public VfxWithLoading DrawCard(List<BattleCardBase> drawList, List<NetworkBattleReceiver.CardInfo> cardInfoList, bool isSkipShuffle, bool isOpenDrawSkill)
	{
		VfxWithLoadingSequential vfxWithLoadingSequential = _replayBattleMgr.DrawCard(this, drawList, cardInfoList);
		vfxWithLoadingSequential.RegisterToMainVfx(CardDrawVfx(drawList, isSkipShuffle, isOpenDrawSkill));
		return vfxWithLoadingSequential;
	}

	public VfxWithLoading TokenDrawCard(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, List<BattleCardBase> targets, bool isOpen, bool isReserved, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.TokenDrawCard(this, ownerCard, cardInfoList, targets, isOpen, isReserved, effectInfo);
	}

	public VfxWithLoading CreateReservedCard(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList)
	{
		return _replayBattleMgr.CreateReservedCard(this, ownerCard, cardInfoList);
	}

	public VfxBase PlayCard(BattleCardBase playCard, int cost, int transformCardId, BattleCardBase.TransformType transformType, NetworkBattleReceiver.CardInfo cardInfo)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		playCard.BattleCardView.HideHandCardInfo();
		IBattleCardView battleCardView = playCard.BattleCardView;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.HandView.RemoveCardFromView(battleCardView, 0.3f);
		}));
		playCard.BattleCardView.UpdateParameterView(playCard.Atk, playCard.Life, cost, playCard.BaseParameter.CardName, playCard.IsInplay, isRecovery: false, useNormalCost: true);
		sequentialVfxPlayer.Register(BattleView.PlayQueueView.AddCardToViewVfx(playCard.BattleCardView, playCard.IsSpell, isSelectTarget: false, isChoice: false));
		if (transformCardId != -1)
		{
			BattleCardBase battleCardBase = playCard;
			SequentialVfxPlayer sequentialVfxPlayer2 = SequentialVfxPlayer.Create();
			bool flag = transformType == BattleCardBase.TransformType.Accelerate || transformType == BattleCardBase.TransformType.Crystallize;
			playCard = _replayBattleMgr.CreateTransformCard(this, playCard, transformCardId, sequentialVfxPlayer2, flag);
			if (transformType == BattleCardBase.TransformType.Choice)
			{
				CardParameter cardParameterFromId = CardMaster.GetInstanceForBattle().GetCardParameterFromId(cardInfo.Id);
				BattleCardBase card = _replayBattleMgr.CreateBattleCard(cardInfo.Id, IsPlayer, null, cardParameterFromId, this, cardInfo.Index);
				playCard.TransformInfo = new BattleCardBase.TransformInformation(transformType, card);
			}
			else
			{
				playCard.TransformInfo = new BattleCardBase.TransformInformation(transformType, battleCardBase);
			}
			if (flag)
			{
				sequentialVfxPlayer.Register(sequentialVfxPlayer2);
			}
			else
			{
				_replayBattleMgr.VfxMgr.RegisterImmediateVfx(sequentialVfxPlayer2);
			}
			base.HandCardList.Insert(base.HandCardList.IndexOf(battleCardBase), playCard);
			base.HandCardList.Remove(battleCardBase);
			sequentialVfxPlayer.Register(_replayBattleMgr.SetupTransformCard(playCard, battleCardBase, flag, isLoadResource: true));
		}
		VfxBase vfxBase = UsePp(cost);
		if (playCard is UnitBattleCard || playCard is FieldBattleCard)
		{
			_replayBattleMgr.HandCardToField(this, playCard);
		}
		if (playCard is UnitBattleCard)
		{
			playCard.BattleCardView.ResetTemplate();
		}
		BattleLogManager.GetInstance().AddLogDestFollower(BattleLogWindow.BattleLogType.PlayCardLog, playCard);
		VfxBase vfxBase2 = _replayBattleMgr.CreatePick(playCard, cardInfo);
		sequentialVfxPlayer.Register(ParallelVfxPlayer.Create(vfxBase, vfxBase2));
		sequentialVfxPlayer.Register(playCard.SetUpInplay());
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			MotionUtils.SetLayerAll(playCard.BattleCardView.CardTemplate.CardNormalTemp.gameObject, 10);
		}));
		if (playCard is SpellBattleCard)
		{
			_replayBattleMgr.HandCardToCemetery(this, playCard);
		}
		return sequentialVfxPlayer;
	}

	public VfxBase PlayChoiceBraveCard(int cost, int cardId, NetworkBattleReceiver.CardInfo cardInfo)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		BattleCardBase playCard = _replayBattleMgr.ReplaceChoiceBraveCard(base.Class, cardId, null);
		base.IsAlreadyChoiceBraveInThisTurn = true;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_CARD_SELECT_3, BattleManagerBase.GetIns().BattleUIContainer.EnemyChoiceBraveBtn.position);
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_CMN_CARD_SELECT_3);
			BattleView.UpdateChoiceBraveButtonPulsateEffectAndSprite();
		}));
		sequentialVfxPlayer.Register(BattleView.PlayQueueView.AddCardToViewVfx(playCard.BattleCardView, forceCardIntoPlayQueue: false, isSelectTarget: false, isChoice: true));
		sequentialVfxPlayer.Register(UseBp(cost, playCard.BaseParameter.IsVariableCost, isSelf: false));
		sequentialVfxPlayer.Register(_replayBattleMgr.CreatePick(playCard, cardInfo));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			MotionUtils.SetLayerAll(playCard.BattleCardView.CardTemplate.CardNormalTemp.gameObject, 10);
		}));
		base.ChoiceBraveCardList.Add(playCard);
		sequentialVfxPlayer.Register(UpdateHandCardsCost());
		return sequentialVfxPlayer;
	}

	public VfxWithLoading SummonToken(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, NetworkBattleReceiver.EffectInfo effectInfo, bool isOwnerEffect, bool isIgnoreVoice, bool isRandomVoice, bool isEvoVoice)
	{
		return _replayBattleMgr.SummonToken(this, ownerCard, cardInfoList, effectInfo, isOwnerEffect, isIgnoreVoice, isRandomVoice, isEvoVoice);
	}

	public VfxWithLoading SummonCard(BattleCardBase ownerCard, List<BattleCardBase> targets, bool isDeckSelf, bool isBurialRite, NetworkBattleReceiver.EffectInfo effectInfo, bool isIgnoreVoice, List<NetworkBattleReceiver.CardInfo> cardInfoList)
	{
		return _replayBattleMgr.SummonCard(this, ownerCard, targets, isDeckSelf, isBurialRite, effectInfo, isIgnoreVoice, cardInfoList);
	}

	public VfxBase AttackStart(BattleCardBase attackCard, BattleCardBase targetCard)
	{
		return _replayBattleMgr.AttackStart(this, attackCard, targetCard);
	}

	public VfxBase Attack(BattleCardBase attackCard, BattleCardBase targetCard, int dealDamage, int receiveDamage, List<BattleCardBase> destroyList, List<NetworkBattleReceiver.DestroyType> destroyTypeList, List<BattleCardBase> banishList, int drain, NetworkBattleReceiver.CardInfo attackCardInfo, List<NetworkBattleReceiver.SideLogSkillInfo> sideLogSkillInfoList, bool isAttackerDead, bool isTargetDead)
	{
		return _replayBattleMgr.Attack(this, attackCard, targetCard, dealDamage, receiveDamage, destroyList, destroyTypeList, banishList, drain, attackCardInfo, sideLogSkillInfoList, isAttackerDead, isTargetDead);
	}

	public VfxBase Evolve(BattleCardBase card, bool isConsumeEp, int choiceEvolutionId, NetworkBattleReceiver.CardInfo cardInfo)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		if (choiceEvolutionId / 1000000 == 910)
		{
			sequentialVfxPlayer.Register(_replayBattleMgr.ChoiceEvolve(card, choiceEvolutionId));
		}
		if (isConsumeEp)
		{
			GainCurrentEpCount();
		}
		base._cumulativeEvolutionCount++;
		sequentialVfxPlayer.Register(card.SkillApplyInformation.AllSkillEffectStop(isEvolve: true));
		(card as UnitBattleCard).Evolution();
		base.IsEpEvolveThisTurn = true;
		sequentialVfxPlayer.Register(new EvolveVfx(card, _replayBattleMgr.BattleResourceMgr, !isConsumeEp));
		sequentialVfxPlayer.Register(card.SkillApplyInformation.UpdateAllSkillEffectInReplay(cardInfo.InplaySkillEffectList, cardInfo.InductionNumber, isInitialize: true));
		sequentialVfxPlayer.Register(card.SkillApplyInformation.AllSkillEffectRestart());
		card.AttackableOnReplay = cardInfo.Attackable;
		card.IsCantAttackClassOnReplay = cardInfo.IsCantAttackClass;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			card.BattleCardView._inPlayFrameEffect.UpdateCanAttackEffect();
		}));
		return sequentialVfxPlayer;
	}

	public VfxBase CompleteFusion(BattleCardBase actCard, List<BattleCardBase> ingredientCards, NetworkBattleReceiver.CardInfo cardInfo, bool isFusionMetamorphose, int fusionMetamorphoseCardId, List<NetworkBattleReceiver.SideLogSkillInfo> sideLogSkillInfoList)
	{
		return _replayBattleMgr.Fusion(actCard, ingredientCards, this, cardInfo, isFusionMetamorphose, fusionMetamorphoseCardId, sideLogSkillInfoList);
	}

	public VfxBase UpdateDeck(BattleCardBase card, List<NetworkBattleReceiver.CardInfo> cardInfoList, bool isChange, bool isOpen, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.UpdateDeck(this, card, cardInfoList, isChange, isOpen, effectInfo);
	}

	public VfxBase Getoff(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.Getoff(this, ownerCard, cardInfoList, effectInfo);
	}

	public VfxBase Unite(BattleCardBase card, List<BattleCardBase> targetCards, int uniteCardId, int uniteCardIndex, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.Unite(this, card, targetCards, uniteCardId, uniteCardIndex, effectInfo);
	}

	public VfxBase OpenCard(BattleCardBase card, int cost, bool isLastDrawOpenCard)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		List<int> costList = card.BattleCardView.GetUseCostList(cost, useNomalCost: true);
		int atk = card.Atk;
		int life = card.Life;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			card.BattleCardView.UpdateCost(costList, isGenerateInHand: false, playEffect: false, isForceUpdate: true);
			card.BattleCardView.UpdateOffence(atk);
			card.BattleCardView.UpdateLife(life);
		}));
		sequentialVfxPlayer.Register(new OpenCardFromHandVfx(card.BattleCardView, card.IsLegend));
		sequentialVfxPlayer.Register(new PlayerEndDrawVfx(new List<BattleCardBase> { card }));
		if (isLastDrawOpenCard)
		{
			sequentialVfxPlayer.Register(BattleView.HandView.ShuffleHand());
		}
		return sequentialVfxPlayer;
	}

	public VfxBase PlayEmotion(ClassCharaPrm.EmotionType emotionType)
	{
		return Emotion.PlayEmotion(emotionType, 1.5f);
	}
}
