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

public class RivayleField : BackGroundBase
{
	public override int FieldId => 41;

	public RivayleField(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_0041_root").gameObject;
			_fieldParticles = _fieldModel.transform.Find("Particles41").gameObject;
			_fieldObjDictionary.Add("gate", _fieldModel.transform.Find("md_bf_0041_01_gate").gameObject);
			m_FieldAnimatorDictionary.Add("gate", _fieldObjDictionary["gate"].GetComponent<Animator>());
			_fieldObjDictionary.Add("tub", _fieldModel.transform.Find("md_bf_0041_01_tub").gameObject);
			m_FieldAnimatorDictionary.Add("tub", _fieldObjDictionary["tub"].GetComponent<Animator>());
			_fieldParticleSystemDictionary.Add("gimic_2", _fieldParticles.transform.Find("gimic_2").GetComponent<ParticleSystem>());
			_fieldParticleSystemDictionary.Add("shake", _fieldParticles.transform.Find("shake").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_41, pos);
	}

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

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		m_FieldAnimatorDictionary["gate"].SetTrigger("Open");
		_battleCamera.Camera.transform.localPosition = new Vector3(1742f, -485f, 51f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-12f, -90f, 90f));
		Vector3[] bezierQuad = MotionUtils.GetBezierQuad(new Vector3(1742f, -485f, 51f), new Vector3(900f, -285f, 18f), new Vector3(184f, 81f, -14f), 10);
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("path", bezierQuad, "movetopath", false, "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-8f, -97f, 90.5f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutSine));
		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" && _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["tub"].SetTrigger("tap");
				yield return new WaitForSeconds(3f);
				break;
			case 2:
				m_FieldAnimatorDictionary["tub"].SetTrigger("fall");
				_fieldParticleSystemDictionary["gimic_2"].Play();
				yield return new WaitForSeconds(6f);
				break;
			}
			_gimicCntDictionary[obj.tag] = 0;
		}
		yield return new WaitForSeconds(0f);
	}

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