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

public class TempleField : BackGroundBase
{
	public override int FieldId => 5;

	public TempleField(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_ctdl_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles05").gameObject;
			_fieldObjDictionary.Add(_fieldParticles.name, _fieldParticles);
			if (FieldId == 5)
			{
				_fieldParticleSystemDictionary.Add("monu", _fieldParticles.transform.Find("monu").GetComponent<ParticleSystem>());
				_fieldParticleSystemDictionary.Add("monu_2", _fieldParticles.transform.Find("monu_2").GetComponent<ParticleSystem>());
				_fieldParticleSystemDictionary.Add("monu_summon", _fieldParticles.transform.Find("monu_summon").GetComponent<ParticleSystem>());
				_fieldParticleSystemDictionary.Add("monu_gimic_1", _fieldParticles.transform.Find("monu_gimic_1").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_5, pos);
	}

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

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		_battleCamera.Camera.transform.localPosition = new Vector3(-750f, 250f, -220f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-20f, -90f, 90f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(-220f, -20f, -60f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-25f, -97f, 93f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		yield return new WaitForSeconds(2f);
		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(0f);
	}

	protected override IEnumerator RunFieldGimic(GameObject obj)
	{
		if (FieldId == 5)
		{
			string tag = obj.tag;
			if (tag != null && tag == "FieldGimic1")
			{
				switch (_gimicCntDictionary[obj.tag])
				{
				case 0:
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:
				case 8:
					_gimicCntDictionary[obj.tag]++;
					GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_1", "se_field_" + _str3DFieldNo, 0f, 0L);
					_fieldParticleSystemDictionary["monu"].transform.GetChild(_gimicCntDictionary[obj.tag] - 1).GetComponent<ParticleSystem>().Play();
					_fieldParticleSystemDictionary["monu_2"].transform.GetChild(_gimicCntDictionary[obj.tag] - 1).GetComponent<ParticleSystem>().Play();
					break;
				case 9:
				{
					_gimicCntDictionary[obj.tag]++;
					GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_1", "se_field_" + _str3DFieldNo, 0f, 0L);
					_fieldParticleSystemDictionary["monu"].transform.GetChild(_gimicCntDictionary[obj.tag] - 1).GetComponent<ParticleSystem>().Play();
					_fieldParticleSystemDictionary["monu_2"].transform.GetChild(_gimicCntDictionary[obj.tag] - 1).GetComponent<ParticleSystem>().Play();
					yield return new WaitForSeconds(1f);
					GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_2", "se_field_" + _str3DFieldNo, 0f, 0L);
					for (int i = 0; i < _fieldParticleSystemDictionary["monu"].transform.childCount; i++)
					{
						ParticleSystem.MainModule main = _fieldParticleSystemDictionary["monu"].transform.GetChild(i).GetComponent<ParticleSystem>().main;
						main.startColor = new Color(1f, 0.25f, 0.25f);
						_fieldParticleSystemDictionary["monu"].transform.GetChild(i).GetComponent<ParticleSystem>().Stop();
						_fieldParticleSystemDictionary["monu"].transform.GetChild(i).GetComponent<ParticleSystem>().Play();
					}
					_fieldParticleSystemDictionary["monu_summon"].Play();
					yield return new WaitForSeconds(1f);
					for (int j = 0; j < _fieldParticleSystemDictionary["monu"].transform.childCount; j++)
					{
						ParticleSystem.MainModule main2 = _fieldParticleSystemDictionary["monu"].transform.GetChild(j).GetComponent<ParticleSystem>().main;
						main2.startColor = new Color(0.25f, 0.5f, 1f);
						_fieldParticleSystemDictionary["monu"].transform.GetChild(j).GetComponent<ParticleSystem>().Stop();
					}
					yield return new WaitForSeconds(4f);
					_gimicCntDictionary[obj.tag] = 0;
					break;
				}
				}
			}
		}
		yield return new WaitForSeconds(0f);
	}

	protected override IEnumerator RunFieldShake()
	{
		yield return new WaitForSeconds(0f);
	}
}
