forked from s425077/PotatoPlan
64 lines
1.4 KiB
C#
64 lines
1.4 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
|
|
class SmartTractor
|
|
{
|
|
private Crops[,] crops;
|
|
private Vector2 housePos;
|
|
private Vector2 tractorPos;
|
|
private Vector2 Size;
|
|
private Vector2 Target;
|
|
|
|
private int tileSize;
|
|
private int Score;
|
|
private int Spacing;
|
|
private Astar astar = new Astar();
|
|
private int Rotation;
|
|
private AI ai = new AI();
|
|
|
|
|
|
//What to do next
|
|
public Path returnChoice()
|
|
{
|
|
ai.update(crops, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
|
|
|
|
|
|
|
|
|
|
getTargetPosition(ai.newTarget());
|
|
|
|
|
|
|
|
|
|
|
|
astar.update(crops, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target/(tileSize+Spacing), Rotation);
|
|
|
|
return astar.FindPath();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Updates the variables every frame
|
|
public void updateMap(Vector2 newTractorPos, Vector2 newHousePos, Crops[,] newCropsStatus, Vector2 newSize, int newTileSize, int newSpacing, int newScore, int rotation)
|
|
{
|
|
crops = newCropsStatus;
|
|
housePos = newHousePos;
|
|
tractorPos = newTractorPos;
|
|
Size = newSize;
|
|
tileSize = newTileSize;
|
|
Spacing = newSpacing;
|
|
Score = newScore;
|
|
Rotation = rotation;
|
|
|
|
}
|
|
|
|
private void getTargetPosition(Vector2 newTarget)
|
|
{
|
|
Target = newTarget * (tileSize + Spacing);
|
|
}
|
|
}
|