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

namespace Wizard;

public class Field1009 : BackGroundBase
{
	private const string MONITOR_TEXTURE_NAME = "tx_bf_1009_01_monitor_d";

	private readonly string[] MONITOR_OBJECT_PATH_LIST = new string[6] { "md_bf_1009_01_main/monitor_set/monitor08", "md_bf_1009_01_main/monitor_set/monitor09", "md_bf_1009_01_main/monitor_set/monitor10", "md_bf_1009_01_main/monitor_set/monitor11", "md_bf_1009_01_main/monitor_set/monitor12", "md_bf_1009_01_main/monitor_set/monitor13" };

	public override int FieldId => 1009;

	public Field1009(string bgmId = "NONE")
		: base(bgmId)
	{
	}

	protected override List<string> CollectAdditionalAssets()
	{
		return new List<string> { Toolbox.ResourcesManager.GetAssetTypePath("tx_bf_1009_01_monitor_d", ResourcesManager.AssetLoadPathType.Uilang3DField) };
	}

	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_1009_root").gameObject;
			_fieldObjDictionary.Add("door", _fieldModel.transform.Find("md_bf_1009_01_door").gameObject);
			m_FieldAnimatorDictionary.Add("door", _fieldObjDictionary["door"].GetComponent<Animator>());
			string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("tx_bf_1009_01_monitor_d", ResourcesManager.AssetLoadPathType.Uilang3DField, isfetch: true);
			Texture texture = Toolbox.ResourcesManager.LoadObject(assetTypePath) as Texture;
			if (texture != null)
			{
				for (int i = 0; i < MONITOR_OBJECT_PATH_LIST.Length; i++)
				{
					MeshRenderer component = _fieldModel.transform.Find(MONITOR_OBJECT_PATH_LIST[i]).GetComponent<MeshRenderer>();
					if (component != null)
					{
						component.material.SetTexture("_MainTex", texture);
					}
				}
			}
			List<string> list = new List<string>(_fieldObjDictionary.Keys);
			List<GameObject> list2 = new List<GameObject>();
			for (int j = 0; j < _fieldObjDictionary.Count; j++)
			{
				list2.Add(_fieldObjDictionary[list[j]]);
			}
			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_1009, pos);
	}

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

	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(1885f, 0f, -150f);
		_battleCamera.Camera.transform.localRotation = Quaternion.Euler(new Vector3(0f, -85f, 90f));
		Vector3[] bezierQuad = MotionUtils.GetBezierQuad(new Vector3(1885f, 0f, -150f), new Vector3(300f, 0f, 100f), new Vector3(-596f, 0f, -170f), 10);
		iTween.MoveTo(_battleCamera.Camera.gameObject, iTween.Hash("path", bezierQuad, "movetopath", false, "time", 1.7f, "delay", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeInOutQuad));
		iTween.RotateTo(_battleCamera.Camera.gameObject, iTween.Hash("rotation", new Vector3(0f, -103f, 90f), "time", 1.7f, "delay", 0.3f, "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 RunFieldShake()
	{
		yield return null;
	}
}
