增加技能响应区域移动支持

main
刘涛 2023-10-31 14:16:34 +08:00
parent f9ae29f1ac
commit 2f8b6c1716
1 changed files with 33 additions and 3 deletions

View File

@ -25,6 +25,7 @@ namespace Gameplay.Area
public SkillHandle skillHandle;
private int _areaId;
private int _lastPlayerCellIndex;
private readonly RaycastHit[] _raycastHits;
@ -92,6 +93,7 @@ namespace Gameplay.Area
var map = LevelManager.Instance.CurrentLevel.Map;
var playerCellIndex = unit.transData.cellIndex;
_lastPlayerCellIndex = playerCellIndex;
var seletRange = inSkillHandle.runtimeData.configData.ReleaseArea;
_totalCellIndexList = map.TerrainGridSystem.CellGetNeighboursWithinRange(playerCellIndex, -1, seletRange, canCrossCheckType: TGS.CanCrossCheckType.IgnoreCanCrossCheckOnAllCells);
_totalCellIndexList.Add(playerCellIndex);
@ -117,7 +119,7 @@ namespace Gameplay.Area
_cacheObjBoarder = obj;
}
private void _HideAreaBoarder()
private void _HideAreaBoarderObj()
{
var map = LevelManager.Instance.CurrentLevel.Map;
var territoryIndex = map.TerrainGridSystem.TerritoryGetIndex(_cacheTerritory);
@ -137,7 +139,7 @@ namespace Gameplay.Area
DebugUtil.LogError("技能CD没好,强制取消释放");
realUse = false;
}
_HideAreaBoarder();
_HideAreaBoarderObj();
var map = LevelManager.Instance.CurrentLevel.Map;
if (_skillAreaEffect != null)
@ -169,13 +171,41 @@ namespace Gameplay.Area
{
return;
}
var mousePos = InputManager.Instance.GetTouchPosition();
var camera = Camera.main;
if (camera == null) return;
var map = LevelManager.Instance.CurrentLevel.Map;
var playerNowCellIndex = unit.transData.cellIndex;
if (playerNowCellIndex != _lastCenterCellIndex)
{
_lastPlayerCellIndex = playerNowCellIndex;
// 清除之前的
_HideAreaBoarderObj();
map.SetBlocksColor(_cacheCellIndexList, false, _bgAreaColor);
map.SetBlocksColor(_totalCellIndexList, false, _bgAreaColor);
_cacheCellIndexList.Clear();
// 更新技能影响区域
var seletRange = skillHandle.runtimeData.configData.ReleaseArea;
_totalCellIndexList = map.TerrainGridSystem.CellGetNeighboursWithinRange(playerNowCellIndex, -1, seletRange, canCrossCheckType: TGS.CanCrossCheckType.IgnoreCanCrossCheckOnAllCells);
_totalCellIndexList.Add(playerNowCellIndex);
_cacheTerritory = map.TerrainGridSystem.TerritoryCreate(_totalCellIndexList);
var obj = map.TerrainGridSystem.ForceDrawTerritoryDrawInteriorBorder(_cacheTerritory, 0, 1, _hintColor, _hintColor2);
var getMat = obj.transform.GetChild(0).GetComponent<MeshRenderer>().material;
getMat.SetColor(Color1, _hintColor);
getMat.SetColor(SecondColor, _hintColor2);
_cacheObjBoarder = obj;
_lastCenterCellIndex = -1;
}
var ray = camera.ScreenPointToRay(mousePos);
var layerMask = LayerMask.GetMask("Ground");
var raycast = Physics.RaycastNonAlloc(ray, _raycastHits, 1000, layerMask);
var map = LevelManager.Instance.CurrentLevel.Map;
if (raycast <= 0) return;
var firstHit = _raycastHits[0];
var hitPoint = firstHit.point;