PotatoPlan/Game1/Sources/Smart/AI.cs

81 lines
1.8 KiB
C#
Raw Normal View History

2020-05-05 16:27:45 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
2020-05-06 16:22:30 +02:00
using Microsoft.Xna.Framework.Graphics;
2020-05-05 16:27:45 +02:00
class AI
{
private Vector2 tractorPos;
private Vector2 housePos;
2020-05-06 16:22:30 +02:00
private Farm farm;
2020-05-05 16:27:45 +02:00
private Vector2 Size;
private Vector2 targetPos;
2020-05-06 16:22:30 +02:00
private Inventory inventory = new Inventory();
2020-05-05 16:27:45 +02:00
private int Rotation;
private Random r = new Random();
2020-05-06 16:22:30 +02:00
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);
}
2020-05-05 16:27:45 +02:00
2020-05-06 16:22:30 +02:00
public void update(Farm newFarm, Vector2 newSize, Vector2 newTractorPos, Vector2 newHousePos, Vector2 newtargetPos, int rotation)
2020-05-05 16:27:45 +02:00
{
tractorPos = new Vector2((int)newTractorPos.X, (int)newTractorPos.Y);
housePos = new Vector2((int)newHousePos.X, (int)newHousePos.Y);
targetPos = newtargetPos;
2020-05-06 16:22:30 +02:00
farm = newFarm;
2020-05-05 16:27:45 +02:00
Size = newSize;
Rotation = rotation;
}
2020-05-06 16:22:30 +02:00
public void drawInventory(Input input, SpriteBatch spriteBatch, SpriteFont Bold, Cargo itemStorageDefined)
{
inventory.printItems(input, spriteBatch, Bold);
}
2020-05-05 16:27:45 +02:00
public Vector2 newTarget()
{
return new Vector2(r.Next(0, (int)Size.X), r.Next(0, (int)Size.Y));
}
2020-05-06 16:22:30 +02:00
public Farm changeCropStatus()
{
if (farm.getCrop((int)tractorPos.X, (int)tractorPos.Y).getCropTimer() == 1)
{
farm.setCropStatus(tractorPos.X, tractorPos.Y);
}
return farm;
}
2020-05-06 20:48:20 +02:00
public Inventory getInventory()
{
return inventory;
}
2020-05-05 16:27:45 +02:00
}