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

namespace Wizard;

public class Field1006 : BackGroundBase
{
	public override int FieldId => 1006;

	public Field1006(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_1006_root").gameObject;
			_fieldObjDictionary.Add("main", _fieldModel.transform.Find("md_bf_1006_01_monitor_main").gameObject);
			_fieldObjDictionary.Add("sub", _fieldModel.transform.Find("md_bf_1006_01_monitor_sub").gameObject);
			_fieldObjDictionary.Add("noise", _fieldModel.transform.Find("md_bf_1006_01_noise").gameObject);
			_fieldObjDictionary.Add("screen_01", _fieldModel.transform.Find("md_bf_1006_01_screen_01").gameObject);
			_fieldObjDictionary.Add("screen_02", _fieldModel.transform.Find("md_bf_1006_01_screen_02").gameObject);
			_fieldObjDictionary.Add("screen_03", _fieldModel.transform.Find("md_bf_1006_01_screen_03").gameObject);
			_fieldObjDictionary.Add("screen_04", _fieldModel.transform.Find("md_bf_1006_01_screen_04").gameObject);
			m_FieldAnimatorDictionary.Add("main", _fieldObjDictionary["main"].GetComponent<Animator>());
			m_FieldAnimatorDictionary.Add("sub", _fieldObjDictionary["sub"].GetComponent<Animator>());
			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);
			_fieldObjDictionary["screen_01"].gameObject.SetActive(value: true);
			_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
			_fieldObjDictionary["screen_02"].gameObject.SetActive(value: false);
			_fieldObjDictionary["screen_03"].gameObject.SetActive(value: false);
			_fieldObjDictionary["screen_04"].gameObject.SetActive(value: false);
		}));
	}

	public override void StartFieldSetEffect(Vector3 pos)
	{
		GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_FIELD_SET_1006, pos);
	}

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

	protected override IEnumerator RunFieldOpening()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr($"se_field_{_str3DFieldNo}_appear_1", "se_field_" + _str3DFieldNo, 0f, 0L);
		m_FieldAnimatorDictionary["main"].SetTrigger("opening");
		m_FieldAnimatorDictionary["sub"].SetTrigger("opening");
		_fieldObjDictionary["screen_01"].gameObject.SetActive(value: true);
		_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
		_fieldObjDictionary["screen_02"].gameObject.SetActive(value: false);
		_fieldObjDictionary["screen_03"].gameObject.SetActive(value: false);
		_fieldObjDictionary["screen_04"].gameObject.SetActive(value: false);
		_battleCamera.Camera.transform.localPosition = new Vector3(7f, -650f, -699f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(-74.1f, -179.8f, 179.8f));
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("position", new Vector3(-871f, -736f, -139f), "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(-36f, 109f, -107f), "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" && _gimicCntDictionary[obj.tag] == 0)
		{
			_gimicCntDictionary[obj.tag]++;
			int num = Random.Range(0, 3);
			GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_field_1006_gim_1", "se_field_" + _str3DFieldNo, 0f, 0L);
			switch (num)
			{
			case 0:
				m_FieldAnimatorDictionary["sub"].SetTrigger("tap");
				_fieldObjDictionary["screen_01"].gameObject.SetActive(value: false);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(0.3f);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
				_fieldObjDictionary["screen_02"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(2f);
				_fieldObjDictionary["screen_02"].gameObject.SetActive(value: false);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(0.3f);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
				_fieldObjDictionary["screen_01"].gameObject.SetActive(value: true);
				_gimicCntDictionary[obj.tag]--;
				break;
			case 1:
				m_FieldAnimatorDictionary["sub"].SetTrigger("tap");
				_fieldObjDictionary["screen_01"].gameObject.SetActive(value: false);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(0.3f);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
				_fieldObjDictionary["screen_03"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(2f);
				_fieldObjDictionary["screen_03"].gameObject.SetActive(value: false);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(0.3f);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
				_fieldObjDictionary["screen_01"].gameObject.SetActive(value: true);
				_gimicCntDictionary[obj.tag]--;
				break;
			case 2:
				m_FieldAnimatorDictionary["sub"].SetTrigger("tap");
				_fieldObjDictionary["screen_01"].gameObject.SetActive(value: false);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(0.3f);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
				_fieldObjDictionary["screen_04"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(2f);
				_fieldObjDictionary["screen_04"].gameObject.SetActive(value: false);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: true);
				yield return new WaitForSeconds(0.3f);
				_fieldObjDictionary["noise"].gameObject.SetActive(value: false);
				_fieldObjDictionary["screen_01"].gameObject.SetActive(value: true);
				_gimicCntDictionary[obj.tag]--;
				break;
			}
			_gimicCntDictionary[obj.tag] = 0;
		}
		yield return null;
	}
}
