Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public GridObject LowestCostObject()
- {
- int index = 0;
- int max = 99999;
- for (int i = 0; i < _spawner.spawnedObjects.Count; i++)
- {
- GridObject gridObject = _spawner.spawnedObjects[i];
- int distanceCost = _pathfinding.TileDistanceCost(gridObject.currentTile, snake.currentTile);
- int totalCost = distanceCost + gridObject.GetWeight();
- if (totalCost < max)
- {
- max = totalCost;
- index = i;
- }
- }
- return _spawner.spawnedObjects[index];
- }
Add Comment
Please, Sign In to add comment