Exemplo n.º 1
0
    IEnumerator WaitToReset()
    {
        isWait = true;
        _AudioController.ChangeMusic(_AudioController.level1);
        _FadeController.FadeIn();
        yield return(new WaitForSeconds(1f));

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        Time.timeScale    = 1f;
        timer             = classRoomTime + 3;
        timerBar.duration = timer;
        state             = GameState.Light;
        chaos             = 0;
        score             = LevelManager.sharedInstance.score;
        scoreText.text    = score.ToString();
        timeSinceLastTick = -2.9f;
        students          = FindObjectsOfType <Student>();

        childsToCorrupt = (LevelManager.sharedInstance.level - 1) / 2;
        timeToCorrupt   = timer / (childsToCorrupt + 1);
        corruptTimer    = timeToCorrupt;

        bgAudioSource = AudioController.SharedInstance;

        bgAudioSource.ChangeMusic(lightBGM);
        bgAudioSource.ChangeBGMVolume(1f);
        bgAudioSource.PlaySoundEffect(StartingSound, 0);

        GameObject go      = GameObject.Find("Class Number");
        Texture2D  texture = SharedResources.GetSharedInstance().numbers[LevelManager.sharedInstance.level];
        Image      im      = go.GetComponent <Image>();

        SharedResources.GetSharedInstance();
        im.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
    }
Exemplo n.º 3
0
 // Desculpa por esse código horrível, mas fazer o que, né
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         if (bossCamera)
         {
             _AudioController.ChangeMusic(_AudioController.boss1);
             if (bgFase != null)
             {
                 bgFase.SetActive(false);
             }
             SalaBoss.instance.iniciarBoss();
         }
         if (conclusao)
         {
             if (bgFase != null)
             {
                 bgFase.SetActive(true);
             }
         }
         if (bossRena)
         {
             StartCoroutine(ativarRena());
         }
         CameraController.instance.EnableCamera(myCamera, bossCamera, bossRena, conclusao);
     }
 }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Jump") || Input.GetKeyDown(KeyCode.Escape))
     {
         _AudioController.ChangeMusic(_AudioController.intro);
         SceneManager.LoadScene(0);
     }
 }
Exemplo n.º 5
0
 public void GoMenu()
 {
     _AudioController.PlayFX(_AudioController.uiClick, 1f);
     Time.timeScale = 1f;
     GameIsPaused   = false;
     _AudioController.ChangeMusic(_AudioController.title);
     _FadeController.FadeIn();
     SceneManager.LoadScene(1);
 }
Exemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     _GameController = FindObjectOfType(typeof(GameController)) as GameController;
     _AudioController = FindObjectOfType(typeof(AudioController)) as AudioController;
     currentAnimal = rat;
     speed = ratSpeed;
     height = ratJumpHeight;
     _AudioController.ChangeMusic(_AudioController.ratAudio);
 }
Exemplo n.º 7
0
    IEnumerator WaitFadeIn()
    {
        //_FadeController.FadeIn();
        _AudioController.ChangeMusic(_AudioController.title);
        yield return(new WaitForSeconds(timeToFadeOut * 4));

        if (_FadeController.isFadeComplete == true)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
        }
    }
Exemplo n.º 8
0
    public void OnPickup(GameObject item)
    {
        drugLevel += 1;
        if (drugLevel >= 2)
        {
            _AudioController.ChangeMusic(_AudioController.music2);
        }

        Destroy(item);
        NextScene();
    }
Exemplo n.º 9
0
 private void Start()
 {
     _AudioController = FindObjectOfType(typeof(AudioController)) as AudioController;
     _AudioController.ChangeMusic(_AudioController.music1);
     _Fade.gameObject.SetActive(true);
     gameplayUI.SetActive(false);
     hpBar.transform.parent.gameObject.SetActive(false);
     altf4.gameObject.SetActive(false);
     pauseMenu.SetActive(false);
     ChangeFadeColor(Color.black);
 }
Exemplo n.º 10
0
    void TakeHit()
    {
        if (healthPoints == 0)
        {
            _AudioController.ChangeMusic(_AudioController.level1);
            return;
        }
        healthPoints--;
        healthBar.SetHealth((int)healthPoints);

        StartCoroutine("Invencivel");
    }
Exemplo n.º 11
0
    public void TakeHit()
    {
        tomouHit = true;
        enemyHP--;
        healthBar.SetHealth((int)enemyHP);

        if (enemyHP < 0)
        {
            _AudioController.ChangeMusic(_AudioController.level2);
            animator.SetTrigger("Die");
            isDie = true;
            PlayerController.instance.moverSozinho = true;
            sacoPapaiNoel.SetActive(true);
        }

        StartCoroutine("Invencivel");
    }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;
        if (chaos >= numberOfStudents && timer >= 0)
        {
            state = GameState.Finished;
            perdeu.SetActive(true);
            // PERDER
        }
        else if (chaos < numberOfStudents && timer <= 0)
        {
            // Vencer
            LevelManager lm = LevelManager.sharedInstance;
            if (lm.level < lm.maxLevel)
            {
                state = GameState.ChangingLevel;
            }
            else
            {
                state = GameState.Finished;
                ganhou.SetActive(true);
            }
        }
        else   // Evita que o jogador continue ganhando pontos após o término do jogo
        {
            timeSinceLastTick += Time.deltaTime;
            if (timeSinceLastTick >= scoreTick)
            {
                IncrementScore();
            }
            if (childsToCorrupt > 0)
            {
                corruptTimer -= Time.deltaTime;
                if (corruptTimer <= 0)
                {
                    int selected = Random.Range(0, students.Length - 1);
                    int iterator = selected;
                    while (students[iterator].status != StudentStatus.Neutral)
                    {
                        iterator = (iterator + 1) % students.Length;
                        if (iterator == selected)
                        {
                            break;
                        }
                    }
                    if (students[iterator].status == StudentStatus.Neutral)
                    {
                        students[iterator].bagunca = students[iterator].threshold;
                    }
                    corruptTimer = timeToCorrupt;
                    childsToCorrupt--;
                }
            }
        }

        switch (state)
        {
        case GameState.Light:
            if (chaos >= enterMediumState)
            {
                bgAudioSource.ChangeMusic(mediumBGM, false);
                state = GameState.Medium;
            }
            break;

        case GameState.Medium:
            if (chaos >= enterHeavyState)
            {
                bgAudioSource.ChangeMusic(heavyBGM, false);
                //bgAudioSource.ChangeBGMVolume(0.5f);
                state = GameState.Heavy;
            }
            break;

        case GameState.Heavy:
            break;

        case GameState.ChangingLevel:
            if (students[0].enabled)
            {
                bgAudioSource.PlaySoundEffect(StartingSound, 0);
                foreach (Student s in students)
                {
                    s.myDesk.objectInPlace.gameObject.SetActive(false);
                    s.enabled = false;
                }
            }
            finishedLevel.SetActive(true);
            //LevelManager.sharedInstance.FinishLevel();
            break;

        case GameState.Finished:
            timer += Time.deltaTime;

            GameObject.FindObjectOfType <TimerBarComponent>().enabled = false;

            foreach (Student s in students)
            {
                s.myDesk.objectInPlace.gameObject.SetActive(false);
                s.enabled = false;
            }

            GameObject temp = (ganhou.activeSelf == true ? ganhou : perdeu);

            Text finalScoreText = temp.transform.Find("score final").gameObject.GetComponent <Text>();
            Text highScoreText  = temp.transform.Find("Highscore value").gameObject.GetComponent <Text>();
            Text recorde        = temp.transform.Find("Recorde").gameObject.GetComponent <Text>();

            finalScoreText.text = scoreText.text;
            int hs = PlayerPrefs.GetInt(Constants.HIGH_SCORE_KEY);

            if (score > hs)                  // Highscore
            {
                PlayerPrefs.SetInt(Constants.HIGH_SCORE_KEY, score);
                recorde.enabled = true;
                hs = score;
            }

            highScoreText.text = hs.ToString();
            break;
        }
    }
Exemplo n.º 13
0
    } //controle da vida

    void GameOver()
    {
        Time.timeScale = 0;
        _AudioController.ChangeMusic(_AudioController.gameOver);
        _PauseMenu.gameOverMenu.SetActive(true);
    }