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

public class VolcanoField : BackGroundBase
{
	public override int FieldId => 3;

	public VolcanoField(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_vlca_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles03").gameObject;
			_fieldObjDictionary.Add(_fieldParticles.name, _fieldParticles);
			_fieldObjDictionary.Add("obj1", _fieldModel.transform.Find("md_bf_vlca_01_obj1").gameObject);
			_fieldParticleSystemDictionary.Add("pillar1", _fieldParticles.transform.Find("pillar1").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("pillar2", _fieldParticles.transform.Find("pillar2").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("pillar3", _fieldParticles.transform.Find("pillar3").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("obj1_fog", _fieldParticles.transform.Find("obj1_fog").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("obj1_stay", _fieldParticles.transform.Find("obj1_stay").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("obj1_shake", _fieldParticles.transform.Find("obj1_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_3, pos);
	}

	public override void StartFieldTapEffect(int areaId, Vector3 pos)
	{
		base.StartFieldTapEffect(areaId, pos);
		switch (areaId)
		{
		case 1:
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_TAP_3_1, pos);
			break;
		case 2:
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_TAP_3_2, pos);
			break;
		}
	}

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		_fieldObjDictionary["obj1"].transform.localPosition = new Vector3(1.308078f, 1.5f, -0.4518712f);
		_battleCamera.Camera.transform.localPosition = new Vector3(840f, -30f, -100f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-50f, -30f, 37f));
		Vector3[] bezierQuad = MotionUtils.GetBezierQuad(new Vector3(840f, -30f, -100f), new Vector3(720f, 450f, -100f), new Vector3(20f, 240f, -80f), 10);
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("path", bezierQuad, "movetopath", false, "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-20f, -75f, 85f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr(GimicAudioList[1], "se_field_" + _str3DFieldNo, 0f, 0L);
		_fieldParticleSystemDictionary["pillar2"].Play();
		yield return new WaitForSeconds(0.5f);
		_fieldParticleSystemDictionary["pillar3"].Play();
		yield return new WaitForSeconds(0.5f);
		_fieldParticleSystemDictionary["pillar1"].Play();
		yield return new WaitForSeconds(1f);
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_CAMERA_ZOOM_OUT);
		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));
		yield return new WaitForSeconds(4f);
		_fieldParticleSystemDictionary["obj1_stay"].Play();
		_fieldParticleSystemDictionary["obj1_fog"].Play();
		iTween.MoveTo(_fieldObjDictionary["obj1"], iTween.Hash("position", new Vector3(1.308078f, 0.5299267f, -0.4518712f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.linear));
		yield return new WaitForSeconds(0f);
	}

	protected override IEnumerator RunFieldGimic(GameObject obj)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		string tag = obj.tag;
		if (tag != null && tag == "FieldGimic1")
		{
			switch (_gimicCntDictionary[obj.tag])
			{
			case 0:
			case 1:
			case 2:
			case 3:
				_gimicCntDictionary[obj.tag]++;
				_fieldParticleSystemDictionary["obj1_shake"].Play();
				iTween.Stop(_fieldObjDictionary["obj1"]);
				iTween.ShakePosition(_fieldObjDictionary["obj1"], iTween.Hash("amount", new Vector3(0.005f, 0f, 0.005f) * _gimicCntDictionary[obj.tag], "time", 0.5f));
				iTween.MoveTo(_fieldObjDictionary["obj1"], iTween.Hash("position", new Vector3(1.308078f, 0.5299267f, -0.4518712f), "time", 0.1f, "delay", 0.5f, "islocal", true));
				GameMgr.GetIns().GetSoundMgr().PlaySeByStr(GimicAudioList[0], "se_field_" + _str3DFieldNo, 0f, 0L);
				break;
			case 4:
				_gimicCntDictionary[obj.tag]++;
				_fieldParticleSystemDictionary["obj1_shake"].Play();
				_fieldParticleSystemDictionary["obj1_stay"].Stop();
				iTween.ShakePosition(_fieldObjDictionary["obj1"], iTween.Hash("amount", new Vector3(0.005f, 0f, 0.005f) * _gimicCntDictionary[obj.tag], "time", 0.5f));
				iTween.MoveTo(_fieldObjDictionary["obj1"], iTween.Hash("position", new Vector3(1.308078f, -1f, -0.4518712f), "time", 0.5f, "delay", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeInExpo));
				GameMgr.GetIns().GetSoundMgr().PlaySeByStr(GimicAudioList[0], "se_field_" + _str3DFieldNo, 0f, 0L);
				yield return new WaitForSeconds(1f);
				_fieldParticleSystemDictionary["pillar1"].Play();
				m_BtlMgrIns.VfxMgr.RegisterImmediateVfx(_battleCamera.ShakeCamera(Vector3.one * 0.1f, 0.5f, 0f));
				m_BtlMgrIns.VfxMgr.RegisterImmediateVfx(SequentialVfxPlayer.Create(WaitVfx.Create(0.5f), _battleCamera.ShakeComplete()));
				yield return new WaitForSeconds(5f);
				_fieldParticleSystemDictionary["obj1_fog"].Play();
				_fieldObjDictionary["obj1"].transform.localPosition = new Vector3(1.308078f, 1.5f, -0.4518712f);
				iTween.MoveTo(_fieldObjDictionary["obj1"], iTween.Hash("position", new Vector3(1.308078f, 0.5299267f, -0.4518712f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.linear));
				yield return new WaitForSeconds(2f);
				_gimicCntDictionary[obj.tag] = 0;
				_fieldParticleSystemDictionary["obj1_stay"].Play();
				break;
			}
		}
		yield return new WaitForSeconds(0f);
	}

	protected override IEnumerator RunFieldShake()
	{
		if (_gimicCntDictionary["FieldGimic1"] < 4)
		{
			_fieldParticleSystemDictionary["obj1_shake"].Play();
			iTween.ShakePosition(_fieldObjDictionary["obj1"], iTween.Hash("amount", new Vector3(0.01f, 0f, 0.01f), "time", 0.8f));
			iTween.MoveTo(_fieldObjDictionary["obj1"], iTween.Hash("position", new Vector3(1.308078f, 0.5299267f, -0.4518712f), "time", 0.1f, "delay", 0.8f, "islocal", true));
		}
		yield return new WaitForSeconds(0f);
	}
}
