90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using Framework;
|
|
using Gameplay.Character;
|
|
using UnityEngine;
|
|
|
|
namespace Gameplay.Level
|
|
{
|
|
public partial class Level
|
|
{
|
|
public bool IsPreparingRegion(Vector2Int position)
|
|
{
|
|
if (_levelData == null)
|
|
{
|
|
DebugUtil.LogError("IsPreparingRegion failed, _levelData is null");
|
|
return true;
|
|
}
|
|
|
|
if (_map == null)
|
|
{
|
|
DebugUtil.LogError("IsPreparingRegion failed, _map is null");
|
|
return true;
|
|
}
|
|
|
|
|
|
var areaId = _levelData.preparingRegionId;
|
|
|
|
var area = _map.MapData.GetRegion(areaId);
|
|
|
|
if (area == null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
for (int i = 0; i < area.positions.Count; i++)
|
|
{
|
|
if (area.positions[i].Equals(position))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void ShowPreparingRegion(bool show)
|
|
{
|
|
if (_levelData == null)
|
|
{
|
|
DebugUtil.LogError("ShowPreparingRegion failed, _levelData is null");
|
|
return;
|
|
}
|
|
|
|
if (_map == null)
|
|
{
|
|
DebugUtil.LogError("ShowPreparingRegion failed, _map is null");
|
|
return;
|
|
}
|
|
|
|
|
|
var areaId = _levelData.preparingRegionId;
|
|
|
|
_map.SetRegionColor(areaId, show, "FF960072");
|
|
}
|
|
|
|
public MapData.Region GetFallbackRegion(int troopId)
|
|
{
|
|
var fallbackRegionId = Constants.INVALID_ID;
|
|
switch (troopId)
|
|
{
|
|
case ETroopsId.Self:
|
|
fallbackRegionId = _levelData.fallbackRegionId;
|
|
break;
|
|
case ETroopsId.Enemy1:
|
|
case ETroopsId.Enemy2:
|
|
fallbackRegionId = _levelData.enemyFallbackRegionId;
|
|
break;
|
|
default:
|
|
fallbackRegionId = _levelData.fallbackRegionId;
|
|
break;
|
|
}
|
|
|
|
if (ValueValidator.IsIdValid(fallbackRegionId))
|
|
{
|
|
return _map.MapData.GetRegion(fallbackRegionId);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|
|
|