コード例 #1
0
    /*
     * IEnumerator SpawnWaves(){
     *      Vector3 posicaospawn;
     *      float tempo_passado = 0.0f;
     *      while (tempo_passado< 15) {
     *              tempo_passado+=Time.deltaTime;
     *              //Debug.Log (tempo_passado);
     *              posicaospawn = new Vector3 (Random.Range (-1.5f, 1.5f), 0, 12);
     *              //Instantiate (meteoroComum, posicaospawn, Quaternion.identity);
     *              pollMeteoros_comuns.AtivarGameObject(posicaospawn);
     *              yield return new WaitForSeconds(1);tempo_passado+=1;
     *
     *
     *
     *
     *
     *      }
     *      yield return 0;
     *
     * }*/


    IEnumerator WaveGenerator(float duracao, float intervalo, int TiposMeteoro, int excluido, int diferencial)
    {
        Vector3 posicaospawn;
        float   tempo_passado = 0.0f;

        while (tempo_passado < duracao)
        {
            tempo_passado += Time.deltaTime;
            posicaospawn   = new Vector3(Random.Range(-1.5f, 1.5f), 0, 12);



            int atual = Random.Range(1, TiposMeteoro + 1);
            if (atual != excluido)
            {
                if (atual == 1)
                {
                    pollMeteoros_comuns.AtivarGameObject(posicaospawn);
                    yield return(new WaitForSeconds(intervalo)); tempo_passado += intervalo;
                }

                if (atual == 2)
                {
                    pollMeteoros_explosivo.AtivarGameObject(posicaospawn);
                    yield return(new WaitForSeconds(intervalo)); tempo_passado += intervalo;
                }

                if (atual == 3)
                {
                    pollMeteoros_hard.AtivarGameObject(posicaospawn);
                    yield return(new WaitForSeconds(intervalo)); tempo_passado += intervalo;
                }

                if (atual == 4)
                {
                    //Separante.
                }
                if (atual == 5)
                {
                    pollMeteoros_aceleradores.AtivarGameObject(posicaospawn);
                    yield return(new WaitForSeconds(intervalo)); tempo_passado += intervalo;
                }


                if (atual == 6)
                {
                    pollMeteoros_indestruct.AtivarGameObject(posicaospawn);
                    yield return(new WaitForSeconds(intervalo)); tempo_passado += intervalo;
                }
            }
        }

        yield return(0);
    }
コード例 #2
0
    public void Atirar()
    {
        if ((Time.time > nextFire) && (balas > 0))
        {
            balas--;
            AttNumeroBala();
            nextFire = Time.time + fireRate;
            pollTiros.AtivarGameObject(new Vector3(spawnTiro.position.x, 0.0f));

            audioTiro.Play();
        }
    }