public void UpdatePathFinding() { if (_pathFindingQueue.Count != 0) { sPathCommand command = PopCommand(); if (command.tileCell.Marked() == false) { command.tileCell.Mark(); if (command.tileCell.CanMove() == true) { command.tileCell.SetPathFindingTestMark(Color.blue); } else if (command.tileCell.CanMove() == false) { command.tileCell.SetPathFindingTestMark(Color.red); } if (command.tileCell.GetDistanceFromStart() > 5) { _reverseTileCell = command.tileCell; _updateState = eUpdateState.BUILD; return; } // 목표 도달? if (command.tileCell.GetTileX() == _targetTileCell.GetTileX() && command.tileCell.GetTileY() == _targetTileCell.GetTileY()) { _updateState = eUpdateState.BUILD; _reverseTileCell = _targetTileCell; return; } // 주변 타일 검사 for (int direction = (int)eMoveDirection.UP; direction < (int)eMoveDirection.NONE; direction++) { sPosition currentTilePosition; currentTilePosition.x = command.tileCell.GetTileX(); currentTilePosition.y = command.tileCell.GetTileY(); sPosition nextTilePos = GetPositionByDirection(currentTilePosition, (eMoveDirection)direction); TileCell nextTileCell = GameManager.Instance.GetMap().GetTileCell(nextTilePos.x, nextTilePos.y); //nextTileCell.SetPathFindingTestMark(Color.red); // 검사 한타일인지 && 이동 가능한 타일 인지 && 갈수 없는 노드의 타입이 혹시 몬스터? -> 리팩토링하고싶다ㅏㅏ if ((nextTileCell.IsPathFindable() == true && nextTileCell.Marked() == false)) { float distanceFromStart = command.tileCell.GetDistanceFromStart() + command.tileCell.GetDistanceWeight() + 1; //float heuristic = CalcAStarHeuristic(distanceFromStart, nextTileCell, _targetTileCell); float heuristic = 0; switch (_character.GetPathFindingType()) { case ePathFindingType.DISTANCE: heuristic = distanceFromStart; break; case ePathFindingType.SIMPLE: heuristic = CalcSimpleHeuristic(command.tileCell, nextTileCell, _targetTileCell); break; case ePathFindingType.COMPLEX: heuristic = CalcComplexHeuristic(nextTileCell, _targetTileCell); break; case ePathFindingType.ASTAR: heuristic = CalcAStarHeuristic(distanceFromStart, nextTileCell, _targetTileCell); break; } if (nextTileCell.GetPrevTileCell() == null) { nextTileCell.SetDistanceFromStart(distanceFromStart); nextTileCell.SetPrevTileCell(command.tileCell); sPathCommand newCommand; newCommand.heuristic = heuristic; newCommand.tileCell = nextTileCell; PushCommand(newCommand); } } } } } }