You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
10 Hrs
6 Min
20 Seg

Contar los movimientos restantes y la puntuaci贸n

23/31
Resources

We must count the player's moves, show his remaining attempts and add points each time he collects groups of matching candies.

We must import the UnityEngine.UI library to connect our GUIManager script with the application interface and update it whenever necessary. In this case we must update the texts we add in the class every time the user makes a move or manages to remove a group of candies.

Contributions 3

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

Las variables auto-computadas nos permiten encapsular la informaci贸n del valor que debe tomar una variable junto con alg煤n m茅todo que se va a ejecutar autom谩ticamente.

Nuestro c贸digo con el ejercicio de convertir el GUIManager en singleton



using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GUIManager : MonoBehaviour
{

    public static GUIManager sharedInstance;
    public Text scoreText, movesText;
    private int score, moves;
    public int Score
    {
        get {return score;}
        set
        {
            score = value;
            scoreText.text = "Score: " + score;
        }
    }
    public int Moves
    {
        get { return moves; }
        set
        {
            moves = value;
            movesText.text = "Moves: " + moves;
        }
    }

    private void Awake()
    {
        if (sharedInstance == null)
        {
            sharedInstance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }
    }

    void Start()
    {
        Score = 0;
        Moves = 30;
    }
}


Genial