World: convert fields to properties
GitOrigin-RevId: 7b0552c278cfe48e66e806ff94106617bf834252
This commit is contained in:
parent
84fa044675
commit
e6fa78e30f
@ -18,22 +18,20 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
class Tile {
|
class Tile {
|
||||||
readonly Texture2D texture;
|
readonly Texture2D texture;
|
||||||
readonly Terrain terrain;
|
|
||||||
Rectangle position;
|
|
||||||
|
|
||||||
public Tile(Texture2D texture, Terrain terrain, Rectangle position) {
|
public Tile(Texture2D texture, Terrain terrain, Rectangle position) {
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
this.terrain = terrain;
|
this.Terrain = terrain;
|
||||||
this.position = position;
|
this.Position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle Position { get { return position; } }
|
public Rectangle Position { get; private set; }
|
||||||
public Terrain Terrain { get { return terrain; } }
|
public Terrain Terrain { get; private set; }
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch, Camera camera) {
|
public void Draw(SpriteBatch spriteBatch, Camera camera) {
|
||||||
int size = World.TileSize;
|
int size = World.TileSize;
|
||||||
Vector2 drawPos = new Vector2(position.Left - camera.Left, position.Top);
|
Vector2 drawPos = new Vector2(Position.Left - camera.Left, Position.Top);
|
||||||
switch (terrain) {
|
switch (Terrain) {
|
||||||
case Terrain.Grass: {
|
case Terrain.Grass: {
|
||||||
Rectangle source = new Rectangle(3 * size, 0 * size, size, size);
|
Rectangle source = new Rectangle(3 * size, 0 * size, size, size);
|
||||||
spriteBatch.Draw(texture, drawPos, source, Color.White);
|
spriteBatch.Draw(texture, drawPos, source, Color.White);
|
||||||
|
Loading…
Reference in New Issue
Block a user