Exemplo n.º 1
0
    }  //Muda o sentido do movimento e sobe ele uma posição ao colidir com o player

    private void Movement()
    {
        if (tempo < (gameManager.tempoRelativo / 60))
        {
            indiceUpdatePosY += auxPos_Y;

            if (indiceUpdatePosY <= -1)                     //Declara derrota (round ou jogo) se chegar à posição abaixo do player
            {
                player.destroiFogo = true;
                Destroy(player._instAbacCen);
                Destroy(player._instAbacEsq);

                player.erros += 1;
                if (player.erros == 3)
                {
                    fogoRestante = GameObject.FindGameObjectsWithTag("Fogo");
                    foreach (GameObject Fire in fogoRestante)
                    {
                        Destroy(Fire);
                    }

                    Destroy(GameObject.FindGameObjectWithTag("Player"));

                    _uiManager.UpdateMiss(player.erros);
                    gameManager.gameStarted   = false;
                    gameManager.tempoRelativo = 0;
                }
                else if (_uiManager.score >= 300)
                {
                    fogoRestante = GameObject.FindGameObjectsWithTag("Fogo");
                    foreach (GameObject Fire in fogoRestante)
                    {
                        Destroy(Fire);
                    }

                    Destroy(GameObject.FindGameObjectWithTag("Player"));

                    _uiManager.UpdateMiss(player.erros);
                    gameManager.gameStarted   = false;
                    gameManager.tempoRelativo = 0;
                }
                else
                {
                    _uiManager.UpdateMiss(player.erros);

                    player.StartCoroutine(player.restartRound());

                    Debug.Log("Abacaxi Central caiu");
                    tempo = (gameManager.tempoRelativo / 60) + tempoAux;
                }

                Destroy(this.gameObject);
            }


            else if (auxPos_Y == 1 && indiceUpdatePosY == 4)        //Checa se vai subir para 4º posição ou não
            {
                int z = Random.Range(1, 3);
                if (z == 1)      //só vai até a terceira
                {
                    indiceUpdatePosY   = 3;
                    auxPos_Y           = auxPos_Y * -1;
                    transform.position = new Vector3(6.2f, pineapple[indiceUpdatePosY], 0);
                    tempo = (gameManager.tempoRelativo / 60) + tempoAux;
                }
                else           //vai até a quarta
                {
                    indiceUpdatePosY   = 5;
                    transform.position = new Vector3(6.2f, pineapple[indiceUpdatePosY - 1], 0);
                    tempo    = (gameManager.tempoRelativo / 60) + tempoAux;
                    auxPos_Y = auxPos_Y * -1;
                }
            }

            else
            {
                transform.position = new Vector3(6.2f, pineapple[indiceUpdatePosY], 0);
                tempo = (gameManager.tempoRelativo / 60) + tempoAux;
            }
        }
    }
Exemplo n.º 2
0
    private void Movement()
    {
        if (tempo < (gameManager.tempoRelativo / 60))
        {
            indiceUpdatePosY += -1;

            if (indiceUpdatePosY <= -1)                   //Se o fogo estiver abaixo da mão do player
            {
                if (player.transform.position.x > posXFogo - 2 && player.transform.position.x < posXFogo + 2)
                {
                    player.destroiFogo = true;
                    Destroy(player._instAbacCen);         //Destrói todos os abacaxis
                    Destroy(player._instAbacDir);
                    Destroy(player._instAbacEsq);
                    player.erros += 1;

                    if (player.erros == 3)
                    {
                        //Destrói os fogos restantes na cena
                        player.fogoRestante = GameObject.FindGameObjectsWithTag("Fogo");
                        foreach (GameObject Fire in player.fogoRestante)
                        {
                            Destroy(Fire);
                        }

                        //reseta o game, mas ainda mostrando na tela a contagem de erros e escores
                        _uiManager.UpdateMiss(player.erros);
                        gameManager.gameStarted   = false;
                        gameManager.tempoRelativo = 0;
                        Destroy(GameObject.FindGameObjectWithTag("Player"));
                    }
                    //caso o player erre (entrou nesse if) e tenha mais de 300 pontos, perde o jogo
                    else if (_uiManager.score >= 300)
                    {
                        player.fogoRestante = GameObject.FindGameObjectsWithTag("Fogo");
                        foreach (GameObject Fire in player.fogoRestante)
                        {
                            Destroy(Fire);
                        }

                        //reseta o game, mas ainda mostrando na tela a contagem de erros e escores
                        _uiManager.UpdateMiss(player.erros);
                        gameManager.gameStarted   = false;
                        gameManager.tempoRelativo = 0;
                        Destroy(GameObject.FindGameObjectWithTag("Player"));
                    }
                    else
                    {
                        //reinicia o round e atualiza o número de erros na tela
                        player.StartCoroutine(player.restartRound());
                        _uiManager.UpdateMiss(player.erros);
                    }
                }
                transform.position = new Vector3(posXFogo, -1, 0);
                tempo = (gameManager.tempoRelativo / 60) + tempoAux;
                Destroy(this.gameObject);
            }

            else
            {
                transform.position = new Vector3(posXFogo, fogo[indiceUpdatePosY], 0);
                tempo = (gameManager.tempoRelativo / 60) + tempoAux;
            }
        }
    }