Skip to content

Commit 7f453f0

Browse files
authored
Updated readme file.
1 parent 0796d49 commit 7f453f0

File tree

1 file changed

+165
-70
lines changed

1 file changed

+165
-70
lines changed

README.md

Lines changed: 165 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@ A cross-platform library that makes it easy to create your own Match 3 game.
44

55
![TerminalAndUnityImplementationMac](https://user-images.githubusercontent.com/28132516/164034219-561688ef-c5ed-41f8-b30e-8e66c4eb2dfb.png)
66

7-
## Unity Sample
8-
9-
<details><summary><b>Gameplay Demonstration</b></summary>
10-
<br />
11-
12-
<!-- https://user-images.githubusercontent.com/28132516/160339166-0efb4537-50db-469c-adb1-3bdcd0ee3d8a.mp4 -->
13-
https://user-images.githubusercontent.com/28132516/164045071-e2038177-1bc2-475c-8dbc-4b4f77d6895b.mp4
14-
15-
</details>
16-
17-
## Terminal Sample
18-
19-
<details><summary><b>Gameplay Demonstration</b></summary>
20-
<br />
21-
22-
https://user-images.githubusercontent.com/28132516/164049550-467590dc-bbf8-4109-a1bb-38dfe6674cd6.mp4
23-
24-
</details>
25-
267
## :open_book: Table of Contents
278

289
- [About](#pencil-about)
@@ -33,6 +14,7 @@ https://user-images.githubusercontent.com/28132516/164049550-467590dc-bbf8-4109-
3314
- [Create fill strategy](#create-fill-strategy)
3415
- [Create level goal](#create-level-goal)
3516
- [Create sequence detector](#create-sequence-detector)
17+
- [Create special block](#create-special-block)
3618
- [ToDo](#dart-todo)
3719
- [Contributing](#bookmark_tabs-contributing)
3820
- [Report a bug](#report-a-bug)
@@ -42,7 +24,11 @@ https://user-images.githubusercontent.com/28132516/164049550-467590dc-bbf8-4109-
4224

4325
## :pencil: About
4426

45-
A Match 3 game template with three implementations to fill the playing field. Use this project as a starting point for creating your own Match 3 game.
27+
The **Match 3 SDK** is designed to speed up the development of Match 3 games. Use the samples as a starting point for creating your own Match 3 game.
28+
29+
### Unity Sample
30+
31+
A Match 3 game sample with three implementations to fill the playing field.
4632

4733
<table>
4834
<tr>
@@ -65,61 +51,38 @@ A Match 3 game template with three implementations to fill the playing field. Us
6551

6652
> **Note:** The `FallDownFillStrategy` & `SlideDownFillStrategy` are given as an example. Consider to implement an object pooling technique for the `ItemMoveData` to reduce memory pressure.
6753
54+
<details><summary><b>Gameplay Demonstration</b></summary>
55+
<br />
56+
57+
https://user-images.githubusercontent.com/28132516/164045071-e2038177-1bc2-475c-8dbc-4b4f77d6895b.mp4
58+
59+
</details>
60+
61+
### Terminal Sample
62+
63+
A Match 3 game sample designed for text terminals.
64+
65+
<details><summary><b>Gameplay Demonstration</b></summary>
66+
<br />
67+
68+
https://user-images.githubusercontent.com/28132516/164049550-467590dc-bbf8-4109-a1bb-38dfe6674cd6.mp4
69+
70+
</details>
71+
6872
## :cactus: Folder Structure
6973

7074
.
71-
├── Art
72-
│ ├── Icons
73-
│ │ ├── Food
74-
│ │ └── Sweets
75-
│ ├── Sprites
76-
│ └── Textures
77-
78-
├── Plugins
79-
│ └── Match3
80-
│ ├── App
81-
│ │ ├── Internal
82-
│ │ │ ├── ...
83-
│ │ │ ├── GameBoard.cs
84-
│ │ │ └── JobsExecutor.cs
85-
│ │ ├── ...
86-
│ │ ├── GameConfig.cs
87-
│ │ ├── Job.cs
88-
│ │ ├── LevelGoal.cs
89-
│ │ └── Match3Game.cs
90-
│ └── Core
75+
├── samples
76+
│ ├── Terminal.Match3
77+
│ └── Unity.Match3
9178
92-
├── Prefabs
93-
│ ├── ItemPrefab.prefab
94-
│ └── TilePrefab.prefab
79+
├── src
80+
│ ├── Match3.App
81+
│ ├── Match3.Core
82+
│ ├── Match3.Template
83+
│ └── Match3.UnityPackage
9584
96-
├── Scenes
97-
│ └── MainScene.unity
98-
99-
├── Scripts
100-
│ ├── Common
101-
│ │ ├── AppModes
102-
│ │ │ ├── DrawGameBoardMode.cs
103-
│ │ │ ├── GameInitMode.cs
104-
│ │ │ ├── GamePlayMode.cs
105-
│ │ │ └── GameResetMode.cs
106-
│ │ ├── LevelGoals
107-
│ │ ├── SequenceDetectors
108-
│ │ ├── ...
109-
│ │ ├── GameBoardRenderer.cs
110-
│ │ ├── GameBoardSolver.cs
111-
│ │ ├── ItemGenerator.cs
112-
│ │ ├── LevelGoalsProvider.cs
113-
│ │ └── UnityItem.cs
114-
│ ├── FillStrategies
115-
│ │ ├── Jobs
116-
│ │ ├── Models
117-
│ │ ├── FallDownFillStrategy.cs
118-
│ │ ├── SimpleFillStrategy.cs
119-
│ │ └── SlideDownFillStrategy.cs
120-
│ ├── App.cs
121-
│ ├── AppContext.cs
122-
│ └── Game.cs
85+
├── Match3.sln
12386

12487
## :rocket: How To Use
12588

@@ -519,11 +482,143 @@ public class AppContext : MonoBehaviour, IAppContext
519482
}
520483
```
521484

485+
### Create special block
486+
487+
Let's create a stone block that is only destroyed when a match happens in one of the neighbour tiles.
488+
489+
Add a `Stone` value to the `TileGroup` enum.
490+
491+
```csharp
492+
public enum TileGroup
493+
{
494+
Unavailable = 0,
495+
Available = 1,
496+
Ice = 2,
497+
Stone = 3
498+
}
499+
```
500+
501+
Create a class `StoneState` and inherit from the `StatefulGridTile`.
502+
503+
```csharp
504+
public class StoneState : StatefulGridTile
505+
{
506+
private bool _isLocked = true;
507+
private bool _canContainItem;
508+
509+
// Prevents the block from move.
510+
public override bool IsLocked => _isLocked;
511+
512+
// Prevents the item creation.
513+
public override bool CanContainItem => _canContainItem;
514+
515+
// Defines the tile group.
516+
public override TileGroup Group => TileGroup.Stone;
517+
518+
// Occurs when all block states have completed.
519+
protected override void OnComplete()
520+
{
521+
_isLocked = false;
522+
_canContainItem = true;
523+
}
524+
525+
// Occurs when the block state is reset.
526+
protected override void OnReset()
527+
{
528+
_isLocked = true;
529+
_canContainItem = false;
530+
}
531+
}
532+
```
533+
534+
To respond to any changes in one of the neighbour tiles, we have to implement an `ITileDetector` interface. Create a `StoneTileDetector` class and inherit from the `ITileDetector`.
535+
536+
```csharp
537+
public class StoneTileDetector : ITileDetector
538+
{
539+
private readonly GridPosition[] _lookupDirections;
540+
private readonly IUnityGameBoardRenderer _gameBoardRenderer;
541+
542+
public StoneTileDetector(IUnityGameBoardRenderer gameBoardRenderer)
543+
{
544+
_gameBoardRenderer = gameBoardRenderer;
545+
_lookupDirections = new[]
546+
{
547+
GridPosition.Up,
548+
GridPosition.Down,
549+
GridPosition.Left,
550+
GridPosition.Right
551+
};
552+
}
553+
554+
public void CheckGridSlot(IUnityGridSlot gridSlot)
555+
{
556+
foreach (var lookupDirection in _lookupDirections)
557+
{
558+
var position = gridSlot.GridPosition + lookupDirection;
559+
560+
if (_gameBoardRenderer.IsPositionOnGrid(position) &&
561+
_gameBoardRenderer.GetTileGroup(position) == TileGroup.Stone)
562+
{
563+
_gameBoardRenderer.TrySetNextTileState(position);
564+
}
565+
}
566+
}
567+
}
568+
```
569+
570+
Once the `StoneTileDetector` is implemented, add it to the list of tile detectors in the `TileGroupDetector` class.
571+
572+
```csharp
573+
public class TileGroupDetector : ISolvedSequencesConsumer<IUnityGridSlot>
574+
{
575+
...
576+
577+
public TileGroupDetector(IUnityGameBoardRenderer gameBoardRenderer)
578+
{
579+
_tileDetectors = new ITileDetector[]
580+
{
581+
...
582+
new StoneTileDetector(gameBoardRenderer)
583+
};
584+
}
585+
586+
...
587+
}
588+
```
589+
590+
Next, move on to setting up the scene and prefabs.
591+
592+
First of all, add a block state sprites to the `TilesSpriteAtlas` and create a `StoneTilePrefab` prefab varian from the `StatefulBlankPrefab`.
593+
594+
<details><summary>Prefab Variant Creation</summary>
595+
<br />
596+
597+
![CreatePrefabVariant](https://user-images.githubusercontent.com/28132516/164171867-3f8b90bf-98d0-482f-bd9e-8d5209932398.png)
598+
599+
</details>
600+
601+
Configure the `StoneTilePrefab` by adding the `StoneState` script to it and filling in a `State Sprite Names` list.
602+
603+
![ConfigureStoneTilePrefab](https://user-images.githubusercontent.com/28132516/164176865-91287ec1-abf5-4c9b-989f-4ee52b2c2630.png)
604+
605+
> **Note:** You can create more than one visual state for a block by adding more state sprites.
606+
607+
Finally, select a `GameBoard` object in the scene and add the `StoneTilePrefab` to a `GridTiles` list of the `UnityGameBoardRenderer` script.
608+
609+
<details><summary>Video Demonstration</summary>
610+
<br />
611+
612+
https://user-images.githubusercontent.com/28132516/164196506-80ebe446-7a7a-4ae6-930c-46586f1b2c25.mp4
613+
614+
</details>
615+
522616
## :dart: ToDo
523617

524618
Here are some features which are either under way or planned:
525619

526620
- [ ] Add tests
621+
- [x] Add special block support
527622
- [ ] Build .unitypackage
528623
- [ ] Publish on Asset Store
529624
- [ ] Optimize `ItemsDrop` & `ItemsRollDown` fill strategies

0 commit comments

Comments
 (0)