Skip to content

Latest commit

 

History

History
149 lines (59 loc) · 4.87 KB

README_EN.md

File metadata and controls

149 lines (59 loc) · 4.87 KB

English | 简体中文

License

MapGridInUnity

A universal game map solution

Analysis of design ideas

Design and analysis of universal game map solution

Main module

Minimum heap maximum heap module

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.

Universal map module

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 node GameObject, binding the map data, getting display object and location, etc.

  • INode: Defines what a simple node should contain.

  • IPathNode: This interface implements all contents of INode, 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.

Pathfinding module

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.

Gif example

Create map generate configuration

创建地图配置

Create Map

创建地图

Whether the map starting point needs to be offset

地图是否需要偏移

Pathfinding

寻路

Map highlighting

地图高亮

Example figure

The grid in the highlighted range of a hexagon map

六边形地图高亮范围内的格子

The hexagon map highlights the grid in the specified direction

The Hexagonal map highlights the grid within the sector

The grid in the highlighted range of the grid map

The grid map highlights the grid in the specified direction

Grids in the highlighted sector of the grid map

Hexagonal map pathfinding

Four direction grid map pathfinding

Eight direction grid map pathfinding

Class diagram

MapGridInUnity类图.drawio

Road map

  • 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.