示例#1
0
文件: Game.cs 项目: Mubir/GanBaba
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel("Sublevel");
        }

        number = (int)Time.time;
        if (number > 19)
        {
            number = 19;
        }

        if (question_finished == 1)
        {
            GameObject_Slash.SetActive(false);
            return;
        }
        PresentTime = (int)(Time.time) - PasttTime;
        minute      = (int)PresentTime / 60;
        seconds     = (int)PresentTime % 60;
        if (selected_option_on == 0)
        {
            _destroyFire destroyFire = GameObject_Slash.GetComponent <_destroyFire>();
            selected_option = destroyFire.option;
        }
        if (selected_option > 0 && selected_option_on == 0)
        {
            temp = selected_option_on;

            selected_option_on = 1;
            Debug.Log("selected_option_on ==" + selected_option_on);
            selected_option_time = (int)PresentTime + .6;
            _destroyFire destroyFire1 = GameObject_Slash.GetComponent <_destroyFire>();
            destroyFire1.option = 0;



            for (int i = 1; i <= 4; i++)
            {
                GameObject_option[i].rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionZ;
            }
        }
        if (selected_option > 0 && temp == 0)
        {
            GameObject_Slash.transform.position = new Vector3(0f, 0f, -90f);
            GameObject_Slash.SetActive(false);

            //for vanishing sprite & text begin
            if (selected_option == 1)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text1");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option1");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }

            else if (selected_option == 2)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text2");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option2");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }
            else if (selected_option == 3)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text3");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option3");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }
            else if (selected_option == 4)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text4");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option4");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }
            //for vanishing sprite & text end

            if ((selected_option_time + .35) < PresentTime)
            {
                tempobjT.GetComponent <TextMesh>().renderer.enabled = true;
                tempobjS.GetComponent <SpriteRenderer>().enabled    = true;

                checkQuestion();
                temp = 1;
            }
        }
        if (selected_option_on == 1 && (selected_option_time - .3) < (PresentTime))
        {
            for (int i = 1; i <= 4; i++)
            {
                //GameObject_option[i].SetActive(true);

                GameObject_option[i].rigidbody.constraints &= ~RigidbodyConstraints.FreezePositionX;
                GameObject_option[i].rigidbody.constraints &= ~RigidbodyConstraints.FreezePositionY;

                GameObject_option[i].rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionZ;
            }
        }
        if (selected_option_on == 1 && (selected_option_time + .5) < (PresentTime))
        {
            selected_option_on = 0;
            answercorrect      = -9;
            GameObject_Slash.SetActive(true);
        }
        if (question_finished == 1)
        {
            for (int i = 1; i <= 4; i++)
            {
                GameObject_option[i].rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionZ;
            }

            Debug.Log("Score in " + loadedLevel + " is " + PlayerPrefs.GetInt(loadedLevel));
        }

        //	Debug.Log ("selected_option_time  :"+selected_option_time+"PresentTime  :"+PresentTime );
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel("Sublevel");
        }
        if (question_finished == 1)
        {
            GameObject_Slash.SetActive(false);
            return;
        }
        PresentTime = (int)(Time.time) - PasttTime;
        minute      = PresentTime / 60;
        seconds     = PresentTime % 60;
        if (PresentTime == 60)
        {
            question_finished = 1;
            scores_update();
            return;
        }
        if (selected_option_on == 0)
        {
            _destroyFire destroyFire = GameObject_Slash.GetComponent <_destroyFire>();
            selected_option = destroyFire.option;
        }
        if (selected_option > 0 && selected_option_on == 0)
        {
            //Slash.SetActive(false);
            temp = selected_option_on;
            selected_option_on   = 1;
            selected_option_time = PresentTime + 1;
            _destroyFire destroyFire1 = GameObject_Slash.GetComponent <_destroyFire>();
            destroyFire1.option = 0;


            checkQuestion();


            for (int i = 1; i <= 4; i++)
            {
                //GameObject_option[i].rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY;

                GameObject_option[i].rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionZ;
                //GameObject_option[i].SetActive(false);
            }
        }

        if (selected_option > 0 && temp == 0)
        {
            //for vanishing sprite & text begin
            if (selected_option == 1)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text1");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option1");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }

            else if (selected_option == 2)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text2");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option2");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }
            else if (selected_option == 3)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text3");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option3");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }
            else if (selected_option == 4)
            {
                tempobjT = GameObject.FindGameObjectWithTag("text4");
                tempobjT.GetComponent <TextMesh>().renderer.enabled = false;
                tempobjS = GameObject.FindGameObjectWithTag("Option4");
                tempobjS.GetComponent <SpriteRenderer>().enabled = false;
            }

            if (selected_option_time < PresentTime)
            {
                tempobjT.GetComponent <TextMesh>().renderer.enabled = true;
                tempobjS.GetComponent <SpriteRenderer>().enabled    = true;

                checkQuestion();
                temp = 1;
            }
        }



        if (selected_option_on == 1 && selected_option_time < PresentTime)
        {
            //Slash.SetActive(true);
            selected_option_on = 0;
            answercorrect      = -9;
            for (int i = 1; i <= 4; i++)
            {
                GameObject_option[i].rigidbody.constraints &= ~RigidbodyConstraints.FreezePositionX;
                GameObject_option[i].rigidbody.constraints &= ~RigidbodyConstraints.FreezePositionY;

                GameObject_option[i].rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezePositionZ;


                /*GameObject_option[i].rigidbody. constraints = RigidbodyConstraints.None;
                 * GameObject_option[i].rigidbody.freezeRotation =true;
                 * _optionMovement optionMovement=GameObject_option[i].GetComponent<_optionMovement>();
                 * optionMovement.initiate();
                 *
                 * GameObject_option[i].SetActive(true);
                 *
                 * //GameObject_option[i].rigidbody.constraints &=~ RigidbodyConstraints.FreezePositionZ ;*/
            }
        }
    }