80 lines
1.8 KiB
C#
80 lines
1.8 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;
|
|
}
|
|
|
|
public Inventory getInventory()
|
|
{
|
|
return inventory;
|
|
}
|
|
}
|