Skip to content

MapTile.cs

aenemenate edited this page Dec 26, 2019 · 7 revisions

Map Tile

Data and it Purpose

A map tile is a 100x100 "chunk" of the world map. It stores some basic properties, such as whether it is owned by the player, what its cost is, how much buildable space it contains, and whether or not it has a dungeon and where that potential dungeon's entrance is.

To store the block and floor tile properties, there are two maps: Block[] map && Tile[] floor. These two maps are one dimensional, and are accessed via the expression (x*width + y).

There are many ways to access this data. You can call WorldMap[wx, wy][x, y] for block data in MapTile (wx, wy) at (x, y). You can call WorldMap[wx, wy].Blocks[x*width+y] or WorldMap[wx, wy].Floor[x*width+y]. Calling this for a block will return an abstract Block object which you can cast into something else if necessary.

To store the creatures, we have a List<Creature> creatures.

There is a DijkstraMap object that the AI uses for navigation. This can be safely ignored unless you want to use it for another function. It's currently only used in-game for ai on the same level as the player and needs to be expanded in the future (such as being correlated/stored with the map/property maps)


Functionality

There are a few important functions to note upon and many various checks which are used during worldgen and gameplay.

The MapTile calls DetermineCost() when it is first created. This function sets its cost to the proper value. This value should be set along with other FINANCIAL VALUES once every FINANCIAL PERIOD. (not implemented)

DrawCell(int x, int y) draws the cell at (x, y). This is a complicated function not worth delving into here. Remember that to draw what is at that position, we must first figure out where on the screen that position should be displayed. Then which block is to be displayed, and if it's a cell on the overworld then what its height is (tile colors are made brighter/darker depending on height)

The rest of the functions are checks and gets which make it easier to work with the map's data.

Clone this wiki locally