private void FindPathToTargetPosition() { _nextResearchTimestamp = TimeHelper.GetCurrentTimestampScaled() + RESEARCH_INTERVAL_SEC * 1000; COORD ts = MapGrid.GetTileCoord(_owner.transform.position.x, _owner.transform.position.z); COORD te = MapGrid.GetTileCoord(_targetPosition.x, _targetPosition.z); MapAStar.PATH path = _game.mapAStar.Calc(ts.x, ts.z, te.x, te.z); _shortPath.SetPath(path); }
private const int SHOW_PATH_TICK_MAX = 100; // * 100; public void AddPath(MapAStar.PATH path) { if (!AppConfig.SHOW_PATH) { return; } foreach (MapAStar.NODE node in path.nodes) { int index = GetGridIndex(node.x, node.z); _gridsPathLeftTick[index] = Mathf.Max(_gridsPathLeftTick[index], SHOW_PATH_TICK_MAX); } }
public void SetPath(MapAStar.PATH path) { if (path != null && path.success && path.nodes.Count > 0) { _hasPath = true; this._path = path; _mapGrid.AddPath(path); List <COORD> coords = CalcTargetTileCenter(); SetPathLineTiles(coords); } else { _hasPath = false; this._path = null; SetPathLineTiles(null); } }