Beispiel #1
0
    void Update()
    {
        characterPos = character.transform.position;
        timeLeft    -= Time.deltaTime;
        playerScoreUI.gameObject.GetComponent <Text>().text = ("Score: " + playerScore);
        Trail.Counter(Pick);



        if (Pick == 1 && FD == 0)
        {
            FoodTrail.transform.position = characterPos;
            FD = 1;
        }
        else if (Pick != 1 && FD == 0)
        {
            FoodTrail.transform.position = offscreen;
        }



        if (FoodTrail.transform.position.x < character.transform.position.x - 0.8f)
        {
            FoodTrail.transform.position = new Vector3(character.transform.position.x - 0.8f, FoodTrail.transform.position.y, FoodTrail.transform.position.z);
        }
        else if (FoodTrail.transform.position.x > character.transform.position.x + 0.8f)
        {
            FoodTrail.transform.position = new Vector3(character.transform.position.x + 0.8f, FoodTrail.transform.position.y, FoodTrail.transform.position.z);
        }



        if (FoodTrail.transform.position.y != character.transform.position.y && FD == 1)
        {
            FoodTrail.transform.position = Vector2.MoveTowards(FoodTrail.transform.position, character.transform.position, Time.deltaTime * 3.5f);
        }



        if (Drop >= 7)
        {
            StartCoroutine(LoadScene());
        }


        IEnumerator LoadScene()
        {
            transition.SetBool("endd", true);
            yield return(new WaitForSeconds(2.5f));

            SceneManager.LoadScene(scenename);
        }
    }