1
0
forked from s425077/PotatoPlan
JoelForkTest/Game1/Sources/Objects/House.cs
2020-05-06 22:02:31 +02:00

57 lines
1.4 KiB
C#

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();
//initializes the house
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);
}
//Moves the house if it is currently out of matrix.
public void updateRectangle(Vector2 Size, int tileSize, int Spacing)
{
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 + Spacing), (int)pos.Y * (tileSize + Spacing), tileSize, tileSize);
}
//Returns house Rectangle
public Rectangle GetRectangle()
{
return housePos;
}
public void setRectangle(int x, int y, int tileSize, int Spacing)
{
pos = new Vector2(x, y);
housePos = new Rectangle(x * (tileSize + Spacing), y * (tileSize + Spacing), tileSize, tileSize);
}
public Vector2 getVector()
{
return new Vector2(housePos.X, housePos.Y);
}
}