LoadNextLevel() публичный Метод

public LoadNextLevel ( ) : void
Результат void
Пример #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Portal"))
     {
         loadLevel.LoadNextLevel();
     }
 }
Пример #2
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.CompareTag("Player"))
     {
         LoadLevel.LoadNextLevel();
     }
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (greenRunInitial)
        {
            green.transform.position += Vector3.right * Time.deltaTime * Speed;
            greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
        }

        if (green.transform.position.x >= -24f)
        {
            greenRunInitial = false;
            greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(0));
        }

        if (red.transform.position.y > 15.3)
        {
            runRed = false;
            red.SetActive(false);
        }

        if (green.transform.position.y > 5.5)
        {
            runGreen = false;
            loadlevel.LoadNextLevel();
        }

        if (runRed)
        {
            if (red.transform.position.x < 14f)
            {
                red.transform.position += Vector3.right * Time.deltaTime * Speed;
                redAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
            else
            {
                red.transform.position += Vector3.up * Time.deltaTime * Speed;
                redAnimator.SetBool("isWalking", true);
                redAnimator.SetBool("Climb", false);
            }
        }

        if (runGreen)
        {
            if (green.transform.position.x < -1.7f)
            {
                green.transform.position += Vector3.right * Time.deltaTime * Speed;
                greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
            else
            {
                green.transform.position += Vector3.up * Time.deltaTime * Speed;
                greenAnimator.SetBool("isWalking", true);
                greenAnimator.SetBool("Climb", false);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (greenRunInitial)
        {
            green.transform.position += Vector3.right * Time.deltaTime * Speed;
            greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
        }

        if (green.transform.position.x >= -18f)
        {
            greenRunInitial = false;
            greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(0));
        }

        if (red.transform.position.y <= 3)
        {
            runRed = false;
            red.SetActive(false);
        }

        if (green.transform.position.y <= -3)
        {
            runGreen = false;
            loadlevel.LoadNextLevel();
        }

        if (runRed)
        {
            if (red.transform.position.x < -13.3f)
            {
                red.transform.position += Vector3.right * Time.deltaTime * Speed;
                redAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
            else
            {
                red.transform.position += new Vector3(1, -1, 0) * Time.deltaTime * Speed;
                redAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
        }

        if (runGreen)
        {
            if (green.transform.position.x < 3.2f)
            {
                green.transform.position += Vector3.right * Time.deltaTime * Speed;
                greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
            else
            {
                green.transform.position += new Vector3(1, -1, 0) * Time.deltaTime * Speed;
                greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (settings.activeSelf)
        {
            if (Input.GetButtonDown("Left"))
            {
                volumeSlider.value -= 0.05f;
                GameObject.FindGameObjectWithTag("Music").GetComponent <Music>().changeVolume(volumeSlider.value);
            }
            else if (Input.GetButtonDown("Right"))
            {
                volumeSlider.value += 0.05f;
                GameObject.FindGameObjectWithTag("Music").GetComponent <Music>().changeVolume(volumeSlider.value);
            }
        }
        //float h = Input.GetAxis("Horizontal");
        //Debug.Log(h);

        if (play)
        {
            StartCoroutine(WalkingAnimation());
        }

        if (walking)
        {
            //GetComponent<Rigidbody2D>().velocity = new Vector2(1, 0) * Speed;
            transform.position += Vector3.right * Time.deltaTime * Speed;
            //animator.SetFloat("Speed", Mathf.Abs(1));
            animator.SetFloat("HorizontalAxis", Mathf.Abs(1));
        }

        if (exit)
        {
            Application.Quit();
            exit = false;
            Debug.Log("EXIT");
        }

        if (this.transform.position.x > 30)
        {
            load.LoadNextLevel();
        }
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (player.transform.position.y >= 4.8f)
        {
            load.LoadNextLevel();
        }

        player.transform.position  += Vector3.up * Time.deltaTime * Speed;
        player2.transform.position += Vector3.up * Time.deltaTime * Speed;


        //light.transform.position += Vector3.up * Time.deltaTime * Speed;
        //light2.transform.position += Vector3.up * Time.deltaTime * Speed;


        //animator.SetFloat("Speed", Mathf.Abs(1));
        player.GetComponent <Animator>().SetTrigger("isWalking");
        player2.GetComponent <Animator>().SetTrigger("isWalking");
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        if (green.transform.position.x > 20f)
        {
            ll.LoadNextLevel();
        }

        if (greenRunInitial)
        {
            green.transform.position += Vector3.right * Time.deltaTime * Speed;
            greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
        }

        if (green.transform.position.x >= -24f)
        {
            greenRunInitial = false;
            greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(0));
        }

        if (redRun)
        {
            if (red.transform.position.x <= 15)
            {
                red.transform.position += Vector3.right * Time.deltaTime * Speed;
                redAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }
            else if (red.transform.position.x > 15 && red.transform.position.y < 15.5f)
            {
                red.transform.position += Vector3.up * Time.deltaTime * Speed;
                redAnimator.SetBool("isWalking", true);
                redAnimator.SetBool("Climb", false);
            }
            else
            {
                redAnimator.SetBool("isWalking", false);
                redAnimator.SetBool("Climb", false);
                red.transform.position += Vector3.right * Time.deltaTime * Speed;
                redAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
            }

            if (greenRun)
            {
                if (green.transform.position.x <= -1f)
                {
                    green.transform.position += Vector3.right * Time.deltaTime * Speed;
                    greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
                }
                else if (green.transform.position.x > -1f && green.transform.position.y < 4.1f && !hasClimbed)
                {
                    //Debug.Log("Climb");
                    green.transform.position += Vector3.up * Time.deltaTime * Speed;
                    greenAnimator.SetBool("isWalking", true);
                    greenAnimator.SetBool("Climb", false);
                }
                else
                {
                    hasClimbed = true;
                    greenAnimator.SetBool("isWalking", false);
                    greenAnimator.SetBool("Climb", false);
                    green.transform.position += Vector3.right * Time.deltaTime * Speed;
                    greenAnimator.SetFloat("HorizontalAxis", Mathf.Abs(1));
                }
            }
        }
    }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        // TIMER TIMINGS
        // if (levelTimer != null) levelTimer.isTimerWorking = ove;


        float x = Input.GetAxis("Horizontal");
        float y = Input.GetAxis("Vertical");

        /*if(x != 0){
         *  rigidbody.kinematic = false;
         * }else{
         *  rigidbody.kinematic = true;
         * }*/

        if (transform.position.x > 28f)
        {
            try { level.LoadNextLevel(); }
            catch { //Debug.Log("No Level");
            }
        }

        if (transform.position.y < -26)
        {
            // Debug.Log("Here");
            this.transform.position = respawnPosition;
        }

        // Adding bool to check which way the player is facing.

        Vector2 direction = new Vector2(x, y);

        if (x > 0)
        {
            isLeft = false;
        }
        else if (x < 0)
        {
            isLeft = true;
        }

        Walk(direction);

        if (canMove)
        {
            anim.SetHorizontalMovement(x, y, rb.velocity.y);
        }

        if (ladder2Collision)
        {
            rb.gravityScale = 3;
            platform.SetActive(true);
            //animator.SetBool("isWalking", false);
            //animator.SetBool("Climb", false);
        }
        // Ghita: Commented this to fix bug.

        if (platform != null && platform.activeSelf && Input.GetButton("Down") && ladderCollision)
        {
            rb.gravityScale = 1;
            platform.SetActive(false);
            // Ghita: Commented this to fix bug.
            //ladderCollision = true;
        }


        if (ladderCollision && Input.GetButton("Up"))
        {
            rb.velocity     = Vector2.Lerp(rb.velocity, (new Vector2(rb.velocity.x, direction.y * speed)), wallLerp * Time.deltaTime);
            rb.velocity     = new Vector2(0, rb.velocity.y);
            rb.gravityScale = 1;
            animator.SetBool("isWalking", true);
            animator.SetBool("Climb", false);
        }

        if (ladderCollision && Input.GetButton("Down") && !coll.onGround && canMove)
        {
            rb.velocity     = Vector2.Lerp(rb.velocity, (new Vector2(rb.velocity.x, direction.y * speed)), wallLerp * Time.deltaTime);
            rb.velocity     = new Vector2(0, rb.velocity.y);
            rb.gravityScale = 1;
            animator.SetBool("isWalking", true);
            animator.SetBool("Climb", false);
        }

        /*if(ladderCollision && (!Input.GetButton("Down") && !Input.GetButton("Up"))){
         *  animator.SetBool("isWalking", false);
         *  if(coll.onGround) animator.SetBool("Climb", false);
         * //Debug.Log("AICI");
         * }*/


        if (infoSign && Input.GetButtonDown("Info"))
        {
            if (SceneManager.GetActiveScene().name == "Level0")
            {
                if (speechIndex == 1 && !continueSpeech)
                {
                    return;
                }
                if (firstBear != null && firstBear.activeSelf == true)
                {
                    firstBear.SetActive(false);
                    speechIndex = 0;
                    bearSpeech[0].SetActive(true);
                }
                else
                {
                    if (speechIndex == bearSpeech.Length - 1)
                    {
                        return;
                        //speechIndex = -1;
                        //bearSpeech[bearSpeech.Length-1].SetActive(false);
                    }
                    else
                    {
                        if (speechIndex >= 0)
                        {
                            bearSpeech[speechIndex].SetActive(false);
                        }
                    }
                    speechIndex++;
                    if (speechIndex == 1 && !continueSpeech)
                    {
                        decisionLevel0.SetActive(true);
                        info.SetActive(false);
                    }
                    bearSpeech[speechIndex].SetActive(true);
                }
            }
            //Debug.Log("AICI");
        }
        if (decisionLevel0 != null)
        {
            if (decisionLevel0.activeSelf)
            {
                if (infoSign && Input.GetButtonDown("Yes"))
                {
                    continueSpeech = true;
                    cherry.SetActive(true);
                    speechIndex++;
                    bearSpeech[speechIndex - 1].SetActive(false);
                    bearSpeech[speechIndex].SetActive(true);
                    decisionLevel0.SetActive(false);
                    info.SetActive(true);
                }

                if (Input.GetButtonDown("No"))
                {
                    decisionLevel0.SetActive(false);
                    info.SetActive(true);
                }
            }
        }

        /*if(!ladderCollision && (Input.GetButton("Down") || Input.GetButton("Up"))){
         *  animator.SetBool("isWalking", false);
         *  animator.SetBool("Climb", false);
         * }*/
        try
        {
            if (!Input.GetButton("Down") && !Input.GetButton("Up"))
            {
                if (!coll.onGround)
                {
                    rb.velocity = new Vector2(0, rb.velocity.y);
                    animator.SetBool("Climb", true);
                    animator.SetBool("isWalking", false);
                }
                else
                {
                    animator.SetBool("isWalking", false);
                    animator.SetBool("Climb", false);
                }

                // animator.Stop("idle-green");
            }
            else
            {
                if (coll.onGround && !Input.GetButton("Up"))
                {
                    animator.SetBool("isWalking", false);
                    animator.SetBool("Climb", false);
                }

                if (coll.onGround && Input.GetButton("Up") && ladder2Collision)
                {
                    animator.SetBool("isWalking", false);
                    animator.SetBool("Climb", false);
                }

                if (coll.onGround && Input.GetButton("Down") && ladderCollision)
                {
                    animator.SetBool("isWalking", false);
                    animator.SetBool("Climb", false);
                }
            }
        }
        catch { }

        if ((x < 0 || x > 0) && canMove)
        {
            if (x > 0)
            {
                side = true;
            }
            if (x < 0)
            {
                side = false;
            }
            // Debug.Log("Aici");
            anim.Flip(side);
        }
    }