예제 #1
0
    /*
     * This function NEEDS TO BE ACTIVATED whenever the scene is reloaded (i.e. pause + reset
     * game or gameover + restart)
     * The states and other variables are reset to their original values.
     */
    public void RepeatStart()
    {
        //This code is repeated in Start
        score         = 0;
        temperature   = 0;
        tossed        = false;
        gameStart     = true;
        gameEnds      = false;
        gameOver      = false;
        pause         = false;
        currIceIndex  = 0;
        clickedOnCube = false;
        //Reinitialize UI Items
        scoreObj      = GameObject.Find("Score");
        tempObj       = GameObject.Find("Temperature");
        touchPosition = new Vector3(0, 0, 0);

        //Restore Cube Positions
        iceObj = GameObject.Find("Cube0");

        iceObj.transform.position = new Vector3(tossOri[0], tossOri[1], tossOri[2]);
        iceObj.transform.rotation = new Quaternion(MainGameLoop.tossOri[3],
                                                   MainGameLoop.tossOri[4],
                                                   MainGameLoop.tossOri[5],
                                                   MainGameLoop.tossOri[6]);

        MainGameLoop.iceObj.GetComponent <Rigidbody>().isKinematic = true;
        MainGameLoop.iceObj.GetComponent <Rigidbody>().useGravity  = false;
        MainGameLoop.iceObj.GetComponent <Rigidbody>().velocity    = new Vector3(0, 0, 0);
        //Restore camera and enable options.
        camera1 = GameObject.Find("Main Camera");
        camera2 = GameObject.Find("gameOverCamera");
        camera2.SetActive(false);

        // TODO: documentation for recovering the original size for all.
        // disabling other cube's from melting.
        GameObject currObj = null;

        for (int i = 0; i < 15; i++)
        {
            currObj = GameObject.Find("Cube" + i.ToString());
            currObj.transform.localScale = originalSize;
            currObj.GetComponent <IceCubeScale>().enabled = false;
        }
        currObj = GameObject.Find("Cube" + 0);
        IceCubeScale a = currObj.GetComponent <IceCubeScale>();

        a.enabled = true;
    }
예제 #2
0
    public void ContinueGame()
    {
        Time.timeScale = 1;
        if (IceCubeScript.timerStarted == true)
        {
            IceCubeScript.timer.Start();
        }

        IceScale         = iceObj.GetComponent <IceCubeScale>();
        IceScale.enabled = true;

        //enable the scripts again

        //CubeScript = iceObj.GetComponent<IceCubeScript>();

        //CubeScript.enabled = true;
    }
예제 #3
0
    public void PauseGame()
    {
        Time.timeScale = 0;
        if (IceCubeScript.timerStarted == true)
        {
            IceCubeScript.timer.Stop();
        }


        // disable the scale function
        IceScale         = iceObj.GetComponent <IceCubeScale>();
        IceScale.enabled = false;

        // disble iceObj script as well

        //CubeScript = iceObj.GetComponent<IceCubeScript>();

        //CubeScript.enabled = false;
    }