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

public class ChateauField : BackGroundBase
{
	public override int FieldId => 6;

	public ChateauField(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_hous_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles06").gameObject;
			_fieldObjDictionary.Add(_fieldParticles.name, _fieldParticles);
			_fieldObjDictionary.Add("door", _fieldModel.transform.Find("md_bf_hous_01_door").gameObject);
			_fieldObjDictionary.Add("shelf_door", _fieldModel.transform.Find("md_bf_hous_01_shelf_door").gameObject);
			m_FieldAnimatorDictionary.Add("door", _fieldObjDictionary["door"].GetComponent<Animator>());
			m_FieldAnimatorDictionary.Add("shelf_door", _fieldObjDictionary["shelf_door"].GetComponent<Animator>());
			_fieldParticleSystemDictionary.Add("clock_gimic_1", _fieldParticles.transform.Find("clock_gimic_1").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("clock_gimic_2", _fieldParticles.transform.Find("clock_gimic_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_6, 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_6_1, pos);
			break;
		case 2:
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_TAP_6_2, pos);
			break;
		}
	}

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		m_FieldAnimatorDictionary["door"].SetTrigger("Open");
		_battleCamera.Camera.transform.localPosition = new Vector3(-870f, -690f, -40f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-37f, 90f, -90f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(10f, -10f, -100f), "time", 1.7f, "delay", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-35f, 105f, -100f), "time", 1.7f, "delay", 0.3f, "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", new Vector3(0f, -20f, -200f), "time", 1f, "islocal", true, "easetype", iTween.EaseType.easeInExpo));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-35f, 10f, -15f), "time", 1f, "islocal", true, "easetype", iTween.EaseType.easeInExpo));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", _battleCamera.BattleCameraPos, "time", 1f, "delay", 1f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", _battleCamera.BattleCameraRot, "time", 1f, "delay", 1f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		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:
				_fieldParticleSystemDictionary["clock_gimic_1"].Play();
				yield return new WaitForSeconds(5f);
				break;
			case 2:
				m_FieldAnimatorDictionary["shelf_door"].SetTrigger("Open");
				yield return new WaitForSeconds(0.5f);
				_fieldParticleSystemDictionary["clock_gimic_2"].Play();
				yield return new WaitForSeconds(5f);
				break;
			}
			_gimicCntDictionary[obj.tag] = 0;
		}
		yield return new WaitForSeconds(0f);
	}

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