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

public class Nat4Field : NateField
{
	public override int FieldId => 34;

	public Nat4Field(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_nat4_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles34").gameObject;
			_fieldObjDictionary.Add("lid", _fieldModel.transform.Find("md_bf_nat4_01_pipemove_lid").gameObject);
			_fieldObjDictionary.Add("big", _fieldModel.transform.Find("md_bf_nat4_01_pipemove_big").gameObject);
			m_FieldAnimatorDictionary.Add("big", _fieldObjDictionary["big"].GetComponent<Animator>());
			m_FieldAnimatorDictionary.Add("lid", _fieldObjDictionary["lid"].GetComponent<Animator>());
			_fieldParticleSystemDictionary.Add("gimic_1", _fieldParticles.transform.Find("gimic_1").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("shake", _fieldParticles.transform.Find("shake").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_34, pos);
	}

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

	protected override IEnumerator RunFieldGimic(GameObject obj)
	{
		string tag = obj.tag;
		if (tag != null && tag == "FieldGimic1" && _gimicCntDictionary[obj.tag] == 0)
		{
			_gimicCntDictionary[obj.tag]++;
			if (Random.Range(0, 2) == 0)
			{
				GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_1", "se_field_" + _str3DFieldNo, 0f, 0L);
				m_FieldAnimatorDictionary["lid"].SetTrigger("Open");
				_fieldParticleSystemDictionary["gimic_1"].Play();
				yield return new WaitForSeconds(8f);
			}
			_gimicCntDictionary[obj.tag] = 0;
		}
		yield return new WaitForSeconds(0f);
	}

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