Candy Crush style lives. Giving plays value.

Flappy bird was infamous for it's difficulty, but it's learning curve was actually quite shallow. A player might die 10 times in the first minute, but very quickly they would get a feel for the game, start being able to guide the bird through a few pipes, and after quarter of an hour be able to set a score in the double digit.

This was because dying in Flappy Bird had no cost. There was no punishment for loosing control and sending the character careering into a neon green pipe. For this reason I wanted to have some sort of lives system in Catchee Monkey, to force the player to play conservatively and to consider there next moves. It would also give me an opportunity to monetise the game with micro-transactions for the keener players.

I began by trying to code the functionality myself. I knew it would have something to do with the unity OnApplicationPause monobehaviour. I would also need some way to count down between lives.

It quickly became apparent that this was completely beyond me. For such a crucial piece of coding, I needed to make sure it was done properly. So, for the first time in this project, I visited the Unity Asset Store. 

Time-Based Life System by ExaGames was my choice. It was cheap, came with a five-star ratings and, most importantly, the reviews said that it was incredibly easy to use... and it was.

The API and the existing files are well documented and commented. If your looking to do a life system such as this one, I'd highly recommend it.

I initially thought I would have the classic Candy Crush style Life system. With a Number indicating how many lives remained, and a timer showing how long remained until a life "regenerated". However I decided I didn't want all this information cluttering the screen.

First off, I decided against a number of lives and decided to simply show all five of my lives on the screen. Represented of course, by bananas. I found an image of a banana on the internet with a public commons license. I then copied it five times and put them in a list. For every life lost, one banana would disappear.  

I kept the timer around for a while until I thought about it: In Candy Crush Saga, a game with a similar mechanic, the only time I wanted to know the exact seconds until I had a life back was when I had lost them all. So showing a timer when there are still lives left ( like the situation above) seemed pointless. 

I decided to put the timer on a "NO LIVES" screen, displayed when the player tries to continue playing whilst they have no lives. For the rest of the time, the regeneration time is represented by an un-interactable slider. The slider fills up as the time to life regeneration gets closer. The slider, disappears when the lives are full. The final mechanic looks like this.

Screen Shot 2017-07-04 at 23.03.39.png

To be able to fully understand how I did all this, you really need the asset. However I've included my script which interacts with that asset here if anyone likes how I've personalised.

public class livesSystem : MonoBehaviour {

    public LivesManager livesManager;
    public List<GameObject> lives;
    int livesNum;
    public Text TimeToNextLifeText;
    public Slider time;

    bool hold;

    void Start () {
        bool hold = true;
    void Update () {

        if (livesManager.HasInfiniteLives) {
            //color gold
        } else {
        //color red
        if (livesManager.HasMaxLives) {
            time.gameObject.SetActive (false);
            hold = true;
        } else {
            if (hold) {
                time.gameObject.SetActive (true);
                hold = false;
            float num = Mathf.InverseLerp (1, 1800, (float)livesManager.SecondsToNextLife);
            time.value = 1 - num;

    public void OnLivesChanged() {
        livesNum = livesManager.Lives;
        foreach (GameObject life in lives) {
            life.SetActive (false);

        for (int i = 0; i < livesNum; i++) {
            lives [i].SetActive (true);

    public void OnTimeToNextLifeChanged() {
        TimeToNextLifeText.text = livesManager.RemainingTimeString;

So just a short update today. I'm quite busy over the next few days, but hopefully I should have a chance to better integrate this functionality with the game. Then I can start working on the shop!

As usual, If you like anything you've read, share it with friends or anyone else who might find it interesting.