Sagui Itay - Unity Assets, software development and mobile games

Pop Blocks Game template and engine Unity Asset

Popup Blocks Unity Asset Card

Overview

Pop Blocks Game template and engine is a full Unity template that gives you a quick and easy way to create Pop Blocks puzzle games.

Features

  • All source code included (C#)
  • Mobile friendly
  • Basic UI setup
  • Multiple block types:
    • Simple
    • Multi-lives
    • Static (unbreakable)
  • Different game modes:
    • Timed
    • Endless
    • Fill new blocks on pop
    • Alignment (Coming soon)
    • Different blocks per level
  • Various winning conditions:
    • Clearing the whole board
    • Reach a certain score
    • Reach score for “stars”
    • Remove certain number of blocks (Coming soon)
    • Remove certain number of specific block types (Coming soon)

Purchase the Pop blocks Game template and engine from the Unity Assets Store here >>

Screenshots

Documentation

Code base

The code base of is generally divided into two parts – the engine, and the UI.

The following classes represent the engine part:

  • Block: represents a single block within the level
  • BlockType: represents a “template” of a block
  • BlockColor: enum representing the color of a block
  • Map: represents a level
  • LevelMode: represents the settings of a level (such as winning conditions and blocks fill-in)

In addition, the engine contains a few helper types:

  • BlockChange: represents a change in the map following a user action
  • BlockChangeType: enum representing the change type

The following classes represent the UI part:

  • BlockScript: represents a block in the UI
  • MapScript represent the level’s map in the UI

In addition, the UI contains a few helper types:

  • LevelCompletedScript: manages the LevelCompleted panel
  • TimerScript: manages the timer object
  • ScoreScript: manages the score object
  • ScorePopupScript: manages score popups
  • QuitOnBackScript: manages “back” button clicks

The Map, along with a LevelMode, represent a level, which consists of multiple Block objects. These can be used without any UI. The BlockScript and MapScript are responsible for the display of the game, and the user interaction.

Creating a new level mode

The template comes with 11 sample levels, showing the different capabilities of the engine. When creating a new LevelMode, developers can decide on the various capabilities to enable and configure. The following are supported:

  • Rows/Columns: these control the size of the board
  • RandomSeed: this allows developers to decide on a consistent “randomness”, instead of using a true random behavior.
  • Timed mode:
    • IsTimed: Control whether the level timed, or endlessStartingTime: The amount of time players starts withGrantTimeOnScore: Should more time be granted to players based on their score:
      • GrantTime: How much time to grantRequiredScoreFirstTimeGrant: What’s the initial score needed to time to be grantedTimeGrantIncreaseMode: How to increase the score needed (add/multiply)RequiredScoreIncreaseTimeGrant: By how much the required score is increased on every grant
      Fill In:
      • FillInOnPop: Should blocks appear as blocks are destroyed?
      Alignment:
      • AlignLeft: Should blocks slide left as columns are cleared?
      Blocks:
      • BlockTypes: List of block types that should be used in the level
    • Winning conditions:
      • ClearBoard: Does winning require clearing the whole board?
      • ReachScore: Does winning require reaching a certain score?
        • RequiredScoreStar1: What score is required for getting 1 star?RequiredScoreStar2: What score is required for getting 2 stars?
        • RequiredScoreStar3: What score is required for getting 3 stars?

To create a new level, create a new Level Mode object (available via Create -> Pop Block -> Level Mode), and set the various settings of the level. In addition, assign the various Block Types that will be randomly used in the level. Lastly, select the different winning conditions.

Here’s an example of an endless level, which continues to fill-in as blocks are destroyed:

Pop-Blocks-Game-template-and-engine-Settings

Once ready, you can use the Level Mode by assigning it to an object assigned with the MapScript component.

Create a new block type

To add a new block type, create a new BlockType object (available via Create -> Pop Block -> Block Type). Once created, set the Color of the block type – blocks of the same colors will be destroyed together. Set the lives of the block, which controls how many times a block must be hit before its destroyed. To match the lives, set the list of sprites to be used – each sprite matches the block’s remaining lives. Lastly, select whether the block is static or not.

Here is an example of a 2-lives purple block:

Pop-Blocks-Game-template-and-engine-Block

Customizing a block’s behavior

By default, blocks come with 2 behaviors:

  • Normal, which means that the block can be destroyed
  • Static, which means that the block cannot be destroyed

To add a new behavior, follow these steps:

  1. Add a new value to the BlockBehavior enum. For example, “Explodable”
  2. Decide how to handle the “block hit” event and implement that behavior in the Block.Hit() method. For example, if the block’s lives reached zero, hit all adjacent blocks in the map.

Frequently Asked Questions

Can the minimum number of blocked required for destruction be changed?

Yes. Change the value of the MINIMUM_REQUIRED_BLOCKS const to whatever minimum you desire.

Can I change the way the score is calculated?

Yes. The default scoring method, which is MapScript.GetScore() uses a simple (N*(N+1)/2) formula, where N is the number of hit blocks. You can change it to be anything you want.

What other features are planned for the asset?

The following features are in the works:
1. Alignment of blocks to all directions (currently only down and left is supported)
2. Additional Winning Conditions:
2.a. Granting stars based on remaining time
2.b. Clearing a specific number of blocks
2.c. Clearing a specific number of blocks of certain types
3. More blocks behaviors:
3.a. Explosion
3.b. Row/Column explosion

Subscribe now

and receive the latest updates and news.