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

public class BattlePlayerVfxCreatorBase : IBattlePlayerVfxCreator
{
	private readonly IBattlePlayerView m_battleView;

	public BattlePlayerVfxCreatorBase(IBattlePlayerView battleView)
	{
		m_battleView = battleView;
	}

	public VfxBase CreateUsePp(int pp, int maxPp, Vector3 labelPosition, bool newReplayMoveTurn)
	{
		if (newReplayMoveTurn)
		{
			return ParallelVfxPlayer.Create(InstantVfx.Create(delegate
			{
				m_battleView.StatusParentPanel.GetComponent<IStatusPanelControl>().SetPp(pp, maxPp, newReplayMoveTurn);
			}));
		}
		return ParallelVfxPlayer.Create(new LoadAndPlayEffectVfx("cmn_ui_cost_1", null, labelPosition, 0f), InstantVfx.Create(delegate
		{
			m_battleView.StatusParentPanel.GetComponent<IStatusPanelControl>().SetPp(pp, maxPp, newReplayMoveTurn);
		}));
	}

	public VfxBase CreateUseBp(int bp, int deltaBp, Func<Vector3> getPosition, bool isVariableCost, bool isSelf)
	{
		if (BattleManagerBase.GetIns().IsRecovery || isVariableCost)
		{
			return ParallelVfxPlayer.Create(m_battleView.SetBp(bp));
		}
		string fileName = ((deltaBp < 0) ? "cmn_ui_hbp_2" : "cmn_ui_hbp_1");
		if (deltaBp < 0 && isSelf)
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_HBP_UP);
		}
		return ParallelVfxPlayer.Create(new LoadAndPlayEffectVfx(fileName, null, getPosition, 0f, BattleManagerBase.GetIns().Battle3DContainer.layer), m_battleView.SetBp(bp));
	}

	public VfxBase CreateUpdateEp(int evolCount, int evolveWaitTurnCount)
	{
		return new UpdateEpVfx(m_battleView, evolCount, evolveWaitTurnCount);
	}

	public VfxBase CreateCardDraw(IEnumerable<BattleCardBase> cards, bool isOpenDrawSkill)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		foreach (BattleCardBase card in cards)
		{
			if (card.BaseCost != card.Cost)
			{
				List<int> costList = card.BattleCardView.GetUseCostList(card.Cost);
				bool isInHand = card.IsInHand;
				sequentialVfxPlayer.Register(InstantVfx.Create(delegate
				{
					card.BattleCardView.UpdateCost(costList, isGenerateInHand: true, playEffect: true, isInHand);
				}));
			}
		}
		sequentialVfxPlayer.Register(new PlayerDrawCardVfx(cards, isOpenDrawSkill));
		sequentialVfxPlayer.Register(new PlayerEndDrawVfx(cards));
		return sequentialVfxPlayer;
	}
}
