Advertisement
gizoncio

Breakout aula 17 - gameManager.cs

Aug 22nd, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. //////////////////////////////////////////////
  2. // Créditos Équilibré Cursos e Treinamentos //
  3. // http://www.equilibrecursos.net           //
  4. // http://www.youtube.com/equilibrecursos   //
  5. //////////////////////////////////////////////
  6.  
  7. using UnityEngine;
  8. using UnityEngine.UI;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11.  
  12. public class gameManager : MonoBehaviour {
  13.  
  14.     public SpriteRenderer renderBolinha;
  15.  
  16.     private player scriptPlayer;
  17.  
  18.     public Sprite[] sprBolinha;
  19.  
  20.     public Text ScoreText;
  21.     public Slider vidasSlider;
  22.  
  23.     public int pontuacao;
  24.  
  25.     public int vidas;
  26.  
  27.     // Use this for initialization
  28.     void Start () {
  29.         vidas = 3;
  30.         pontuacao = 0;
  31.         scriptPlayer = GameObject.Find("player").GetComponent<player>();
  32.         renderBolinha = GameObject.Find("ball").GetComponent<SpriteRenderer>();
  33.     }
  34.    
  35.     // Update is called once per frame
  36.     void Update () {
  37.  
  38.  
  39.         ScoreText.text = pontuacao.ToString();
  40.         vidasSlider.value = vidas;
  41.  
  42.         if (vidas > 0)
  43.         {
  44.             if (scriptPlayer.podeAtirar && !scriptPlayer.ativaExplosao)
  45.                 renderBolinha.sprite = sprBolinha[1];
  46.             else if (!scriptPlayer.podeAtirar && scriptPlayer.ativaExplosao)
  47.                 renderBolinha.sprite = sprBolinha[2];
  48.             else
  49.                 renderBolinha.sprite = sprBolinha[0];
  50.  
  51.             if (scriptPlayer.podeAtirar && scriptPlayer.ativaExplosao)
  52.                 renderBolinha.color = Color.yellow;
  53.             else
  54.                 renderBolinha.color = Color.white;
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement