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

public class LaboratoryField : BackGroundBase
{
	public override int FieldId => 7;

	public LaboratoryField(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_labo_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles07").gameObject;
			_fieldObjDictionary.Add(_fieldParticles.name, _fieldParticles);
			_fieldObjDictionary.Add("golem", _fieldModel.transform.Find("md_bf_labo_01_golem").gameObject);
			_fieldObjDictionary.Add("bookfall_1", _fieldModel.transform.Find("md_bf_labo_01_bookfall_1").gameObject);
			_fieldObjDictionary.Add("bookfall_2", _fieldModel.transform.Find("md_bf_labo_01_bookfall_2").gameObject);
			m_FieldAnimatorDictionary.Add("golem", _fieldObjDictionary["golem"].GetComponent<Animator>());
			m_FieldAnimatorDictionary.Add("bookfall_1", _fieldObjDictionary["bookfall_1"].GetComponent<Animator>());
			m_FieldAnimatorDictionary.Add("bookfall_2", _fieldObjDictionary["bookfall_2"].GetComponent<Animator>());
			_fieldParticleSystemDictionary.Add("book_1", _fieldParticles.transform.Find("book_1").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("book_2", _fieldParticles.transform.Find("book_2").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_7, pos);
	}

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

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		m_FieldAnimatorDictionary["golem"].SetTrigger("Threat01");
		_battleCamera.Camera.transform.localPosition = new Vector3(-525f, 125f, -230f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-25f, -105f, 98f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(-240f, -60f, 20f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-30f, -105f, 98f), "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)
	{
		string tag = obj.tag;
		if (tag != null && tag == "FieldGimic1" && _gimicCntDictionary[obj.tag] == 0)
		{
			_gimicCntDictionary[obj.tag]++;
			int num = Random.Range(1, 3);
			GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_gim_{num}", "se_field_" + _str3DFieldNo, 0f, 0L);
			switch (num)
			{
			case 1:
				m_FieldAnimatorDictionary["golem"].SetTrigger("Threat01");
				yield return new WaitForSeconds(7.5f);
				break;
			case 2:
				m_FieldAnimatorDictionary["golem"].SetTrigger("Threat02");
				yield return new WaitForSeconds(2f);
				break;
			}
			_gimicCntDictionary[obj.tag] = 0;
		}
		yield return new WaitForSeconds(0f);
	}

	protected override IEnumerator RunFieldShake()
	{
		m_FieldAnimatorDictionary["golem"].SetTrigger("Shake");
		if (FieldId == 7)
		{
			m_FieldAnimatorDictionary["bookfall_1"].SetTrigger("Fall");
			m_FieldAnimatorDictionary["bookfall_2"].SetTrigger("Fall");
			yield return new WaitForSeconds(0.5f);
			_fieldParticleSystemDictionary["book_1"].Play();
			_fieldParticleSystemDictionary["book_2"].Play();
		}
		yield return new WaitForSeconds(0f);
	}
}
