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

namespace Wizard.Battle.Player.ClassCharacter;

public abstract class ClassCharacterBase : IClassCharacter
{
	protected const float ENEMY_ORTHO_SCALE_X = 0.934f;

	protected Vector3 _initPosition;

	private LeaderSoundManager _leaderSoundManager;

	protected bool _isAnimation;

	protected GameObject _emotionLabel;

	protected GameObject _enviromentLabel;

	protected abstract Vector3 MessagePosition { get; }

	public GameObject GameObject { get; protected set; }

	public bool IsWaiting { get; private set; }

	public bool IsRecovery { get; private set; }

	protected ClassCharacterBase()
	{
		_leaderSoundManager = new LeaderSoundManager();
	}

	public abstract VfxBase CreateLoadResouceVfx();

	public abstract void ClearResourceObject();

	public abstract void PlayMotion(ClassCharaPrm.MotionType motionType);

	public abstract void ResetMotion();

	public abstract void SetTrigger(string str);

	public abstract IEnumerator WaitMotionEnd();

	public abstract void ChangeFace(ClassCharaPrm.FaceType faceType);

	public abstract IEnumerator WaitChangeFace(ClassCharaPrm.FaceType faceType);

	public abstract void SetAnimationEnable(bool enable);

	public abstract bool IsAnimationEnable();

	public VfxBase CreateLoadVoiceResource(string voiceId)
	{
		OpeningVfx.OpenningLogStep = "CreateLoadVoiceResource " + voiceId;
		return _leaderSoundManager.CreateLoadResouceVfx(voiceId);
	}

	public VfxBase PlayVoice(string voiceId, bool forcePlay = false)
	{
		OpeningVfx.OpenningLogStep = "PlayVoice " + voiceId;
		return _leaderSoundManager.CreatePlayVfx(voiceId, forcePlay);
	}

	public VfxBase PlaySkinEvolveSe(string skinId, string suffix)
	{
		OpeningVfx.OpenningLogStep = "PlaySe " + skinId + suffix;
		return _leaderSoundManager.CreateLoadAndPlayEvolveSeVfx(skinId, suffix);
	}

	public VfxBase ShowVoiceMessage(string text)
	{
		return InstantVfx.Create(delegate
		{
			if (GameMgr.GetIns().IsWatchBattle)
			{
				if (GameMgr.GetIns().GetDataMgr().Is3DSkin(isPlayer: true))
				{
					_emotionLabel.layer = 24;
				}
				else
				{
					_emotionLabel.SetLayer(24, isSetChildren: true);
				}
			}
			else
			{
				_emotionLabel.layer = 24;
			}
			_emotionLabel.SetActive(value: true);
			_emotionLabel.transform.Find("Scale/MessageLabel").GetComponent<UILabel>().text = text;
			_emotionLabel.transform.position = MessagePosition;
		});
	}

	public VfxBase HideVoiceMessage()
	{
		return InstantVfx.Create(delegate
		{
			_emotionLabel.SetActive(value: false);
		});
	}

	public VfxBase SetWaiting(bool flag)
	{
		IsWaiting = flag;
		return UpdateEnviromentMessage();
	}

	public VfxBase SetRecovery(bool flag)
	{
		IsRecovery = flag;
		return UpdateEnviromentMessage();
	}

	public VfxBase ResetStatusInfo()
	{
		IsRecovery = false;
		IsWaiting = false;
		return UpdateEnviromentMessage();
	}

	public VfxBase UpdateEnviromentMessage()
	{
		return InstantVfx.Create(delegate
		{
			if (_enviromentLabel != null)
			{
				_enviromentLabel.layer = LayerMask.NameToLayer("FrontUI");
				string text = string.Empty;
				if (IsRecovery)
				{
					text = Data.SystemText.Get("Battle_0473");
				}
				else if (IsWaiting)
				{
					text = Data.SystemText.Get("Battle_0445");
				}
				_enviromentLabel.SetActive(text != string.Empty);
				_enviromentLabel.transform.Find("Scale/MessageLabel").GetComponent<UILabel>().text = text;
				_enviromentLabel.transform.position = MessagePosition;
			}
		});
	}

	public abstract void OutFrame();

	public void IntoFrame()
	{
		BattleCoroutine.GetInstance().StartCoroutine(WaitReturnFrame());
	}

	protected abstract IEnumerator WaitReturnFrame();

	public abstract float GetCurrentClipTime();

	public abstract bool GetCurrentClipIsName(ClassCharaPrm.MotionType motionType);

	protected abstract string GetTagName();

	protected abstract Quaternion ConvertBackPanelRotation(Quaternion originalRotation);

	protected abstract Vector3 GetPosition();

	protected abstract void SetUpAnchor(GameObject o);

	protected abstract void AttachOtherUI(GameObject o);

	public abstract Vector3 GetSpinePosition();

	public abstract Vector3 GetMaskImagePosition();

	protected abstract Vector3 GetShieldPosition();

	protected abstract Vector3 GetLifeIconPosition();

	protected abstract string GetTextureName();

	public abstract Quaternion GetMaskImageRotation();

	public abstract Vector3 ConvertSpineScale(Vector3 originalScale);

	public abstract int GetSpineSortingOrder(bool isBack = false);

	public abstract int GetMaskSortingOrder(bool isBack = false);

	protected abstract int GetEmoteLabelDepth();

	protected abstract int GetCharaId();

	public abstract int GetSkinId();

	public abstract int GetStencil();

	public abstract ClassCharaPrm.MotionType GetMotion();

	public abstract bool IsNoEvolveShift();

	public abstract bool IsOpponentReverse();
}
