Last active
May 30, 2017 04:57
-
-
Save aschuhardt/987ee4903bcd312718e98cddcd2d8409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
public class Map { | |
private Tile.TileTypes[,] _tileTypesLayout; | |
private int _width, _height; | |
private int _offsetX, _offsetY; | |
//North node | |
private Map _north; | |
public Map North { | |
get { | |
if (_north == null) { | |
_north = new Map(_width, _height, _offsetX, _offsetY - 1); | |
_north.South = this; | |
if (_west != null) | |
_north.SouthWest = _west; | |
if (_northWest != null) | |
_north.West = _northWest; | |
if (_northEast != null) | |
_north.East = _northEast; | |
if (_east != null) | |
_north.SouthEast = _east; | |
} | |
return _north; | |
} | |
set { _north = value; } | |
} | |
//South node | |
private Map _south; | |
public Map South { | |
get { | |
if (_south == null) { | |
_south = new Map(_width, _height, _offsetX, _offsetY + 1); | |
_south.North = this; | |
if (_southWest != null) | |
_south.West = _southWest; | |
if (_west != null) | |
_south.NorthWest = _west; | |
if (_east != null) | |
_south.NorthEast = _east; | |
if (_southEast != null) | |
_south.East = _southEast; | |
} | |
return _south; | |
} | |
set { _south = value; } | |
} | |
//East node | |
private Map _east; | |
public Map East { | |
get { | |
if (_east == null) { | |
_east = new Map(_width, _height, _offsetX + 1, _offsetY); | |
_east.West = this; | |
if (_south != null) | |
_east.SouthWest = _south; | |
if (_southEast != null) | |
_east.South = _southEast; | |
if (_northEast != null) | |
_east.North = _northEast; | |
if (_north != null) | |
_east.NorthWest = _north; | |
} | |
return _east; | |
} | |
set { _east = value; } | |
} | |
//West node | |
private Map _west; | |
public Map West { | |
get { | |
if (_west == null) { | |
_west = new Map(_width, _height, _offsetX - 1, _offsetY); | |
_west.East = this; | |
if (_south != null) | |
_west.SouthEast = _south; | |
if (_southWest != null) | |
_west.South = _southWest; | |
if (_northWest != null) | |
_west.North = _northWest; | |
if (_north != null) | |
_west.NorthEast = _north; | |
} | |
return _west; | |
} | |
set { _west = value; } | |
} | |
//NorthEast node | |
private Map _northEast; | |
public Map NorthEast { | |
get { | |
if (_northEast == null) { | |
_northEast = new Map(_width, _height, _offsetX + 1, _offsetY - 1); | |
_northEast.SouthWest = this; | |
if (_north != null) | |
_northEast.West = _north; | |
if (_east != null) | |
_northEast.South = _east; | |
} | |
return _northEast; | |
} | |
set { _northEast = value; } | |
} | |
//NorthWest node | |
private Map _northWest; | |
public Map NorthWest { | |
get { | |
if (_northWest == null) { | |
_northWest = new Map(_width, _height, _offsetX - 1, _offsetY - 1); | |
_northWest.SouthEast = this; | |
if (_north != null) | |
_northWest.East = _north; | |
if (_west != null) | |
_northWest.South = _west; | |
} | |
return _northWest; | |
} | |
set { _northWest = value; } | |
} | |
//SouthEast node | |
private Map _southEast; | |
public Map SouthEast { | |
get { | |
if (_southEast == null) { | |
_southEast = new Map(_width, _height, _offsetX + 1, _offsetY + 1); | |
_southEast.NorthWest = this; | |
if (_south != null) | |
_southEast.West = _south; | |
if (_east != null) | |
_southEast.North = _east; | |
} | |
return _southEast; | |
} | |
set { _southEast = value; } | |
} | |
//SouthWest node | |
private Map _southWest; | |
public Map SouthWest { | |
get { | |
if (_southWest == null) { | |
_southWest = new Map(_width, _height, _offsetX - 1, _offsetY + 1); | |
_southWest.NorthEast = this; | |
if (_west != null) | |
_southWest.North = _west; | |
if (_south != null) | |
_southWest.East = _south; | |
} | |
return _southWest; | |
} | |
set { _southWest = value; } | |
} | |
public Map(int width, int height, int offsetX, int offsetY) { | |
_tileTypesLayout = new Tile.TileTypes[width, height]; | |
_offsetX = offsetX; | |
_offsetY = offsetY; | |
} | |
public void SetTileType(int x, int y, Tile.TileTypes t) { | |
_tileTypesLayout[x, y] = t; | |
} | |
public Tile.TileTypes TileTypeAt(int x, int y) { | |
return _tileTypesLayout[x, y]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment