Exemplo n.º 1
0
    public void GameOver()
    {
        switch (gameOverType)
        {
        case GameOverType.Win:
            for (int i = 0; i < GameOverFx.Length; i++)
            {
                GameOverFx[i].SetActive(true);
            }
            SoundManagerForCollectFruits.sharedManager().PlayWinFX();
            Manager.sharedManager().isGameStarted = false;
            Manager.sharedManager().isGameOver    = true;
            gameOverPanel.SetActive(true);
            Manager.sharedManager().txtBtnRestart.text = "Next Level";
            Manager.sharedManager().btnRestart.onClick.AddListener(() => StageManager.sharedManager().GotoNextLevel());
            Manager.sharedManager().inGamePanel.SetActive(false);
            break;

        case GameOverType.Lose:
            SoundManagerForCollectFruits.sharedManager().PlayLoseFX();
            Manager.sharedManager().isGameStarted = false;
            Manager.sharedManager().isGameOver    = true;
            gameOverPanel.SetActive(true);
            Manager.sharedManager().inGamePanel.SetActive(false);
            break;
        }
    }
Exemplo n.º 2
0
    private void OnCollisionEnter(Collision collision)
    {
        collision.gameObject.GetComponent <Collider>().enabled = false;
        Instantiate(magicPoofFx, collision.gameObject.transform.position, Quaternion.identity);
        CheckIfoodPositionExceed();
        switch (collision.gameObject.tag)
        {
        case "Apple":
            Destroy(collision.gameObject);
            Instantiate(Manager.sharedManager().apples, fruitsPosition[fruitCount]);

            break;

        case "Coconut":
            Destroy(collision.gameObject);
            Instantiate(Manager.sharedManager().coconut, fruitsPosition[fruitCount]);

            break;

        case "Orange":
            Destroy(collision.gameObject);
            Instantiate(Manager.sharedManager().orange, fruitsPosition[fruitCount]);

            break;
        }
        fruitCount++;
        SoundManagerForCollectFruits.sharedManager().PlayFruitCollectFX();
        if (fruitCount == fruitOnCartPosition.Length)
        {
            GameActions.sharedManager().gameOverType = GameActions.GameOverType.Win;
            GameActions.sharedManager().GameOver();
            MoveIt();
            fruitCount = 0;
            stackFilled++;
        }
    }