English | 简体中文
A universal game map solution
Design and analysis of universal game map solution
This module mainly supports subsequent pathfinding algorithms. It uses the list as the actual storage container, and the list elements need to implement the IComparable
interface. The algorithm adjusts the sorting of heap elements through the CompareTo
method.
The module does this by completely separating the map data from the map display. A series of map-related interfaces are separated from the module, such as IMapGrid
, IMapShow
, INode
, IPathNode
, INodeEntity
, etc. Each interface is responsible for defining what the implementation class should do. This module uses the interface to realize the universality of the map module. Each class in the module only depends on the method in the interface, and the type is set through the form of dependency injection.
-
IMapGrid
: The common properties and necessary methods of the map data class are defined. -
IMapShow
: Defines the map display related content, such as setting the map nodeGameObject
, binding the map data, getting display object and location, etc. -
INode
: Defines what a simple node should contain. -
IPathNode
: This interface implements all contents ofINode
, and on this basis adds some necessary contents of pathfinding, such as generation value, parent node, whether passable and so on. -
INodeEntity
: Defines display interfaces for nodes, such as highlighting, restoring, and so on.
This module contains the A star pathfinding algorithm and optimized minimum heap of A star algorithm in the optimization algorithm, the introduction of the minimum heap to quickly remove the minimum cost of the node from the Open list, introducing the SessionId to speed the list if the node in the Open and Close the list of judgment.
- Added structure class diagram for map module.
- Take apart the entire module via blog or video.
- Added pathfinding algorithm test scenario.
- Added a TileMap example.
- Map editor based on Unity UI Elements.