done by hand, but works eh.

First stable. RC_01
This commit is contained in:
BOTLester 2020-04-08 20:04:31 +02:00
parent 363f3fe1d1
commit 4d1b20b32f
36 changed files with 897 additions and 60 deletions

63
Tractor_VS/.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

261
Tractor_VS/.gitignore vendored Normal file
View File

@ -0,0 +1,261 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

Binary file not shown.

View File

@ -13,6 +13,18 @@
#---------------------------------- Content ---------------------------------#
#begin Crop.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Crop.png
#begin Font.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
@ -20,6 +32,42 @@
/processorParam:TextureFormat=Compressed
/build:Font.spritefont
#begin house.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:house.png
#begin Plantable.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Plantable.png
#begin Planted.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Planted.png
#begin Tile.png
/importer:TextureImporter
/processor:TextureProcessor
@ -32,6 +80,18 @@
/processorParam:TextureFormat=Color
/build:Tile.png
#begin tileunplantable.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:tileunplantable.png
#begin Tractor.png
/importer:TextureImporter
/processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -4,13 +4,23 @@
<Platform>Windows</Platform>
<Config />
<SourceFiles>
<File>C:/Users/Joel/source/repos/Game1/Game1/Content/Font.spritefont</File>
<File>C:/Users/Joel/source/repos/Game1/Game1/Content/Tile.png</File>
<File>C:/Users/Joel/source/repos/Game1/Game1/Content/Tractor.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Crop.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Font.spritefont</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/house.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Plantable.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Planted.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Tile.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/tileunplantable.png</File>
<File>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Tractor.png</File>
</SourceFiles>
<DestFiles>
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
</DestFiles>
</SourceFileCollection>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SourceFile>C:/Users/Joel/source/repos/Game1/Game1/Content/Font.spritefont</SourceFile>
<SourceFile>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Font.spritefont</SourceFile>
<SourceTime>2018-12-08T17:35:46+01:00</SourceTime>
<DestFile>C:/Users/Joel/source/repos/Game1/Game1/Content/bin/Windows/Content/Font.xnb</DestFile>
<DestTime>2020-04-07T00:39:59.615775+02:00</DestTime>
<DestFile>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/bin/Windows/Content/Font.xnb</DestFile>
<DestTime>2020-04-08T19:58:28.9131631+02:00</DestTime>
<Importer>FontDescriptionImporter</Importer>
<ImporterTime>2018-12-08T17:35:54+01:00</ImporterTime>
<Processor>FontDescriptionProcessor</Processor>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SourceFile>C:/Users/Joel/source/repos/Game1/Game1/Content/Tile.png</SourceFile>
<SourceTime>2020-04-06T13:52:22.5160544+02:00</SourceTime>
<DestFile>C:/Users/Joel/source/repos/Game1/Game1/Content/bin/Windows/Content/Tile.xnb</DestFile>
<DestTime>2020-04-07T00:39:59.9623316+02:00</DestTime>
<SourceFile>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Tile.png</SourceFile>
<SourceTime>2020-04-07T14:11:48.0383577+02:00</SourceTime>
<DestFile>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/bin/Windows/Content/Tile.xnb</DestFile>
<DestTime>2020-04-08T19:58:29.046164+02:00</DestTime>
<Importer>TextureImporter</Importer>
<ImporterTime>2018-12-08T17:35:54+01:00</ImporterTime>
<Processor>TextureProcessor</Processor>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SourceFile>C:/Users/Joel/source/repos/Game1/Game1/Content/Tractor.png</SourceFile>
<SourceFile>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/Tractor.png</SourceFile>
<SourceTime>2020-04-06T14:11:32.7941423+02:00</SourceTime>
<DestFile>C:/Users/Joel/source/repos/Game1/Game1/Content/bin/Windows/Content/Tractor.xnb</DestFile>
<DestTime>2020-04-07T00:39:59.9743322+02:00</DestTime>
<DestFile>D:/Ny mapp (2)/Ny mapp (2)/PotatoPlan/Tractor_VS/Game1/Content/bin/Windows/Content/Tractor.xnb</DestFile>
<DestTime>2020-04-08T19:58:29.1251636+02:00</DestTime>
<Importer>TextureImporter</Importer>
<ImporterTime>2018-12-08T17:35:54+01:00</ImporterTime>
<Processor>TextureProcessor</Processor>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
namespace Game1
{
@ -12,11 +13,12 @@ namespace Game1
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont Bold;
private Texture2D tile;
private Texture2D[] tile = new Texture2D[4];
private Texture2D tractor;
private Texture2D house;
private Tractor tractorUnit = new Tractor();
private Input input = new Input();
private House houseUnit = new House();
public Game1()
@ -29,8 +31,19 @@ namespace Game1
{
// TODO: Add your initialization logic here
base.Initialize();
input.init(graphics, new Vector2(8,8), 56, 1);
tractorUnit.updateSizing(input.getTileSize(), input.getSpacing());
//Generates the map with some random values
input.init(graphics, new Vector2(8,8), 56, 1); //Generates the starting size
houseUnit.init(input.getTileSize(), input.getSpacing()); //Generates the house position
tractorUnit.init(houseUnit.GetRectangle());
tractorUnit.updateSizing(input, 0, houseUnit.getVector());
tractorUnit.setPos(houseUnit.getVector());
graphics.PreferredBackBufferWidth = (input.getTileSize() + input.getSpacing()) * (int)input.getSize().X;
graphics.PreferredBackBufferHeight = (input.getTileSize() + input.getSpacing()) * (int)input.getSize().Y + 125;
graphics.ApplyChanges();
@ -38,28 +51,37 @@ namespace Game1
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
tile = Content.Load<Texture2D>("Tile");
//Loads the PNG content and Fonts
tile[0] = Content.Load<Texture2D>("tileunplantable");
tile[1] = Content.Load<Texture2D>("Plantable");
tile[2] = Content.Load<Texture2D>("Planted");
tile[3] = Content.Load<Texture2D>("Crop");
tractor = Content.Load<Texture2D>("Tractor");
Bold = Content.Load<SpriteFont>("Font");
house = Content.Load<Texture2D>("house");
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
protected override void Update(GameTime gameTime) //updates every 60 seconds
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
tractorUnit.updateSizing(input.getTileSize(), input.getSpacing());
tractorUnit.updatePosition(input.getSize());
tractorUnit.setSpeed(input.changeSpeed(tractorUnit.getSpeed()));
input.changeSize();
tractorUnit.updateSizing(input, 0, houseUnit.getVector()); //Updates the size
tractorUnit.setSpeed(input.changeSpeed(tractorUnit.getSpeed())); //Updates the speed of the tractor
input.controlWindowSize(); //Controls the size of the screen depending on the number of tiles
houseUnit.updateRectangle(input.getSize(), input.getTileSize());
base.Update(gameTime);
}
@ -75,13 +97,18 @@ namespace Game1
{
for (int j = 0; j < input.getSize().Y; j++)
{
spriteBatch.Draw(tile, new Rectangle(i * (input.getTileSize() + input.getSpacing()), j * (input.getTileSize() + input.getSpacing()), input.getTileSize(), input.getTileSize()), Color.White);
spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).Status], new Rectangle(i * (input.getTileSize() + input.getSpacing()), j * (input.getTileSize() + input.getSpacing()), input.getTileSize(), input.getTileSize()), Color.White);
}
}
spriteBatch.Draw(tractor, new Rectangle((int)tractorUnit.getTargetPosition().X, (int)tractorUnit.getTargetPosition().Y, input.getTileSize(), input.getTileSize()) , Color.Red); //Draws the tractors target
spriteBatch.Draw(tractor, new Rectangle((int)tractorUnit.getPos().X, (int)tractorUnit.getPos().Y, input.getTileSize(), input.getTileSize()), Color.Black); //Draws the tractor
spriteBatch.DrawString(Bold, "Speed:" + tractorUnit.getSpeed().ToString(), new Vector2(10, input.getSize().Y * input.getTileSize() + 20) , Color.White); //Draws the the speed
spriteBatch.Draw(tractor, new Rectangle((int)tractorUnit.getTargetPosition().X, (int)tractorUnit.getTargetPosition().Y, input.getTileSize(), input.getTileSize()) , Color.Red); //Draws the current target of the tractor
spriteBatch.Draw(tractor, new Rectangle((int)tractorUnit.getPos().X, (int)tractorUnit.getPos().Y, input.getTileSize(), input.getTileSize()), Color.White);
spriteBatch.Draw(house, houseUnit.GetRectangle(), Color.White);
spriteBatch.DrawString(Bold, "Speed:" + tractorUnit.getSpeed().ToString(), new Vector2(10, input.getSize().Y * input.getTileSize() + 20) , Color.White); //Draws the speed value
spriteBatch.DrawString(Bold, "Tile Size:" + input.getTileSize().ToString() + "pix", new Vector2(10, input.getSize().Y * input.getTileSize() + 40), Color.White); //Draws the tile size
spriteBatch.DrawString(Bold, "Matrix Size: " + input.getSize().X.ToString() + " X " + input.getSize().Y.ToString(), new Vector2(10, input.getSize().Y * input.getTileSize() + 60), Color.White);
spriteBatch.DrawString(Bold, tractorUnit.getCurrentTask(), new Vector2(10, input.getSize().Y * input.getTileSize() + 80), Color.White); //Draws the tile size
spriteBatch.DrawString(Bold, tractorUnit.getScore().ToString(), new Vector2(10, input.getSize().Y * input.getTileSize() + 100), Color.White);
spriteBatch.End();
base.Draw(gameTime);

