@@ -4,25 +4,6 @@ A cross-platform library that makes it easy to create your own Match 3 game.
4
4
5
5
![ TerminalAndUnityImplementationMac] ( https://user-images.githubusercontent.com/28132516/164034219-561688ef-c5ed-41f8-b30e-8e66c4eb2dfb.png )
6
6
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
-
26
7
## :open_book : Table of Contents
27
8
28
9
- [ About] ( #pencil-about )
@@ -33,6 +14,7 @@ https://user-images.githubusercontent.com/28132516/164049550-467590dc-bbf8-4109-
33
14
- [ Create fill strategy] ( #create-fill-strategy )
34
15
- [ Create level goal] ( #create-level-goal )
35
16
- [ Create sequence detector] ( #create-sequence-detector )
17
+ - [ Create special block] ( #create-special-block )
36
18
- [ ToDo] ( #dart-todo )
37
19
- [ Contributing] ( #bookmark_tabs-contributing )
38
20
- [ Report a bug] ( #report-a-bug )
@@ -42,7 +24,11 @@ https://user-images.githubusercontent.com/28132516/164049550-467590dc-bbf8-4109-
42
24
43
25
## :pencil : About
44
26
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.
46
32
47
33
<table >
48
34
<tr >
@@ -65,61 +51,38 @@ A Match 3 game template with three implementations to fill the playing field. Us
65
51
66
52
> ** Note:** The ` FallDownFillStrategy ` & ` SlideDownFillStrategy ` are given as an example. Consider to implement an object pooling technique for the ` ItemMoveData ` to reduce memory pressure.
67
53
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
+
68
72
## :cactus : Folder Structure
69
73
70
74
.
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
91
78
│
92
- ├── Prefabs
93
- │ ├── ItemPrefab.prefab
94
- │ └── TilePrefab.prefab
79
+ ├── src
80
+ │ ├── Match3.App
81
+ │ ├── Match3.Core
82
+ │ ├── Match3.Template
83
+ │ └── Match3.UnityPackage
95
84
│
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
123
86
124
87
## :rocket : How To Use
125
88
@@ -519,11 +482,143 @@ public class AppContext : MonoBehaviour, IAppContext
519
482
}
520
483
```
521
484
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
+
522
616
## :dart : ToDo
523
617
524
618
Here are some features which are either under way or planned:
525
619
526
620
- [ ] Add tests
621
+ - [x] Add special block support
527
622
- [ ] Build .unitypackage
528
623
- [ ] Publish on Asset Store
529
624
- [ ] Optimize ` ItemsDrop ` & ` ItemsRollDown ` fill strategies
0 commit comments