Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D col) //col ==> trou ;;//gameobject --> object qui est en collision avec les trous, on attache ce script à grain et nn trou
    {
        if (gameObject.CompareTag("arrosoir") && col.gameObject.CompareTag("trou1") && PelleToTrou.pelle1Done == true && GrainToTrou.grain1Done == true)
        {
            myAnim = Instantiate(prefabAnim, col.transform.position, transform.rotation); // initiate dans la pos du trou
            Destroy(myAnim, 2.0f);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy
            if (col.gameObject.CompareTag("trou1"))
            {
                action3             = true;
                ScoreCounter.score += 2;
                InstantiatePlusTwoAnim();
            }
        }


        if (GrainLevel2.action2Tr3 == true && gameObject.CompareTag("arrosoir") && col.gameObject.CompareTag("trou3"))
        {
            myAnim = Instantiate(prefabAnim, col.transform.position, transform.rotation); // initiate dans la pos du trou
            Destroy(myAnim, 2.0f);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy

            if (col.gameObject.CompareTag("trou3"))
            {
                action3Tr3          = true;
                ScoreCounter.score += 2;
                InstantiatePlusTwoAnim();
                //on montre la 1ere etoile
                StarOne.showStarOne();
                star1L2 = true;
            }
        }



        if (GrainLevel2.action2Tr4 == true && gameObject.CompareTag("arrosoir") && col.gameObject.CompareTag("trou4"))
        {
            myAnim = Instantiate(prefabAnim, col.transform.position, transform.rotation); // initiate dans la pos du trou
            Destroy(myAnim, 2.0f);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy

            if (col.gameObject.CompareTag("trou4"))
            {
                action3Tr4          = true;
                ScoreCounter.score += 2;
                InstantiatePlusTwoAnim();
                Star2.showStar2();
                star2L2 = true;
            }
        }



        if (gameObject.CompareTag("arrosoir") && col.gameObject.CompareTag("trou5") && Trou4Level2.grainTrou5 == true)
        {
            myAnim = Instantiate(prefabAnim, col.transform.position, transform.rotation); // initiate dans la pos du trou
            Destroy(myAnim, 2.0f);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy


            if (col.gameObject.CompareTag("trou5"))
            {
                action3Tr5          = true;
                ScoreCounter.score += 2;
                InstantiatePlusTwoAnim();
                star3.showStar3();
                star3L2 = true;
            }
        }
    }
Exemplo n.º 2
0
    void OnCollisionEnter2D(Collision2D col) //col ==> trou ;;//gameobject --> object qui est en collision avec les trous, on attache ce script à grain et nn trou
    {
        if (DDCreuser.action1 == true && DDGrain.action2 == true && gameObject.CompareTag("arrosoir"))
        {
            InstantiatePrefab(col.transform.position);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy
            if (col.gameObject.CompareTag("trou1"))
            {
                action3             = true;
                ScoreCounter.score += 1;
                InstantiatePlusOneAnim();
            }
        }

        if (DDCreuser.action1Tr2 == true && DDGrain.action2Tr2 == true && gameObject.CompareTag("arrosoir"))
        {
            if (ScoreCounter.score > 5)
            {
                isColliding = true;
                return;
            }
            InstantiatePrefab(col.transform.position);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy

            if (col.gameObject.CompareTag("trou2"))
            {
                action3Tr2          = true;
                ScoreCounter.score += 1;
                InstantiatePlusOneAnim();
            }
        }

        if (DDCreuser.action1Tr3 == true && DDGrain.action2Tr3 == true && gameObject.CompareTag("arrosoir"))
        {
            if (ScoreCounter.score > 8)
            {
                isColliding = true;
                return;
            }

            InstantiatePrefab(col.transform.position);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy

            if (col.gameObject.CompareTag("trou3"))
            {
                action3Tr3          = true;
                ScoreCounter.score += 1;
                InstantiatePlusOneAnim();
                //on montre la 1ere etoile
                StarOne.showStarOne();
                star1L1 = true;
            }
        }


        if (DDCreuser.action1Tr4 == true && DDGrain.action2Tr4 == true && gameObject.CompareTag("arrosoir"))
        {
            if (ScoreCounter.score > 11)
            {
                isColliding = true;
                return;
            }
            InstantiatePrefab(col.transform.position);
            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy

            if (col.gameObject.CompareTag("trou4"))
            {
                action3Tr4          = true;
                ScoreCounter.score += 1;
                InstantiatePlusOneAnim();
            }
        }



        if (DDCreuser.action1Tr5 == true && DDGrain.action2Tr5 == true && gameObject.CompareTag("arrosoir"))
        {
            if (ScoreCounter.score > 14)
            {
                isColliding = true;
                return;
            }

            InstantiatePrefab(col.transform.position);

            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy
            if (col.gameObject.CompareTag("trou5"))
            {
                action3Tr5          = true;
                ScoreCounter.score += 1;
                InstantiatePlusOneAnim();
            }
        }


        if (DDCreuser.action1Tr6 == true && DDGrain.action2Tr6 == true && gameObject.CompareTag("arrosoir"))
        {
            if (ScoreCounter.score > 17)
            {
                isColliding = true;
                return;
            }
            InstantiatePrefab(col.transform.position);

            RegenererGameObject();
            Destroy(this.gameObject); //l'ordre compte, il faut regenerer tout d'abord, après destroy

            if (col.gameObject.CompareTag("trou6"))
            {
                action3Tr6          = true;
                ScoreCounter.score += 1;
                InstantiatePlusOneAnim();
                //la plante6 pousse on le donne une 2 eme etoile
                Star2.showStar2();

                star2L1 = true;
                youWin.SetActive(true);
                Debug.Log(star2L1);
            }
        }

        else
        {
            isColliding = true;
        }
    }