1
0
forked from s425077/PotatoPlan
JoelForkTest/Game1/Sources/Farm.cs

92 lines
2.0 KiB
C#
Raw Normal View History

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();
}
}