Example #1
0
    void AddTail()
    {
        SnakeMovement newTail = Instantiate(bodyPrefab).GetComponent <SnakeMovement>();

        newTail.transform.position = tail.transform.position - tail.transform.forward;
        if (score < 1)
        {
            Destroy(newTail.GetComponent <SphereCollider>());
        }

        newTail.follow = tail;
        tail           = newTail;
        score++;
    }
Example #2
0
    void Update()
    {
        print(nextlevel);
        if (GameState.GAME == gameState)
        {
            nextlevel++;
        }


        ScoreText.text     = "SCORE: " + SCORE;
        MenuScoreText.text = "SCORE: " + SCORE;

        if (Input.GetKey(KeyCode.D) /* || Input.GetTouch(0).phase == TouchPhase.Began*/)
        {
            SetGame();
        }
        colorTimeChange++;

        if (SCORE > BESTSCORE)
        {
            BESTSCORE          = SCORE;
            BestScoreText.text = BESTSCORE + "";
            if (!speedAdded && SCORE > 150)
            {
                SM.speed++;
                speedAdded = true;
            }
        }
        if (nextlevel == levelLife && GameState.GAME == gameState)
        {
            switch (level)
            {
            case 1:
            {
                SM.GetComponent <SnakeMovement>().SetInitialAmount(SM.BodyParts.Count);
                SceneManager.LoadScene("LEVEL2", LoadSceneMode.Single);
                nextlevel = 0;
                break;
            }

            case 2: {
                SM.GetComponent <SnakeMovement>().SetInitialAmount(SM.BodyParts.Count);
                SceneManager.LoadScene("LEVEL3", LoadSceneMode.Single);
                nextlevel = 0;
                break;
            }

            case 3:
            {
                SM.GetComponent <SnakeMovement>().SetInitialAmount(SM.BodyParts.Count);
                SceneManager.LoadScene("LEVEL4", LoadSceneMode.Single);
                break;
            }

            case 4:
                SceneManager.LoadScene("LEVEL1", LoadSceneMode.Single);
                break;

            default:
                SceneManager.LoadScene("LEVEL2", LoadSceneMode.Single);
                break;
            }
        }
        if (colorTimeChange > changetime)
        {
            InvokeColorChange();
            colorTimeChange = 0;
        }
    }