using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Wizard;

public class Field1012 : BackGroundBase
{
	public override int FieldId => 1012;

	public Field1012(string bgmId = "NONE")
		: base(bgmId)
	{
	}

	protected override void BattleFieldBuild()
	{
		BattleCoroutine.GetInstance().StartCoroutine(BackGroundBase.ObjectChecker(0.5f, _str3DFieldPath, delegate
		{
			base.Field = GameObject.Find(_str3DFieldPath);
			base.Field.transform.parent = GameMgr.GetIns().m_GameManagerObj.transform;
			GimicAudioList = base.Field.GetComponent<AudioList>().GimicAudioList;
			_fieldModel = base.Field.transform.Find("md_bf_1012_01_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles1012").gameObject;
			_fieldParticleSystemDictionary.Add("base", _fieldParticles.transform.Find("base").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("shake", _fieldParticles.transform.Find("shake").GetComponent<ParticleSystem>());
			List<string> list = new List<string>(_fieldObjDictionary.Keys);
			List<GameObject> list2 = new List<GameObject>();
			for (int i = 0; i < _fieldObjDictionary.Count; i++)
			{
				list2.Add(_fieldObjDictionary[list[i]]);
			}
			GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(list2, delegate
			{
				base.SetShaderGlobalColorBG = base.Field.transform.Find("SetMaterialColorBGManager").GetComponent<SetShaderGlobalColorBG>();
				base.IsLoadDone = true;
			}, isBattle: true, isField: true);
		}));
	}

	public override void StartFieldSetEffect(Vector3 pos)
	{
		GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_SET_1012, pos);
	}

	public override void StartFieldTapEffect(int areaId, Vector3 pos)
	{
		base.StartFieldTapEffect(areaId, pos);
		if (areaId == 1)
		{
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_TAP_1012_1, pos);
		}
	}

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		_fieldParticleSystemDictionary["base"].Play();
		_battleCamera.Camera.transform.localPosition = new Vector3(-678f, -2223f, -8.5f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-69.4f, 54.5f, -56.56f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(-380f, -1292f, -8.5f), "time", 1.5f, "islocal", true, "easetype", iTween.EaseType.easeInQuart));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-69.4f, 54.5f, -56.56f), "time", 1.5f, "islocal", true, "easetype", iTween.EaseType.easeInQuart));
		yield return new WaitForSeconds(1.5f);
		_battleCamera.Camera.transform.localPosition = new Vector3(-380f, -1292f, -8.5f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-69.4f, 54.5f, -56.56f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(-132.6f, -553.3f, -8.5f), "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-69.4f, 54.5f, -56.56f), "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutQuad));
		yield return new WaitForSeconds(0.5f);
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", _battleCamera.BattleCameraPos, "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutExpo));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", _battleCamera.BattleCameraRot, "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutExpo));
	}

	protected override IEnumerator RunFieldShake()
	{
		_fieldParticleSystemDictionary["shake"].Play();
		yield return new WaitForSeconds(0f);
	}
}
