Ejemplo n.º 1
0
    //==========================================================================================================//
    /// <summary>
    /// Cria os alvos a serem acertados pelo jogador.
    /// </summary>
    /// <param name="baseAlvo"> A GameObject de referência para criação dos alvos. </param>
    //==========================================================================================================//
    public static void CriarAlvo(GameObject baseAlvo)
    {
        Color      novaCor;
        GameObject novoAlvo;
        Material   material;

        if (instance.GetTamanhoListaAlvos() < instance.CSV_GetMaximoAlvos() & instance.GetQuantidadeAlvos() < instance.CSV_GetMaximoAlvos())
        {
            for (int i = 0; i < instance.CSV_GetMaximoAlvos(); i++)
            {
                if (instance.GetTamanhoListaAlvos() < instance.CSV_GetMaximoAlvos() & instance.GetQuantidadeAlvos() < instance.CSV_GetMaximoAlvos())
                {
                    novaCor  = new Vector4(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);
                    novoAlvo = Instantiate(baseAlvo) as GameObject;
                    novoAlvo.transform.position   = new Vector2(UnityEngine.Random.Range(-7, 7), UnityEngine.Random.Range(-3, 3));
                    novoAlvo.transform.localScale = new Vector3(instance.CSV_GetTamanhoAlvos(), instance.CSV_GetTamanhoAlvos(), 0.001f);
                    material       = novoAlvo.GetComponent <Renderer>().material;
                    material.color = novaCor;
                    instance.AddAlvo(novoAlvo);
                }
            }
        }
    }
Ejemplo n.º 2
0
 //============================================================================================================
  /// <summary>
  /// A cada novo frame a função de criação dos alvos é chamada para garantir que a quantidade de alvos na tela
  /// seja a mesma informada no arquivo CSV e as variáveis de informação são atualizadas.
  /// </summary>
 //============================================================================================================
 void Update() {
     if(game == true) {
         CriarAlvos();
         Distracao.CriarDistracao(baseDistracao);
         quantAlvos = instance.GetQuantidadeAlvos();
         tamListaAlvos = instance.GetTamanhoListaAlvos();
         timer += Time.deltaTime;
         if(timer > 1) {
             tempoGame--;
             timer = 0;
         }
         if(tempoGame <= 0) {
             EndGame();
         }
     }
 }