← Back to projects

Match puzzle · Unity 6

Element Crash

A Royal Match–style match puzzle built in Unity 6 (6000.3) and C#, with ten JSON-driven levels, a move limit, and obstacle goals.

Overview

The player taps connected groups of same-colored cubes and clears them within a move limit. Clearing every obstacle on the level wins. Running out of moves opens a fail popup with retry.

Progress is saved between sessions, and the main menu resumes the current level.

Specials

Group size decides what the match becomes. Adjacent specials combine into larger explosions that can chain.

  • Group of 4–5

    Becomes a rocket that sweeps a row or a column.

  • Group of 6+

    Becomes TNT that clears a square.

  • Adjacent specials

    Combine into a larger explosion that can chain.

Obstacles

  • Stone

    Breaks only when hit by a special.

  • Vase

    Falls with the board and has two hit points.

  • Chalice box

    A 2×2 box that opens, then the chalices inside are collected.

Architecture

Simulation stays separate from presentation. GridModel, Cell, and a polymorphic GridItem hierarchy (CubeItem, RocketItem, TntItem, and the obstacle types) hold the board as plain C# objects.

GroupFinder flood-fills matches with a queue and a hash set. FallController resolves gravity and spawns. LevelGoalTracker checks the win conditions.

GameplayController runs each turn as a coroutine so blasts, combos, falls, and the end state play in order. GridView and ItemVisual only render sprites and motion.

Levels are TextAsset JSON files parsed with JsonUtility into a typed grid. Art and level references live on a ScriptableObject loaded from Resources. The level scene, canvas, and HUD are built at runtime by a bootstrap instead of hand-placed prefabs.

Unity

Orthographic 2D rendering uses SpriteRenderer. The HUD, fail popup, and celebration are uGUI (Canvas, CanvasScaler, Image, Text). Board taps and UI use the new Input System. SceneManager handles the menu and level flow. PlayerPrefs stores the last unlocked level. Editor scripting (MenuItem, AssetDatabase, and a small EditorWindow) assembles scenes and assets.

C#

The rules stay in the model and the view stays thin: abstract classes and virtual methods, switch expressions and pattern matching, generic obstacle counts, IEquatable structs for grid positions, value types for damage, and expression-bodied members.

Technologies

Unity 6 (6000.3) C# SpriteRenderer uGUI Input System JsonUtility ScriptableObjects PlayerPrefs Editor scripting

Features