76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class SceneInfo : MonoBehaviour
|
|
{
|
|
BattleMapConfigTableData CurStageData;
|
|
|
|
public void Load_AddScene(BattleMapConfigTableData _stagedata, Action addloadend)
|
|
{
|
|
if (CurStageData == null)
|
|
{ // 최초 로드
|
|
CurStageData = _stagedata;
|
|
StartCoroutine(Co_Control_AddScene(_stagedata, true, addloadend));
|
|
}
|
|
else if (CurStageData.s_Scene.Equals(_stagedata.s_Scene))
|
|
{ // 같은 맵
|
|
PCInfo.Ins.Make_Actors(false, ServerInfo.Ins.m_ServerData);
|
|
}
|
|
else
|
|
{ // 다른 씬
|
|
StartCoroutine(Co_Control_AddScene(_stagedata, false, addloadend));
|
|
CurStageData = _stagedata;
|
|
StartCoroutine(Co_Control_AddScene(_stagedata, true, addloadend));
|
|
}
|
|
}
|
|
|
|
IEnumerator Co_Control_AddScene(BattleMapConfigTableData _stagedata, bool _add, Action addloadend)
|
|
{
|
|
ActorInfo.Ins.Destroy_All();
|
|
IndicatorInfo.Ins.All_Off_Imm();
|
|
if (_add)
|
|
{
|
|
DSUtil.StartStopWatch();
|
|
var asyncLoad = SceneManager.LoadSceneAsync(CurStageData.s_Scene, LoadSceneMode.Additive);
|
|
while (!asyncLoad.isDone)
|
|
{
|
|
LoadingUI.Ins.Set_LoadingSlider(asyncLoad.progress);
|
|
yield return null;
|
|
}
|
|
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
PCInfo.Ins.Make_Actors(false, sdata);
|
|
if (CurStageData.s_Scene.Equals("MyFarm"))
|
|
{
|
|
// TODO 정인호 : 팜 로드 시 심어져있는 것들
|
|
//for (int i = 0; i < MyValue.VegetableField; i++)
|
|
//{
|
|
// if (!sdata.CanSowPlant(eFarmType.Vegetable, i))
|
|
// { // 채소가 심어져있다.
|
|
// MyFarmInfo.Ins.Sow_Plant(i, table_farm.Ins.Get_Data(sdata.Get_PlantID(eFarmType.Vegetable, i)));
|
|
// }
|
|
//}
|
|
//for (int i = 0; i < MyValue.TreeCount; i++)
|
|
//{
|
|
// if (!sdata.CanSowPlant(eFarmType.Tree, i))
|
|
// { // 나무가 심어져있다.
|
|
// MyFarmInfo.Ins.Sow_Plant(i, table_farm.Ins.Get_Data(sdata.Get_PlantID(eFarmType.Tree, i)));
|
|
// }
|
|
//}
|
|
}
|
|
|
|
yield return new WaitForSeconds(1f);
|
|
|
|
//LoadingUI.Ins.End_Loading();
|
|
SoundInfo.Ins.Play_BGM(DSUtil.StringToEnum<eBGM>(CurStageData.s_BGM));
|
|
addloadend?.Invoke();
|
|
Debug.Log(DSUtil.StopStopWatch(false));
|
|
}
|
|
else
|
|
{
|
|
yield return SceneManager.UnloadSceneAsync(CurStageData.s_Scene);
|
|
}
|
|
}
|
|
} |