2024-12-15 01:39:39 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
|
|
public class LoadMapMgr : MonoBehaviourSingletonTemplate<LoadMapMgr>
|
|
|
|
|
{
|
|
|
|
|
public string LoadSceneName, LoadMapPrefab;
|
|
|
|
|
GameObject go_map;
|
|
|
|
|
Camera[] arr_viewCam;
|
|
|
|
|
MapData m_MapData;
|
|
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
base.Awake();
|
|
|
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>(LoadMapPrefab, handle =>
|
|
|
|
|
{
|
|
|
|
|
go_map = DSUtil.Get_Clone(handle.Result);
|
|
|
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(go_map);
|
|
|
|
|
SceneManager.MoveGameObjectToScene(go_map, SceneManager.GetSceneByName(LoadSceneName));
|
|
|
|
|
m_MapData = go_map.GetComponent<MapData>();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-09 23:46:04 +00:00
|
|
|
public MapZoneData Get_MapZoneData(ChoiceMapData data) { return m_MapData.Get_MapZoneData(data.n_PortalIndex); }
|
|
|
|
|
|
2024-12-15 01:39:39 +00:00
|
|
|
public void Get_PortalPos(ChoiceMapData data, Action<Vector3> action)
|
2025-01-25 21:04:01 +00:00
|
|
|
{ StartCoroutine(Co_Get_PortalPos(data, action)); }
|
2024-12-15 01:39:39 +00:00
|
|
|
IEnumerator Co_Get_PortalPos(ChoiceMapData data, Action<Vector3> action)
|
|
|
|
|
{
|
|
|
|
|
while (DSUtil.CheckNull(m_MapData)) yield return null;
|
2025-03-09 23:46:04 +00:00
|
|
|
action(Get_MapZoneData(data).go_portal.transform.position + Vector3.forward);
|
2024-12-15 01:39:39 +00:00
|
|
|
}
|
|
|
|
|
public Vector3 Get_ReincanationPos(ChoiceMapData data)
|
2025-03-09 23:46:04 +00:00
|
|
|
{ return Get_MapZoneData(data).go_reincarnation.transform.position + Vector3.forward; }
|
2024-12-15 01:39:39 +00:00
|
|
|
public void Get_tfFarmer(ChoiceMapData data, Action<Transform> action)
|
2025-01-25 21:04:01 +00:00
|
|
|
{ StartCoroutine(Co_Get_tfFarmer(data, action)); }
|
2024-12-15 01:39:39 +00:00
|
|
|
IEnumerator Co_Get_tfFarmer(ChoiceMapData data, Action<Transform> action)
|
|
|
|
|
{
|
|
|
|
|
while (DSUtil.CheckNull(m_MapData)) yield return null;
|
2025-03-09 23:46:04 +00:00
|
|
|
action(Get_MapZoneData(data).tf_Farmer);
|
2024-12-15 01:39:39 +00:00
|
|
|
}
|
|
|
|
|
public void Get_tfObj(ChoiceMapData data, int index, Action<Transform> action)
|
2025-01-25 21:04:01 +00:00
|
|
|
{ StartCoroutine(Co_Get_tfObj(data, index, action)); }
|
2024-12-15 01:39:39 +00:00
|
|
|
IEnumerator Co_Get_tfObj(ChoiceMapData data, int index, Action<Transform> action)
|
|
|
|
|
{
|
|
|
|
|
while (DSUtil.CheckNull(m_MapData)) yield return null;
|
2025-03-09 23:46:04 +00:00
|
|
|
action(Get_MapZoneData(data).tf_Obj[index]);
|
2024-12-15 01:39:39 +00:00
|
|
|
}
|
2025-03-09 23:46:04 +00:00
|
|
|
|
2025-01-25 21:04:01 +00:00
|
|
|
public void Set_MazeMap(int index) { StartCoroutine(Co_Set_MazeMap(index)); }
|
|
|
|
|
IEnumerator Co_Set_MazeMap(int index)
|
|
|
|
|
{
|
|
|
|
|
while (DSUtil.CheckNull(m_MapData)) yield return null;
|
|
|
|
|
m_MapData.Set_MazeMap(index);
|
|
|
|
|
}
|
|
|
|
|
public void Set_MazeNextPortal(int index, bool active) { StartCoroutine(Co_Set_MazeNextPortal(index, active)); }
|
|
|
|
|
IEnumerator Co_Set_MazeNextPortal(int index, bool active)
|
|
|
|
|
{
|
|
|
|
|
while (DSUtil.CheckNull(m_MapData)) yield return null;
|
|
|
|
|
m_MapData.Set_MazeNextPortal(index, active);
|
|
|
|
|
}
|
2024-12-15 01:39:39 +00:00
|
|
|
|
|
|
|
|
public void SetActive_Map(bool _active)
|
|
|
|
|
{
|
|
|
|
|
go_map.SetActive(_active);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Camera Get_ViewCamera(string _name)
|
|
|
|
|
{
|
|
|
|
|
if (arr_viewCam == null) arr_viewCam = go_map.GetComponentsInChildren<Camera>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < arr_viewCam.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (arr_viewCam[i].name.Equals(_name))
|
|
|
|
|
return arr_viewCam[i];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|