View File

@ -44,8 +44,12 @@
<Compile Include="Game1.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sources\House.cs" />
<Compile Include="Sources\Crops.cs" />
<Compile Include="Sources\Farm.cs" />
<Compile Include="Sources\Input.cs" />
<Compile Include="Sources\Queue.cs" />
<Compile Include="Sources\SmartTractor.cs" />
<Compile Include="Sources\Task.cs" />
<Compile Include="Sources\Tractor.cs" />
</ItemGroup>
@ -57,7 +61,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\Crop.png" />
<Content Include="Content\house.png" />
<Content Include="Content\Plantable.png" />
<Content Include="Content\Planted.png" />
<Content Include="Content\Tile.png" />
<Content Include="Content\tileunplantable.png" />
<Content Include="Content\Tractor.png" />
<Content Include="Icon.ico" />
</ItemGroup>

View File

@ -0,0 +1,46 @@
using System;
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 Crops
{
public int Status;
private int Timer;
private Random r;
public int x;
public int y;
public void updateCrop()
{
if (Status != 0)
{
Timer--;
}
}
public int getCropTimer()
{
return Timer;
}
public int getStatus()
{
return Status;
}
public void setStatus(int newStatus)
{
Status = newStatus;
}
public void setPosition(int newx, int newy)
{
x = newx;
y = newy;
}
}

