94 lines
2.6 KiB
C#
94 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using Framework;
|
|
using Gameplay.Area;
|
|
using Gameplay.Character;
|
|
using Gameplay.Common;
|
|
using Gameplay.Unit;
|
|
using UnityEngine;
|
|
|
|
namespace Gameplay.Level
|
|
{
|
|
public partial class Level
|
|
{
|
|
public bool IsPreparingRegion(int cellIndex)
|
|
{
|
|
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;
|
|
}
|
|
|
|
return area.positions.Contains(cellIndex);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public void ShowUnitAroundRegion(GameUnit unit, bool isNeedShow)
|
|
{
|
|
var positions = AreaManager.instance.GetCellIndexsAround(unit.transData.cellIndex, 1);
|
|
|
|
_map.SetBlocksColor(positions, isNeedShow, MapUtils.GetRGBAColor("FF960072"));
|
|
}
|
|
}
|
|
|
|
}
|
|
|