コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        //timer -= Time.deltaTime;

        //UpdateText();

        if (timer <= 0)
        {
            UIStoryScript.TimeOut(); //time runs out and the game ends
            self.SetActive(false);   //turn myself off
            TimeOut = true;
        }
    }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        AudioSource Bark = gameObject.GetComponent <AudioSource>();

        Bark.Play();

        if (other.gameObject == FPPlayer)
        {
            //collect the dog
            GameManager.DogCaught = true;
            UIStoryScript.SuccessDogCatch();
            Timer.SetActive(false);
            self.SetActive(false); //turn off myself
        }
    }
コード例 #3
0
    public void OnTriggerEnter(Collider other)

    {
        print("I have collided " + other.gameObject.name);


        if (other.gameObject == ExitMorning)
        {
            //Leaving the house in the beginning
            ExitMorning.SetActive(false);
            EnterHome.SetActive(true);
        }

        if (other.gameObject == EnterHome)
        {
            //Enterhome pathways
            if (GameManager.HarriTalked == true || GameManager.WhistleFound == true)
            {
                //you just went back to bed you coward
                UIStoryScript.AbandonedTheMission();
            }

            if (GameManager.DogCaught == true)
            {
                if (UIStoryScript.IsOver == true)
                {
                    UIStoryScript.SuccessDogReturn();
                    UIStoryScript.IsOver = true;
                }
                else
                {
                    UIStoryScript.YouStole();
                }
            }
        }

        if (other.gameObject == EnterHarrisHome)
        {
            if (GameManager.HarriTalked == false)
            {
                UIStoryScript.EnterHarri1();
                Sadness.Play();

                GameManager.HarriTalked = true;
            }

            if (GameManager.DogCaught == true)
            {
                //congrats you did it
                UIStoryScript.SuccessDogReturn();
                Joy.Play();
                GameManager.DogReturned = true;
            }
        }

        if (other.gameObject == EnterStore)
        {
            //Store pathways
            if (GameManager.HarriTalked == true)
            {
                //get dog whistle

                GameManager.WhistleFound = true;
                UIStoryScript.EnterStore();
            }

            // if(GameManager.HarriTalked == false)
            // {
            //     //fail state

            // }
        }

        if (other.gameObject == EnterOtherHome)
        {
            //other home pathways
            if (GameManager.HarriTalked == true)
            {
                if (GameManager.WhistleFound == true)
                {
                    //why are you here?
                    UIStoryScript.EnterWrongHouse();
                }

                if (GameManager.WhistleFound == false)
                {
                    //I'm not the store
                    UIStoryScript.EnterWrongHouse();
                }
            }

            if (GameManager.HarriTalked == false)
            {
                //fail
                UIStoryScript.EnterWrongHouse();
            }
            if (GameManager.DogCaught == true)
            {
                UIStoryScript.WrongOwner();
            }
        }
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Space))
        {
            if (UIStoryScript.IsOver == true)
            {
                GameManager.GameComplete = true;
                GameManager.ResetEntireGame();

                //end the game
                Sc.ChangeScene();
            }
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (GameManager.WhistleFound == true && DogTimerScript.TimeOut == false) //if you have the whistle and the timer isn't over
            {
                //blow whistle
                Whistle.Play();             //plauy the whistle sound
                UIStoryScript.WhistleUse(); //change the text
                Timer.SetActive(true);      //start the timeer
                Dog.SetActive(true);        //release the hound
            }
        }
        //CameraLook(); //Move the camera based on mouse - moved this to it's own script because I was getting confused

        #region WASD Controller

        Vector3 ForwardDirection = transform.forward; //the player's relative forward
        Vector3 RightDirection   = transform.right;   //the players relative right
        Vector3 CurrentVelocity  = rb.velocity;       //the current velocity



        if (Input.GetKey(ForwardButton))
        {
            //rb.velocity = new Vector3 (0,0,MovementSpeed); //altering these because they don't account for rotation
            rb.velocity = ForwardDirection * MovementSpeed; //Move forward at the movement speed float
        }

        if (Input.GetKey(BackButton))
        {
            // rb.velocity = new Vector3 (0,0,-MovementSpeed);
            rb.velocity = ForwardDirection * -MovementSpeed;
        }

        if (Input.GetKey(StrafeLeft))
        {
            // rb.velocity = new Vector3 (MovementSpeed,0,0);
            rb.velocity = RightDirection * -MovementSpeed;
        }

        if (Input.GetKey(StrafeRight))
        {
            // rb.velocity = new Vector3 (-MovementSpeed,0,0);
            rb.velocity = RightDirection * MovementSpeed;
        }

        else if (Input.GetKeyUp(StrafeLeft) ||
                 Input.GetKeyUp(ForwardButton) ||
                 Input.GetKeyUp(StrafeRight) ||
                 Input.GetKeyUp(BackButton))
        {
            // if (Player.position.y <= 1){
            rb.velocity = new Vector3(0, 0, 0); // if no input from controls please stop

            // }
        }
        #endregion

        // #region jump Removing the jump, it isn't used ever
        // if (Input.GetKeyDown(JumpButton))
        // {
        //     rb.AddForce (new Vector3 (0, jumpForce, 0));
        //     print("I am jumping");
        // }
        // #endregion
    }