Exemple #1
0
    void Awake()
    {
        AdControl.hideBanner();

        Application.targetFrameRate = 60;

        gameState = GameConst.GAME_STATE.PLAYING;

        bonusStyleControl = GetComponent<BonusStyleControl> ();

        trans = GetComponent<Transform> ();

        canvas = GameObject.Find ("Canvas");

        score = canvas.GetComponent<Score>();

        panelGameOver = goPanelGameover.GetComponent<PanelGameOver> ();

        panelPause = goPanelPause.GetComponent<PanelPause> ();

        listSnake = new List<SnakeBody> ();
        listFood = new List<Food>();
        snakeState = GameConst.snakeState.MOVING;

        AudioSource[] audios = gameObject.GetComponents<AudioSource> ();
        combineSound = audios[0];
        eatSound = audios[1];
        crushSound = audios[2];
    }
Exemple #2
0
    private void snakeDie()
    {
        snakeState = GameConst.snakeState.DEAD;

        crushSound.Play();

        bool levelComplete = false;
        int totalGrid = (GameConst.HALF_ROW * 2 + 1) * (GameConst.HALF_LINE * 2 + 1);
        totalGrid -= 1;
        int count2048 = 0;
        foreach(var body in listSnake)
        {
            if(body.num == 2048)
            {
                ++count2048;
            }
        }
        if (totalGrid <= count2048) {
            levelComplete = true;
        }

        panelGameOver.updateScore (score.score,levelComplete);

        animtorPanelGameOver.SetBool ("gameIsOver",true);

        AdControl.showBanner();

        gameState = GameConst.GAME_STATE.GAMEOVER;
    }