View File

@ -0,0 +1,91 @@
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 Farm
{
private Crops[,] crops;
private Random r;
public void init(Vector2 Size)
{
r = new Random();
crops = new Crops[100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 56) - 125 / 56];
for (int i = 0; i < Size.X; i++)
{
for (int j = 0; j < Size.Y; j++)
{
int x = r.Next(0, 2);
crops[i, j] = new Crops();
crops[i, j].Status = x;
}
}
}
public void updateFarm(Vector2 Size)
{
for (int i = 0; i > Size.X; i++)
{
for (int j = 0; j > Size.Y; j++)
{
crops[i, j].updateCrop();
}
}
}
public void setCropStatus(float xfloat, float yfloat, int Spacing)
{
int x = (int)xfloat / Spacing;
int y = (int)yfloat / Spacing;
if (crops[x, y].Status == 3)
{
crops[x, y].Status = 1;
}
else if(crops[x, y].Status == 0)
{
//do nothing
}
else if (crops[x, y].Status == 1)
{
crops[x, y].Status = 2;
}
else if (crops[x, y].Status == 2)
{
crops[x, y].Status = 3;
}
}
public Crops getCrop(int x, int y)
{
return crops[x,y];
}
public Crops[,] getCrops()
{
return crops;
}
public void updateSize(Vector2 Size, int tileSize, int Spacing)
{
for (int i = 0; i < (int)Size.X; i++)
{
for (int j = 0; j < (int)Size.Y; j++)
{
crops[i, j].x = (tileSize + Spacing) * i;
crops[i, j].y = (tileSize + Spacing) * j;
}
}
}
public string getSize()
{
return crops[1, 1].x.ToString();
}
}

