2020-04-08 20:04:31 +02:00
|
|
|
|
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();
|
|
|
|
|
|
2020-05-03 13:05:05 +02:00
|
|
|
|
//initializes the house
|
2020-04-08 20:04:31 +02:00
|
|
|
|
public void init(int tileSize, int Spacing)
|
|
|
|
|
{
|
|
|
|
|
int x = r.Next(0, 8);
|
|
|
|
|
int y = r.Next(0, 8);
|
|
|
|
|
|
|
|
|
|
pos = new Vector2(x, y);
|
2020-05-06 16:22:30 +02:00
|
|
|
|
housePos = new Rectangle(x * (tileSize + Spacing), y * (tileSize + Spacing), tileSize, tileSize);
|
2020-04-08 20:04:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 13:05:05 +02:00
|
|
|
|
|
|
|
|
|
//Moves the house if it is currently out of matrix.
|
|
|
|
|
public void updateRectangle(Vector2 Size, int tileSize, int Spacing)
|
2020-04-08 20:04:31 +02:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2020-05-03 13:05:05 +02:00
|
|
|
|
housePos = new Rectangle((int)pos.X * (tileSize + Spacing), (int)pos.Y * (tileSize + Spacing), tileSize, tileSize);
|
2020-04-08 20:04:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 13:05:05 +02:00
|
|
|
|
|
2020-04-08 20:04:31 +02:00
|
|
|
|
public Rectangle GetRectangle()
|
|
|
|
|
{
|
|
|
|
|
return housePos;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 16:27:45 +02:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 20:04:31 +02:00
|
|
|
|
public Vector2 getVector()
|
|
|
|
|
{
|
|
|
|
|
return new Vector2(housePos.X, housePos.Y);
|
|
|
|
|
}
|
|
|
|
|
}
|