Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (pickup && !win)
        {   //Backpack
            if (CheckCloseToTag("backpack", distance))
            {
                g        = GameObject.FindGameObjectWithTag("backpack");
                backpack = true;
                collect.Play();
                g.SetActive(false);
                back_img.SetActive(true);
                counter--;
            }
            else if ((CheckCloseToTag("brown", distance) || CheckCloseToTag("red", distance) || CheckCloseToTag("black", distance)) &&
                     !backpack && !red && !brown && !black)
            {
                StartCoroutine(ShowMessage("You have to collect the Backpack first", 4));
            }
            //Red
            if (CheckCloseToTag("red", distance) && backpack && !red)
            {
                top             = GameObject.FindGameObjectWithTag("reed");
                chestAnim       = top.GetComponent <ChestAnimition>();
                chestAnim.start = true;
                turning.stop    = true;
                Debug.Log(turning.stop);
                Debug.Log(chestAnim.start);
                if (chestAnim.finish)
                {
                    red = true;
                    collect.Play();
                    StartCoroutine(ShowHideObjects(flashlight));
                    red_img.SetActive(true);
                    counter--;
                }
            }
            else if ((CheckCloseToTag("brown", distance) || CheckCloseToTag("black", distance)) &&
                     backpack && !red && !brown && !black)
            {
                StartCoroutine(ShowMessage("You have to check Red box first", 2));
            }
            //Black
            if (CheckCloseToTag("black", distance) && backpack && red && !black)
            {
                top             = GameObject.FindGameObjectWithTag("black_top");
                chestAnim       = top.GetComponent <ChestAnimition>();
                chestAnim.start = true;
                turning.stop    = true;
                if (chestAnim.finish)
                {
                    black = true;
                    collect.Play();
                    StartCoroutine(ShowHideObjects(mobile));
                    black_img.SetActive(true);
                    counter--;
                }
            }
            else if ((CheckCloseToTag("brown", distance)) &&
                     backpack && red && !brown && !black)
            {
                StartCoroutine(ShowMessage("You have to check Black box first", 4));
            }
            //Brown
            if (CheckCloseToTag("brown", distance) && backpack && black && red && !brown)
            {
                top             = GameObject.FindGameObjectWithTag("brown_top");
                chestAnim       = top.GetComponent <ChestAnimition>();
                chestAnim.start = true;
                turning.stop    = true;
                if (chestAnim.finish)
                {
                    collect.Play();
                    StartCoroutine(ShowHideObjects(rope));
                    brown_img.SetActive(true);
                    counter--;
                }
            }
        }

        if (counter == 0 && !win)
        {
            win          = true;
            turning.stop = true;
            StartCoroutine(PlayWinning());
            StartCoroutine(ShowMessage("Congratulations you completed Level 4", 3));
        }
        if (win)
        {
            StartCoroutine(NextLevel());
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (pickup && !win)
        {   //Backpack
            //    if (CheckCloseToTag("backpack", distance) && !backpack)
            //    {
            //        g = GameObject.FindGameObjectWithTag("backpack");
            //        img = GameObject.FindGameObjectWithTag("basket_img");
            //        backpack = true;
            //        collect.Play();
            //        g.SetActive(false);
            //        img.SetActive(false);
            //        counter--;
            //    }
            //Brown
            if (CheckCloseToTag("brown", distance) && !brown)
            {
                img             = GameObject.FindGameObjectWithTag("brown_img");
                top             = GameObject.FindGameObjectWithTag("brown_top");
                chestAnim       = top.GetComponent <ChestAnimition>();
                chestAnim.start = true;
                turning.stop    = true;
                if (chestAnim.finish)
                {
                    brown = true;
                    collect.Play();
                    img.SetActive(false);
                    brown_img.SetActive(true);
                    code = "if Brown_Box :" + '\n' + "    collect_Rope()";
                    StartCoroutine(ShowHideObjects(rope));
                    StartCoroutine(ShowCode(code));
                    counter--;
                }
            }
            //Red
            if (CheckCloseToTag("red", distance) && !red)
            {
                img             = GameObject.FindGameObjectWithTag("red_img");
                top             = GameObject.FindGameObjectWithTag("red_top");
                chestAnim       = top.GetComponent <ChestAnimition>();
                chestAnim.start = true;
                turning.stop    = true;
                if (chestAnim.finish)
                {
                    red = true;
                    collect.Play();
                    img.SetActive(false);
                    red_img.SetActive(true);
                    code = "if Red_Box :" + '\n' + "    collect_Flashlight()";
                    StartCoroutine(ShowHideObjects(flashlight));
                    StartCoroutine(ShowCode(code));
                    counter--;
                }
            }
            //Black
            if (CheckCloseToTag("black", distance) && !black)
            {
                img             = GameObject.FindGameObjectWithTag("black_img");
                top             = GameObject.FindGameObjectWithTag("black_top");
                chestAnim       = top.GetComponent <ChestAnimition>();
                chestAnim.start = true;
                turning.stop    = true;
                if (chestAnim.finish)
                {
                    black = true;
                    collect.Play();
                    img.SetActive(false);
                    black_img.SetActive(true);
                    code = "if Black_Box :" + '\n' + "    collect_Mobile()";
                    StartCoroutine(ShowHideObjects(mobile));
                    StartCoroutine(ShowCode(code));
                    counter--;
                }
            }
        }

        if (counter == 0 && !win)
        {
            win          = true;
            turning.stop = true;
            StartCoroutine(PlayWinning());
            StartCoroutine(ShowMessage("Congratulations you completed Level 3", 3));
        }
        if (win)
        {
            StartCoroutine(NextLevel());
        }
    }