Esempio n. 1
0
    void OnCollisionEnter(Collision col)
    {
        if (this.transform.gameObject.tag == "ingredient" & col.gameObject.tag != "ingredient" & !SpawnPointScript.gameOver)
        {
            // play sound if it is enabled
            if (MenuScript.SoundOn == true)
            {
                source.Play();
            }

            this.transform.gameObject.tag = "GroundedSlice";



            // adding gameobject to the list of grounded slices to calculate highest point of the sanwich
            SpawnPointScript.slicesInPile.Add(this.transform.gameObject);


            // disable on the fly boolean. User input is available again
            SpawnPointScript.sliceOntheFly = false;


            // spawning new slice on after collision with the base

            SpawnPointScript spw    = FindObjectOfType <SpawnPointScript>();
            GameObject       spawnP = GameObject.Find("Spawn_point");


            // Using the x coordinate of the slice to spawn next one
            Vector3 SpawnCoord = new Vector3(this.transform.position.x, spawnP.transform.position.y, spawnP.transform.position.z);

            if (gameObject.name != "Free(Clone)")
            {
                spw.SpawnSlice(SpawnCoord, true);
                MenuScript.scoreValue += 1;
            }
            else
            {
                // seperate spawn technique for the bunch of free
                SpawnPointScript.numPotatoesCollided++;
                if (SpawnPointScript.numPotatoesCollided == 6)
                {
                    Debug.Log("Request to spawn fries sent - onCollision");
                    spw.SpawnSlice(SpawnCoord, true);
                    SpawnPointScript.numPotatoesCollided = 0;     //--- Free spawn DISABLED
                    MenuScript.scoreValue0 += 1;
                }
            }



            // stability assist feature
            FreezeLowerSlices();
            SimplifiedCollisionDetector();
        }
    }
Esempio n. 2
0
    public void Restart()
    {
        nextButton.SetActive(false);

        //unhiding back the resume button
        resBut.GetComponent <Image>().color         = new Color(255, 255, 255, 255f);
        resBut.GetComponentInChildren <Text>().text = "Resume";

        //  zeroing the values
        SpawnPointScript.currentSlice = 0;


        // resetting the values in scripts


        DestroyAllObjects();
        scoreValue0    = 0;
        scoreValue     = 0;
        scoreValue1    = 0;
        Time.timeScale = 1f;

        levelProgress         = 0;
        ProgressBar.fillRatio = 0.05f; // reseting the infill ofthe progress bar

        accuracy1 = 0;                 // resetting the accuracy
        accuracy2 = 0;
        accuracy3 = 0;

        nextLevelOpen = false;



        // getting the new values for in-level score value
        scoreLimit = SpawnPointScript.FoodSequenceFull[currentLevel].Length - 2;


        // removing all menus and  switches
        mainMenu.SetActive(false);
        MenuUI.SetActive(false);
        SpawnPointScript.gameOver = false;
        PausePressed = false;
        colliderBase.resultUploaded = false;


        // instantiate box and  glass

        SpawnItemsOnPlate();


        //GameObject obj1 =  Instantiate(box, new Vector3(-0.68f, -7.9f,-1.04f), Quaternion.Euler(0f, 0, 0f)) as GameObject;
        //GameObject obj2 = Instantiate(glass, new Vector3(2.22f, -8f, -1.29f), Quaternion.Euler(0f, 0, 0f)) as GameObject;
        //GameObject obj3 = Instantiate(fluidLevel, new Vector3(2.22f, -8.06f, -1.32f), Quaternion.Euler(0f, 0, 0f)) as GameObject;

        //spawning the first slice  at all spawn points
        SpawnPointScript spw = FindObjectOfType <SpawnPointScript>();

        spw.SpawnSlice(new Vector3(spw.transform.position.x + 0f, spw.transform.position.y, spw.transform.position.z + 0.5f), true);



        // resetting the camera and spawn position to initial  -- DISABLED ---

        spw.ResetCameraAndSpawnPos();

        // clearing the lists of gameobjects used for height calculations
        SpawnPointScript.slicesInPile.Clear();
        numRestarts++;

        /*
         *      if(Monetization.IsReady("video") & numRestarts%3 ==0)
         *      {
         *              ShowAdPlacementContent ad = null;
         *              ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent;
         *
         *              if(ad !=null){
         *                      ad.Show();
         *              } else {
         *                      Debug.Log("ad =null");
         *              }
         *      }
         */
    }