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

public class NateField : BackGroundBase
{
	public override int FieldId => 31;

	public NateField(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_nate_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles" + FieldId).gameObject;
			_fieldParticleSystemDictionary.Add("gimic_on1", _fieldParticles.transform.Find("gimic_on1").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("gimic_on2", _fieldParticles.transform.Find("gimic_on2").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("shake_1", _fieldParticles.transform.Find("shake_1").GetComponent<ParticleSystem>());
			_fieldObjDictionary.Add(_fieldParticles.name, _fieldParticles);
			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_31, 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_31_1, pos);
			break;
		case 2:
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_TAP_31_2, pos);
			break;
		}
	}

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		_battleCamera.Camera.transform.localPosition = new Vector3(1680f, -475f, -226f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-16f, -63f, 82f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(57f, -54f, 30f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-20f, -110f, 98f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		yield return new WaitForSeconds(2f);
		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)
	{
		string tag = obj.tag;
		if (tag != null && tag == "FieldGimic1")
		{
			switch (_gimicCntDictionary[obj.tag])
			{
			case 0:
			case 1:
			case 2:
				_gimicCntDictionary[obj.tag]++;
				_fieldParticleSystemDictionary["gimic_on1"].transform.GetChild(_gimicCntDictionary[obj.tag] - 1).GetComponent<ParticleSystem>().Play();
				_fieldParticleSystemDictionary["gimic_on2"].transform.GetChild(_gimicCntDictionary[obj.tag] - 1).GetComponent<ParticleSystem>().Play();
				GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_1", "se_field_" + _str3DFieldNo, 0f, 0L);
				break;
			case 3:
			{
				_gimicCntDictionary[obj.tag]++;
				for (int i = 0; i < _fieldParticleSystemDictionary["gimic_on1"].transform.childCount; i++)
				{
					_fieldParticleSystemDictionary["gimic_on1"].transform.GetChild(i).GetComponent<ParticleSystem>().Stop();
				}
				GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_2", "se_field_" + _str3DFieldNo, 0f, 0L);
				yield return new WaitForSeconds(2f);
				_gimicCntDictionary[obj.tag] = 0;
				break;
			}
			}
		}
		yield return new WaitForSeconds(0f);
	}

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