Exemplo n.º 1
0
    /// <summary>
    /// Sets up board according to rules
    /// </summary>
    /// <param name="rules"></param>
    public void InitBoard(LevelRules rules)
    {
        grid = GetComponent <Grid>();
        grid.BuildBoard();

        tilePot = GetComponent <TilePot>();
        tilePot.ConfigurePot(rules);

        SpawnFreshBoard();
    }
Exemplo n.º 2
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
    public void StartLevel(LevelRules rules)
    {
        if (rules.Index - 1 > levelIndex)
        {
            return;
        }

        GameManager.Instance.Configure(rules);

        HideLevelSelect();
    }
Exemplo n.º 4
0
    public void Configure(LevelRules rules)
    {
        if (!rules || !rules.GameBoard)
        {
            throw new Exception("Invalid ruleset / game board!");
        }

        this.rules = rules;

        InitNewData();
        InitGameBoard();

        AudioManager.Instance.PlayAudio(Sound.LevelIntro);
    }
Exemplo n.º 5
0
    private void SpawnLevelCards()
    {
        for (int i = 0; i < levelRules.Length; i++)
        {
            Button card = Instantiate(cardPrefab, cardHolder);
            cards.Add(card);

            LevelRules rules = levelRules[i];

            cards[i].onClick.AddListener(() =>
            {
                StartLevel(rules);
            });

            cards[i].GetComponentInChildren <TextMeshProUGUI>().text = rules.Index.ToString();
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Sets up a tile pot according to current level settings.
 /// </summary>
 /// <param name="rules"></param>
 public void ConfigurePot(LevelRules rules)
 {
     this.rules = rules;
     RegenerateDistribution();
 }