1
0
forked from s425077/PotatoPlan

Removing old files

This commit is contained in:
BOTLester 2020-05-04 11:37:20 +02:00
parent 740730958b
commit 28f5031ba8
8 changed files with 0 additions and 591 deletions

View File

@ -1,46 +0,0 @@
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

@ -1,91 +0,0 @@
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

@ -1,47 +0,0 @@
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

@ -1,100 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
class Input
{
private KeyboardState state = Keyboard.GetState();
private GraphicsDeviceManager graphics;
private Vector2 Size;
private int tileSize;
private int Spacing;
public void init(GraphicsDeviceManager Graphics, Vector2 size, int TileSize, int SPacing)
{
graphics = Graphics;
tileSize = TileSize;
Spacing = SPacing;
Size = size;
}
public int changeSpeed(int speed)
{
KeyboardState state = Keyboard.GetState();
if (state.IsKeyDown(Keys.Right))
{
speed++;
}
if (state.IsKeyDown(Keys.Left) && speed > 0)
{
speed--;
}
return speed;
}
private Vector2 changeSize()
{
KeyboardState state = Keyboard.GetState();
if (state.IsKeyDown(Keys.D) && Size.X < 100)
{
Size.X++;
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 - Spacing;
}
if (state.IsKeyDown(Keys.W) && Size.Y < (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize)
{
Size.Y++;
graphics.PreferredBackBufferHeight = (tileSize + Spacing) * (int)Size.Y - Spacing + 100;
}
if (state.IsKeyDown(Keys.S) && Size.Y > 2)
{
Size.Y--;
graphics.PreferredBackBufferHeight = (tileSize + Spacing) * (int)Size.Y - Spacing + 100;
}
return Size;
}
public void controlWindowSize()
{
if (Size.X * tileSize + 5 > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width)
{
tileSize--;
}
if (Size.X * tileSize - 5 < GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width && tileSize < 56)
{
tileSize++;
}
changeSize();
graphics.ApplyChanges();
}
public int getTileSize()
{
return tileSize;
}
public int getSpacing()
{
return Spacing;
}
public Vector2 getSize()
{
return Size;
}
public void setTileSize(int newTileSize)
{
tileSize = newTileSize;
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game1.Sources
{
class Queue
{
private Task[] task;
public void Sort()
{
}
}
}

View File

@ -1,23 +0,0 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Game1.Sources
{
class Task
{
private Vector2 Position;
private int Objective;
private float timer;
public void setTimer(float newTimer)
{
timer = newTimer;
}
public void updateTimer()
{
timer = timer - 1 / 60;
}
}
}

View File

@ -1,220 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
class Tractor
{
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(Input input, int Status, Vector2 newHousePos)
{
Spacing = input.getSpacing();
sizeTile = input.getTileSize();
Size = input.getSize();
updatePosition(input.getSize(), Status);
housePos = newHousePos;
}
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)
{
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 0;
}
else if (DeltaPosition.Y < 0)
{
Direction = new Vector2(0, -1);
return 0;
}
return 0;
}
else if (DeltaPosition.X > 0)
{
Direction = new Vector2(1, 0);
return 0;
}
else if (DeltaPosition.X < 0)
{
Direction = new Vector2(-1, 0);
return 0;
}
return 0;
}
public void updatePosition(Vector2 Size, int Status) /// updates the position
{
farm.updateSize(Size, sizeTile, Spacing);
for (int i = 0; i < Speed; i++) //Where all the choices the tractor does comes from
{
smartTractor.updateMap(Position, housePos, farm.getCrops(), Size, sizeTile, Spacing, Score);
Position = Position + Direction;
updateDirection(Size, Position);
}
}
public Vector2 getPos()
{
return Position;
}
public void increaseSpeed()
{
Speed++;
}
public void decreaseSpeed()
{
if (Speed > 0)
{
Speed--;
}
}
private void setTargetPosition(Vector2 newPosition) /// sets the TargetPosition once it reaches its destination
{
TargetPosition = newPosition;
}
public void setSpeed(int newSpeed)
{
Speed = newSpeed;
}
public int getSpeed()
{
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

@ -1,46 +0,0 @@
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;
}
}