Example #1
0
 public void PrepareGame()
 {
     Time.timeScale = 1;
     for (int i = 0; i <= hazards.Length - 1; i++)
     {
         GameObject hazard = hazards[i];
         mover                  = hazard.GetComponent <Mover>();
         mover.speed            = 600;
         mover.rotateToPlayer   = false;
         enemyInCircle          = hazard.GetComponent <EnemyInCircle>();
         enemyInCircle.enabled  = false;
         enemyInCircle.onPlayer = false;
     }
 }
Example #2
0
    IEnumerator BossFight()
    {
        //playerController.destroy = true;
        //Destroy(platforma);
        //ChangeButtons();
        Vector3    spawnPositionBoss = new Vector3(0f, spawnPositiony, 0f);
        GameObject bossObject        = Instantiate(boss, spawnPositionBoss, Quaternion.identity) as GameObject;
        BossHp     bossHp            = bossObject.GetComponent <BossHp>();
        Quaternion spawnRotation     = Quaternion.Euler(180, 180, 180);

        yield return(new WaitForSeconds(levelWait * 3));

        do
        {
            CheckGameOver();
            if (bossHp.hpBoss <= 120 && bossHp.hpBoss > 90)
            {
                for (int i = 0; i < 5; i++)
                {
                    spawnPositionBoss = bossObject.transform.position;
                    int        type   = UnityEngine.Random.Range(0, hazards.Length - 1);
                    GameObject hazard = hazards[type];
                    enemyInCircle         = hazard.GetComponent <EnemyInCircle>();
                    enemyInCircle.enabled = true;
                    Instantiate(hazard, spawnPositionBoss, spawnRotation);
                    yield return(new WaitForSeconds(0.3f));
                }
                bossHp.ChangeImage();
                bossHp.moved = false;
                while (!bossHp.moved)
                {
                    yield return(new WaitForSeconds(0.0000001f));
                }
                if (gameOver)
                {
                    UpdateScore(count);
                }
                yield return(new WaitForSeconds(waveWait));
            }
            else if (bossHp.hpBoss <= 90 && bossHp.hpBoss > 60)
            {
                for (int i = 0; i < 5; i++)
                {
                    spawnPositionBoss = bossObject.transform.position;
                    int        type   = UnityEngine.Random.Range(0, hazards.Length - 1);
                    GameObject hazard = hazards[type];
                    enemyInCircle          = hazard.GetComponent <EnemyInCircle>();
                    enemyInCircle.enabled  = true;
                    enemyInCircle.onPlayer = true;
                    Instantiate(hazard, spawnPositionBoss, spawnRotation);
                    yield return(new WaitForSeconds(0.3f));
                }
                bossHp.ChangeImage();
                bossHp.moved = false;
                while (!bossHp.moved) // && animation running
                {
                    yield return(new WaitForSeconds(0.0000001f));
                }
                if (gameOver)
                {
                    UpdateScore(count);
                }
                yield return(new WaitForSeconds(waveWait));
            }
            else if (bossHp.hpBoss <= 60 && bossHp.hpBoss > 30)
            {
                for (int i = 0; i < 5; i++)
                {
                    spawnPositionBoss = bossObject.transform.position;
                    int        type   = UnityEngine.Random.Range(0, hazards.Length - 1);
                    GameObject hazard = hazards[type];
                    enemyInCircle         = hazard.GetComponent <EnemyInCircle>();
                    enemyInCircle.enabled = false;
                    mover = hazard.GetComponent <Mover>();
                    mover.rotateToPlayer = true;
                    Instantiate(hazard, spawnPositionBoss, spawnRotation);
                    yield return(new WaitForSeconds(spawnWait));
                }

                bossHp.ChangeImage();
                bossHp.moved = false;
                while (!bossHp.moved) // && animation running
                {
                    yield return(new WaitForSeconds(0.0000001f));
                }
                if (gameOver)
                {
                    UpdateScore(count);
                }
                yield return(new WaitForSeconds(waveWait));
            }
            else if (bossHp.hpBoss <= 30)
            {
                for (int i = 0; i < 5; i++)
                {
                    spawnPositionBoss = bossObject.transform.position;
                    int        type   = UnityEngine.Random.Range(0, hazards.Length - 1);
                    GameObject hazard = hazards[type];
                    enemyInCircle          = hazard.GetComponent <EnemyInCircle>();
                    enemyInCircle.enabled  = true;
                    enemyInCircle.onPlayer = false;
                    mover = hazard.GetComponent <Mover>();
                    mover.rotateToPlayer = false;
                    Instantiate(hazard, spawnPositionBoss, spawnRotation);

                    yield return(new WaitForSeconds(0.3f));
                }

                for (int i = 0; i < 5; i++)
                {
                    int        type   = UnityEngine.Random.Range(0, hazards.Length - 1);
                    GameObject hazard = hazards[type];
                    enemyInCircle          = hazard.GetComponent <EnemyInCircle>();
                    enemyInCircle.enabled  = true;
                    enemyInCircle.onPlayer = true;
                    Instantiate(hazard, spawnPositionBoss, spawnRotation);
                    yield return(new WaitForSeconds(0.3f));
                }

                for (int i = 0; i < 5; i++)
                {
                    int        type   = UnityEngine.Random.Range(0, hazards.Length - 1);
                    GameObject hazard = hazards[type];
                    enemyInCircle         = hazard.GetComponent <EnemyInCircle>();
                    enemyInCircle.enabled = false;
                    mover = hazard.GetComponent <Mover>();
                    mover.rotateToPlayer = true;
                    Instantiate(hazard, spawnPositionBoss, spawnRotation);
                    yield return(new WaitForSeconds(spawnWait));
                }

                bossHp.ChangeImage();
                bossHp.moved = false;

                while (!bossHp.moved)
                {
                    yield return(new WaitForSeconds(0.0000001f));
                }
                if (gameOver)
                {
                    UpdateScore(count);
                }
                yield return(new WaitForSeconds(waveWait));
            }
        } while (!end);
        playerControllerV2.boxCollider2d.enabled = false;
        spawnRotation = Quaternion.Euler(0, 0, 270);
        PrepareGame();
        highScore = 51;
        UpdateScore(highScore);
        gameManagerScript.Save();
        for (int i = 0; i < hazards.Length - 1; i++)
        {
            GameObject hazard = hazards[i];
            spawnPositionBoss = new Vector2(UnityEngine.Random.Range(-3, 3), 0);
            GameObject enemy = Instantiate(hazard, spawnPositionBoss, spawnRotation) as GameObject;
            yield return(new WaitForSeconds(spawnWait));
        }
        bossHp.destroyBoss = true;

        SceneManager.LoadScene("End");
    }