コード例 #1
0
    void Update()
    {
        totalTimePlaying += Time.deltaTime;

        if (distractionTimer <= 0.0f)
        {
            totalTimeDistracted += Time.deltaTime;

            if (!clickingCounts)
            {
                clickingCounts  = true;
                clicks.myClicks = 0;
            }
            //pause the game
            gamePaused = true;

            //if setting to dark
            if (setDark)
            {
                cameraControl.vignette += Time.deltaTime;
                if (cameraControl.vignette >= 3.0f)
                {
                    setDark = false;
                }
            }
            else
            {
                if (clicks.myClicks >= 15)
                {
                    cameraControl.vignette -= Time.deltaTime;
                    if (cameraControl.vignette <= 0.0f)
                    {
                        cameraControl.vignette = 0.0f;
                        SetDistractionTime();
                        gamePaused      = false;
                        clicks.myClicks = 0;
                    }
                }
            }
        }
        else if (!gameComplete && !myBook.active)
        {
            distractionTimer -= Time.deltaTime;
        }
        else if (gameComplete)
        {
            Feedback feedback = GameObject.FindGameObjectWithTag("FeedbackSystem").GetComponent <Feedback>();
            if (feedback)
            {
                feedback.AddChallengeTime(totalTimePlaying);
                feedback.AddTimeDistracted(totalTimeDistracted);
                feedback.SetOverallScore(myScore.score);
            }
            Application.LoadLevel("Alpha_Home_outside");
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        totalTimePlaying += Time.deltaTime;

        //pressing space closes the menu and puts the highlighter off screen
        if (Input.GetKeyDown(KeyCode.Space))
        {
            menuUp = false;
            Highlighter.transform.position = new Vector3(0, -7.0f, 0);
        }
        //this large if statement decides which books are meant to be up. Sorry about the mess, I got stuck.
        //if the menu isn't up
        if (menuUp == false)
        {
            //by default the books shouldn't be seen
            BookSprite1.GetComponent <Renderer>().enabled = false;
            BookSprite2.GetComponent <Renderer>().enabled = false;
            BookSprite3.GetComponent <Renderer>().enabled = false;
            BookSprite4.GetComponent <Renderer>().enabled = false;
            BookSprite5.GetComponent <Renderer>().enabled = false;
            //if the book has been returned then don't show the book.
            if (bookReturned[1] == true)
            {
                BookSprite1.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite1.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[2] == true)
            {
                BookSprite2.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite2.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[3] == true)
            {
                BookSprite3.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite3.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[4] == true)
            {
                BookSprite4.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite4.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[5] == true)
            {
                BookSprite5.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite5.GetComponent <Renderer>().enabled = true;
            }
        }
        else
        {
            //if the meny is up then the books are up by default
            BookSprite1.GetComponent <Renderer>().enabled = true;
            BookSprite2.GetComponent <Renderer>().enabled = true;
            BookSprite3.GetComponent <Renderer>().enabled = true;
            BookSprite4.GetComponent <Renderer>().enabled = true;
            BookSprite5.GetComponent <Renderer>().enabled = true;
            //If the book has been returned then it shouldn't show up.
            if (bookReturned[1] == true)
            {
                BookSprite1.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite1.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[2] == true)
            {
                BookSprite2.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite2.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[3] == true)
            {
                BookSprite3.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite3.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[4] == true)
            {
                BookSprite4.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite4.GetComponent <Renderer>().enabled = true;
            }

            if (bookReturned[5] == true)
            {
                BookSprite5.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                BookSprite5.GetComponent <Renderer>().enabled = true;
            }
        }

        //if books have been returned then set them to returned
        if (Shelf0.GetComponent <ReturnReturnedBook>().returned == true)
        {
            bookReturned[1] = true;
        }
        if (Shelf1.GetComponent <ReturnReturnedBook>().returned == true)
        {
            bookReturned[2] = true;
        }
        if (Shelf2.GetComponent <ReturnReturnedBook>().returned == true)
        {
            bookReturned[3] = true;
        }
        if (Shelf3.GetComponent <ReturnReturnedBook>().returned == true)
        {
            bookReturned[4] = true;
        }
        if (Shelf4.GetComponent <ReturnReturnedBook>().returned == true)
        {
            bookReturned[5] = true;
        }

        //game over state
        gameOver = true;
        if (bookReturned[1] == false || bookReturned[2] == false && bookReturned[3] == false || bookReturned[4] == false || bookReturned[5] == false)
        {
            gameOver = false;
        }

        if (gameOver == true)
        {
            Feedback feedback = ScoreKeeper.GetComponent <Feedback>();
            if (feedback)
            {
                feedback.AddChallengeTime(totalTimePlaying);
                feedback.AddTimeDistracted(totalTimeDistracted);
                feedback.SetOverallScore((score * 5));
            }
            Application.LoadLevel("Alpha_Home_outside");
        }



        //display score
        ScoreDisplay.text = "score : " + score;
    }