ModestosV / BlackDice

SOEN490 Capstone Project @ Concordia University
MIT License
4 stars 1 forks source link

View Hex Grid #1

Closed 0matleb2 closed 6 years ago

0matleb2 commented 6 years ago

User Story

As a user, I want to view a grid playing field composed of hexagonal tiles. I want to view a variety of playing field layouts including a 6 tile-per-side hexagonal layout.

Story Points: 13 Priority: High Risk: High

Task Breakdown

ModestosV commented 6 years ago

Mockup: image

Found: https://www.redblobgames.com/grids/hexagons/

ModestosV commented 6 years ago

IGNORE ALL PREVIOUS COMMITS.

0matleb2 commented 6 years ago

Dev recap from Slack. #28

I've been working heavily in the Sandbox folder on a rewrite of the grid that supports editing the grid and tiles in scene, and easy creation of irregular grids. It's very much the same however I still chose to rewrite to not disturb the original scripts. I've ported the GetNeighbors algorithm so far. This GIF shows how irregular grids are supported. They can be rapidly created by disabling the MeshRenderer on the tiles in a base 19x19 grid. I've attached the Neighbors algo to the mouse selection for testing purposes. I also added multi-select with LEFT_CTRL pressed, may come in handy. 1 2 I created the above irregular grid from this base grid prefab in just a few moments. Also it will support changing out the HexTile mesh as the positions of the tiles are linked to the size of the mesh. As long as new meshes have the shape of a regular hexagon, the layout of the grid should remain consistent.

Pathfinding with BFS ✔️ 3

A* instead of BFS ✔️ . Much faster. 4

To verify and demo how A* searches I slowed down the algorithm and marked every node on the search path. In Unity waiting is not as simple as Thread.Sleep(), so I had to learn how to make the magic happen with Coroutines 😅 5

Multi-select support and selection polishing, 6

0matleb2 commented 6 years ago

Implementation hindering unit testing. Resolved ✔️ image

0matleb2 commented 6 years ago

Character selection and movement on grid ✔️ #2 best

0matleb2 commented 6 years ago

Refactoring GridController to reduce cohesion. image ✔️

image

0matleb2 commented 6 years ago

Prevent movement to unreachable tiles and error hover. ✔️ movementprevented

0matleb2 commented 6 years ago

@ModestosV Unit testing ✔️ image

0matleb2 commented 6 years ago

Character info panel integrated with grid. ✔️ stat_panel

0matleb2 commented 6 years ago

Demo Steps

  1. Launch game and press "Play" to start a match.
  2. View the grid composed of hexagon tiles in the scene.
  3. Hover over tiles in the scene.
  4. Select a tile by left-clicking it and deselect the tile by left-clicking it again.
  5. Select a tile and deselect it by left-clicking off the grid.
  6. Select a tile and change the tile selection by left clicking on another tile.
0matleb2 commented 6 years ago

Acceptance Tests

Test Inputs Expected Output Status
Show Grid Launch game and press "Play". Grid composed of hexagonal tiles is visible. Pass ✔️
Hover Tile Hover mouse over a tile. Tile is hover highlighted. Pass ✔️
Select Tile Left-click on a tile that does not contain a character. Tile is selection highlighted. No character movement. Pass ✔️
Deselect Tile Left-click on the selected tile or off the grid. Tile is not selection highlighted. No character movement. Pass ✔️
Change Tile Selection With an unoccupied tile selected, select another unoccupied tile. Initial selected tile is deselected. New selected tile is selected. Pass ✔️
0matleb2 commented 6 years ago

@ModestosV

We could expand on this test by setting gridWidth to 2 and then verifying the coordinates are correct for all 4 hex tiles in the grid. These 4 tiles will have coordinates that can be expressed as movement along the 3 axes of the hexagonal grid. Asserting all of their coordinates are correct will be a more complete test than asserting the first and only tile in a 1 width grid has origin coordinates.

https://github.com/ModestosV/BlackDice/blob/c4e30dc064a5c0b2e3e151e49e271527ed92c6d4/Online%20Grid%20Arena/Assets/Editor/GridTests/GridControllerTests.cs#L28-L49

0matleb2 commented 6 years ago

@ModestosV For example, have a look at how I have tested getNorthEastNeighbor in GridTraversalController. https://github.com/ModestosV/BlackDice/blob/feature/issue_002_1/Online%20Grid%20Arena/Assets/Editor/GridTests/GridTraversalControllerTests.cs

0matleb2 commented 6 years ago

Second pass on GridController tests. ✔️ image

lambhunter0 commented 5 years ago
Test Inputs Expected Output Status Last Tested
Show Grid Launch game and press "Play". Grid composed of hexagonal tiles is visible. Pass 04/19/2019
Hover Tile Hover mouse over a tile. Tile is hover highlighted. Pass 04/19/2019
Select Tile Left-click on a tile that does not contain a character. Tile is selection highlighted. No character movement. Pass 04/19/2019
Change Tile Selection With an unoccupied tile selected, select another unoccupied tile. Initial selected tile is deselected. New selected tile is selected. Pass 04/19/2019