PotatoPlan/Game1/Sources/Smart/AI.cs
2020-05-06 16:22:30 +02:00

76 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
class AI
{
private Vector2 tractorPos;
private Vector2 housePos;
private Farm farm;
private Vector2 Size;
private Vector2 targetPos;
private Inventory inventory = new Inventory();
private int Rotation;
private Random r = new Random();
public void init()
{
inventory.initInventorySystem();
inventory.addItem(1, 1);
inventory.addItem(1, 1);
inventory.addItem(3, 1);
inventory.addItem(5, 1);
inventory.addItem(7, 1);
inventory.addItem(7, 1);
inventory.addItem(10, 1);
inventory.addItem(10, 1);
inventory.useItem(10, 1);
}
public void update(Farm newFarm, Vector2 newSize, Vector2 newTractorPos, Vector2 newHousePos, Vector2 newtargetPos, int rotation)
{
tractorPos = new Vector2((int)newTractorPos.X, (int)newTractorPos.Y);
housePos = new Vector2((int)newHousePos.X, (int)newHousePos.Y);
targetPos = newtargetPos;
farm = newFarm;
Size = newSize;
Rotation = rotation;
}
public void drawInventory(Input input, SpriteBatch spriteBatch, SpriteFont Bold, Cargo itemStorageDefined)
{
inventory.printItems(input, spriteBatch, Bold);
}
public Vector2 newTarget()
{
return new Vector2(r.Next(0, (int)Size.X), r.Next(0, (int)Size.Y));
}
public Farm changeCropStatus()
{
if (farm.getCrop((int)tractorPos.X, (int)tractorPos.Y).getCropTimer() == 1)
{
farm.setCropStatus(tractorPos.X, tractorPos.Y);
}
return farm;
}
}