View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
class House
{
private Rectangle housePos;
private Vector2 pos;
private Random r = new Random();
public void init(int tileSize, int Spacing)
{
int x = r.Next(0, 8);
int y = r.Next(0, 8);
pos = new Vector2(x, y);
housePos = new Rectangle((x * tileSize + Spacing), y * (tileSize + Spacing), tileSize, tileSize);
}
public void updateRectangle(Vector2 Size, int tileSize)
{
if (pos.X + 1 > Size.X)
{
pos = new Vector2(pos.X - 1, pos.Y);
}
if (pos.Y + 1 > Size.Y)
{
pos = new Vector2(pos.X, pos.Y - 1);
}
housePos = new Rectangle((int)pos.X * (tileSize + 1), (int)pos.Y * (tileSize + 1), tileSize, tileSize);
}
public Rectangle GetRectangle()
{
return housePos;
}
public Vector2 getVector()
{
return new Vector2(housePos.X, housePos.Y);
}
}

View File

@ -7,10 +7,10 @@ using Microsoft.Xna.Framework.Graphics;
class Input
{
private KeyboardState state = Keyboard.GetState();
GraphicsDeviceManager graphics;
Vector2 Size;
int tileSize;
int Spacing;
private GraphicsDeviceManager graphics;
private Vector2 Size;
private int tileSize;
private int Spacing;
public void init(GraphicsDeviceManager Graphics, Vector2 size, int TileSize, int SPacing)
{
@ -35,46 +35,46 @@ class Input
return speed;
}
public Vector2 changeSize()
private Vector2 changeSize()
{
KeyboardState state = Keyboard.GetState();
if (state.IsKeyDown(Keys.D) && Size.X < 100)
{
Size.X++;
graphics.PreferredBackBufferWidth = (tileSize + Spacing) * (int)Size.X - 1;
graphics.PreferredBackBufferWidth = (tileSize + Spacing) * (int)Size.X - Spacing;
}
if (state.IsKeyDown(Keys.A) && Size.X > 2)
{
Size.X--;
graphics.PreferredBackBufferWidth = (tileSize + Spacing) * (int)Size.X - 1;
graphics.PreferredBackBufferWidth = (tileSize + Spacing) * (int)Size.X - Spacing;
}
if (state.IsKeyDown(Keys.W) && Size.Y < (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 56) - 125/56)
if (state.IsKeyDown(Keys.W) && Size.Y < (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize)
{
Size.Y++;
graphics.PreferredBackBufferHeight = 57 * (int)Size.Y - 1 + 100;
graphics.PreferredBackBufferHeight = (tileSize + Spacing) * (int)Size.Y - Spacing + 100;
}
if (state.IsKeyDown(Keys.S) && Size.Y > 2)
{
Size.Y--;
graphics.PreferredBackBufferHeight = 57 * (int)Size.Y - 1 + 100;
graphics.PreferredBackBufferHeight = (tileSize + Spacing) * (int)Size.Y - Spacing + 100;
}
controlWindowSize();
return Size;
}
private void controlWindowSize()
public void controlWindowSize()
{
if (Size.X * tileSize + 20 > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width)
if (Size.X * tileSize + 5 > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width)
{
tileSize--;
}
if (Size.X * tileSize - 100 < GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width && tileSize < 56)
if (Size.X * tileSize - 5 < GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width && tileSize < 56)
{
tileSize++;
}
changeSize();
graphics.ApplyChanges();
}

View File

@ -6,60 +6,105 @@ using System;
class Tractor
{
private Vector2 Position;
static private Vector2 Position;
private Vector2 TargetPosition;
private Vector2 Direction;
private int Spacing, sizeTile;
private int Speed = 1;
private Vector2 Size;
private Random r = new Random();
private Farm farm = new Farm();
private Vector2 housePos;
private String currentTask;
private SmartTractor smartTractor = new SmartTractor();
private int Score;
private int previousTask;
public void updateSizing(int newSize, int newSpacingSize)
public void updateSizing(Input input, int Status, Vector2 newHousePos)
{
Spacing = newSpacingSize;
sizeTile = newSize;
Spacing = input.getSpacing();
sizeTile = input.getTileSize();
Size = input.getSize();
updatePosition(input.getSize(), Status);
housePos = newHousePos;
}
private void updateDirection(Vector2 Size) /// Runs when the tractor reaches a tile
public void init(Rectangle house)
{
sizeTile = 56;
Spacing = 1;
farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / sizeTile) - 125 / sizeTile));
Position = housePos;
}
private int updateDirection(Vector2 Size, Vector2 newPosition) /// Runs when the tractor reaches a tile
{
Vector2 DeltaPosition = TargetPosition - Position;
if (DeltaPosition.X == 0)
{
if (DeltaPosition.Y == 0)
{
Direction = new Vector2(0, 0);
setTargetPosition(new Vector2(r.Next(0, (int)Size.X), r.Next(0, (int)Size.Y)) * (sizeTile + Spacing)); //Sets a random Target
/// Do Nothing - is currently located on the targetPos
return;
if (housePos != Position)
{
int x = (int)Position.X / (sizeTile + Spacing);
int y = (int)Position.Y / (sizeTile + Spacing);
currentTask = currentTaskDecider(farm.getCrop(x, y).Status, 0);
farm.setCropStatus(x, y, Spacing);
setTargetPosition(housePos); //Returns to the farm
}
else
{
setTargetPosition(smartTractor.returnChoice()); //Sets a random Target
int xTarget = (int)TargetPosition.X / (sizeTile + Spacing);
int yTarget = (int)TargetPosition.Y / (sizeTile + Spacing);
currentTask = currentTaskDecider(farm.getCrop(xTarget, yTarget).Status, 1);
}
return 1;
}
else if (DeltaPosition.Y > 0)
{
Direction = new Vector2(0, 1);
return;
return 0;
}
else if (DeltaPosition.Y < 0)
{
Direction = new Vector2(0, -1);
return;
return 0;
}
return 0;
}
else if (DeltaPosition.X > 0)
{
Direction = new Vector2(1, 0);
return;
return 0;
}
else if (DeltaPosition.X < 0)
{
Direction = new Vector2(-1, 0);
return;
return 0;
}
return 0;
}
public void updatePosition(Vector2 Size) /// updates the position
public void updatePosition(Vector2 Size, int Status) /// updates the position
{
for (int i = 0; i < Speed; i++)
farm.updateSize(Size, sizeTile, Spacing);
for (int i = 0; i < Speed; i++) //Where all the choices the tractor does comes from
{
updateDirection(Size);
smartTractor.updateMap(Position, housePos, farm.getCrops(), Size, sizeTile, Spacing, Score);
Position = Position + Direction;
updateDirection(Size, Position);
}
@ -100,8 +145,76 @@ class Tractor
return Speed;
}
public void setPos(Vector2 newPos)
{
Position = newPos;
}
public Farm getFarm()
{
return farm;
}
public Vector2 getTargetPosition()
{
return TargetPosition;
}
public String getCurrentTask()
{
return currentTask;
}
public int getScore()
{
return Score;
}
private String currentTaskDecider(int Status, int Stage)
{
previousTask = Status;
if (previousTask == 3 && Stage != 1)
{
Score++;
}
if (Stage == 0)
{
if (Status == 0)
{
return "Returning with nothing after going out for a stroll";
}
else if (Status == 1)
{
return "Returning with nothing after planting seeds";
}
else if (Status == 2)
{
return "Returning with nothing after adding fertilizer";
}
else if (Status == 3)
{
return "Returning with Crops";
}
}
else
{
if (Status == 0)
{
return "Going for a stroll";
}
else if (Status == 1)
{
return "Planting seeds";
}
else if (Status == 2)
{
return "Adding fertilizer";
}
else if (Status == 3)
{
return "Going for Crops";
}
}
return null;
}
}

