Exemple #1
0
 private void updateScore()
 {
     // atualiza score no canvas
     // chamar essa função sempre que haja mudança na pontuação
     if (pairs == 3)
     {
         // VENCEU
         // aqui todos os pares foram formados
         // jogador vence e ganha uma vida, uma nova partida deverá iniciar
         score += lives; // vidas remanescentes tornam-se pontos
         lives += 1;     // ganha um ponto ganho pela rodada
         updateAlertTestCanvas(true, "You Win");
         GameManager.Instance.Sound.playWin();
         showCards(); // revela a carta curinga
         lockClick();
         Invoke("resetDeck", 2);
         testCanvas.transform.Find("Scores/Points").GetComponent <Text>().text = score.ToString();
     }
     if (testCanvas != null && testCanvas.activeInHierarchy)   // atualiza VIDAS no canvas de teste
     {
         testCanvas.transform.Find("Scores/Lives").GetComponent <Text>().text = lives.ToString();
     }
     if (hud != null && hud.isActiveAndEnabled)
     {
         // se o HUD estiver presente
         // atualiza pontuação e vidas
         hud.updateLives(lives);
         hud.updateScore(score);
     }
 }