2021-04-08 20:09:59 +08:00
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public static class MapHelper
|
|
|
|
|
{
|
|
|
|
|
public static MapScene GetMapByUnitScene(this Unit unit)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
|
|
|
int mapid = unitScene.MapId;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
MapScene map = MapSceneComponent.Instance.GetMap(mapid);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (map == null)
|
|
|
|
|
map=MapSceneComponent.Instance.GetMap(Sys_SceneId.Scene_MainCity * 100 + 1);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
return MapSceneComponent.Instance.GetMap(Sys_SceneId.Scene_MainCity * 100 + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static MapScene GetMap(this Unit unit)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return unit.GetParent<MapScene>();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
return MapSceneComponent.Instance.GetMap(Sys_SceneId.Scene_MainCity * 100 + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|