View File

@ -0,0 +1,46 @@
using System;
using Microsoft.Xna.Framework;
using System;
class SmartTractor
{
private Crops[,] crops;
private Vector2 housePos;
private Vector2 tractorPos;
private Vector2 Size;
private int tileSize;
private int Score;
private int Spacing;
private Random r = new Random();
public Vector2 returnChoice()
{
return new Vector2(r.Next(0, (int)Size.X), r.Next(0, (int)Size.Y)) * (tileSize + Spacing);
}
public void updateMap(Vector2 newTractorPos, Vector2 newHousePos, Crops[,] newCropsStatus, Vector2 newSize, int newTileSize, int newSpacing, int newScore)
{
crops = newCropsStatus;
housePos = newHousePos;
tractorPos = newTractorPos;
Size = newSize;
tileSize = newTileSize;
Spacing = newSpacing;
Score = newScore;
}
}

View File

@ -0,0 +1 @@
PLZ WORK PLZPLZPLZLPZLXPZLXPZ

View File

@ -1 +1 @@
4d2592adfb4cd19156f3ef9ac9b8402e1aa87b33
e5b74bdf7392fcaaa637d1f384c05bda540e10ba

View File

@ -24,3 +24,66 @@ c:\users\joel\source\repos\Game1\Game1\obj\x86\Debug\Game1.pdb
c:\users\joel\source\repos\Game1\Game1\bin\Windows\x86\Debug\Content\Tile.xnb
c:\users\joel\source\repos\Game1\Game1\bin\Windows\x86\Debug\Content\Tractor.xnb
c:\users\joel\source\repos\Game1\Game1\bin\Windows\x86\Debug\Content\Font.xnb
C:\Users\Joel\source\repos\Game1\Game1\bin\Windows\x86\Debug\Content\house.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Font.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\house.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Tile.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\tileunplantable.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Tractor.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Game1.exe
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Game1.pdb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\MonoGame.Framework.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.MediaFoundation.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XAudio2.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.DXGI.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct3D11.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct2D1.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XInput.dll
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\MonoGame.Framework.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.MediaFoundation.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XAudio2.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.DXGI.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct3D11.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct2D1.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XInput.xml
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.csprojAssemblyReference.cache
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.csproj.CoreCompileInputs.cache
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.csproj.CopyComplete
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.exe
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.pdb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Plantable.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Planted.xnb
C:\Users\Joel\source\repos\s425077\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Crop.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Crop.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Font.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\house.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Plantable.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Planted.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Tile.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\tileunplantable.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Content\Tractor.xnb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Game1.exe
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\Game1.pdb
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\MonoGame.Framework.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.MediaFoundation.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XAudio2.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.DXGI.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct3D11.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct2D1.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XInput.dll
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\MonoGame.Framework.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.MediaFoundation.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XAudio2.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.DXGI.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct3D11.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.Direct2D1.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\bin\Windows\x86\Debug\SharpDX.XInput.xml
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.csprojAssemblyReference.cache
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.csproj.CoreCompileInputs.cache
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.csproj.CopyComplete
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.exe
D:\Ny mapp (2)\Ny mapp (2)\PotatoPlan\Tractor_VS\Game1\obj\x86\Debug\Game1.pdb