コード例 #1
0
ファイル: OfficePlayer.cs プロジェクト: se-mendheim/Escape
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("MainDoor"))
        {
            // if the player has the gun
            if (hasGun)
            {
                // make the screen go black for dramatic effect
                OfficeManager._instance.FadeOut();

                // play the gunshot sound
                OfficeAudio.PlaySound("gunshot");

                // open up the main door
                OfficeManager._instance.OpenMainDoor();

                // send message to the player
                OfficeManager._instance.messageText.text = "Escaped the office building";
                OfficeManager._instance.ShowHint();

                // end the game
                OfficeManager._instance.EndGame();
            }

            else
            {
                // send message to the user
                OfficeManager._instance.messageText.text = "There are chains holding the door together...";
                OfficeManager._instance.ShowHint();
            }
        }
    }
コード例 #2
0
 public void UpElevator()
 {
     if (player.transform.position.y < 5)
     {
         // play the sound of going up the elevator
         OfficeAudio.PlaySound("elevator");
         // fade the screen black
         FadeOut();
         // move the player upwards
         player.transform.position = new Vector2(player.transform.position.x, player.transform.position.y + 12);
     }
     else
     {
         // if the ceo office has been unlocked
         if (ceoOffice)
         {
             // play the sound of going up the elevator
             OfficeAudio.PlaySound("elevator");
             // fade the screen black
             FadeOut();
             // move the player up
             player.transform.position = new Vector2(player.transform.position.x, player.transform.position.y + 12);
         }
         else
         {
             // send a message to the user
             messageText.text = "Can't get to that floor with the elevator buttons...";
             ShowHint();
         }
     }
 }
コード例 #3
0
 public void DisplayPrinter()
 {
     // turning on the printer sound
     OfficeAudio.PlaySound("computer");
     // setting the canvas to true
     printer.enabled = true;
     // disable the players movement
     player.GetComponent <PlayerMovement>().enabled = false;
 }
コード例 #4
0
 public void DisplayBreakerBox()
 {
     // opening the breaker box sound
     OfficeAudio.PlaySound("breaker");
     // setting the canvas to true
     breakerBox.enabled = true;
     // disable the players movement
     player.GetComponent <PlayerMovement>().enabled = false;
 }
コード例 #5
0
 public void DownElevator()
 {
     if (player.transform.position.y > -20)
     {
         // play the sound of going up the elevator
         OfficeAudio.PlaySound("elevator");
         // fade the screen black
         FadeOut();
         // move the player down
         player.transform.position = new Vector2(player.transform.position.x, player.transform.position.y - 12);
     }
 }
コード例 #6
0
    public void AddLetter(string letter)
    {
        // add a letter to the printer
        OfficeAudio.PlaySound("lightswitch");

        if (codeValue.Equals("ERROR"))
        {
            codeValue = "";
        }
        if (!computerOn)
        {
            codeValue += letter;
        }
    }
コード例 #7
0
 public void VendingButtonDown(string number)
 {
     // play the lightswitch sound
     OfficeAudio.PlaySound("lightswitch");
     // if it is equal to ERROR
     if (vendingValue.Equals("ERROR"))
     {
         // reset the value
         vendingValue = "";
     }
     if (!ceoOffice)
     {
         // add the integer to the number
         vendingValue += number;
     }
 }
コード例 #8
0
 public void DisplayComputer()
 {
     if (computerOn)
     {
         // turning on the computer sound
         OfficeAudio.PlaySound("computer");
         // setting the canvas to true
         computer.enabled = true;
         // removing controls from the player
         player.GetComponent <PlayerMovement>().enabled = false;
         // activating the computer script
         computer.GetComponent <ComputerScript>().enabled = true;
     }
     else
     {
         // show the hint to the player
         messageText.text = "This computer needs to be unlocked";
         ShowHint();
     }
 }
コード例 #9
0
ファイル: OfficePlayer.cs プロジェクト: se-mendheim/Escape
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Door"))
        {
            if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
            {
                // go up the elevator
                OfficeManager._instance.UpElevator();
            }
            else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
            {
                // go down the elevator
                OfficeManager._instance.DownElevator();
            }
        }
        else if (collision.gameObject.CompareTag("Power"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // if the player has the key
                if (hasKey == true)
                {
                    // display the breaker box to the user
                    OfficeManager._instance.DisplayBreakerBox();
                }
                else
                {
                    // send a message to the screen
                    OfficeManager._instance.messageText.text = "Need a key to open the breaker box...";
                    OfficeManager._instance.ShowHint();
                }
            }
        }

        else if (collision.gameObject.CompareTag("OfficeWire"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // if the player doesnt have the key
                if (!hasKey)
                {
                    // play the sound of picking up the key
                    OfficeAudio.PlaySound("item");

                    // change the inventory
                    OfficeManager._instance.ChangeInventory("key");

                    // the user now has a key
                    hasKey = true;

                    // send emssage to screen
                    OfficeManager._instance.messageText.text = "Aquired a key...";
                    OfficeManager._instance.ShowHint();
                }
            }
        }

        else if (collision.gameObject.CompareTag("USBPlant"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // if the user does not have the USB
                if (!OfficeManager._instance.hasUSB)
                {
                    // play the sound of picking up the USB
                    OfficeAudio.PlaySound("item");

                    // change the inventory
                    OfficeManager._instance.ChangeInventory("USB");

                    // set the hasUSB bool
                    OfficeManager._instance.HasUSB();

                    // display message to the user
                    OfficeManager._instance.messageText.text = "Aquired a USB...";
                    OfficeManager._instance.ShowHint();
                }
            }
        }

        else if (collision.gameObject.CompareTag("Printer"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // display the printer to the screen
                OfficeManager._instance.DisplayPrinter();
            }
        }

        else if (collision.gameObject.CompareTag("Vending Machine"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // display the vending machine to the screen
                OfficeManager._instance.DisplayVendingMachine();
            }
        }

        else if (collision.gameObject.CompareTag("GunDesk"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // picking up item sound
                OfficeAudio.PlaySound("item");

                // the player now has a gun
                hasGun = true;

                // change the inventory to have a gun
                OfficeManager._instance.ChangeInventory("gun");

                // send message to the user
                OfficeManager._instance.messageText.text = "Picked up a gun?...";
                OfficeManager._instance.ShowHint();
            }
        }

        else if (collision.gameObject.CompareTag("Computer 2"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // display the computer to the screen
                OfficeManager._instance.DisplayComputer();
            }
        }

        else if (collision.gameObject.CompareTag("WaterCooler"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // send message to the user
                OfficeManager._instance.messageText.text = "The water looks disgusting...";
                OfficeManager._instance.ShowHint();
            }
        }

        else if (collision.gameObject.CompareTag("Computer 1"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // send message to the user
                OfficeManager._instance.messageText.text = "The computer seems to be dead...";
                OfficeManager._instance.ShowHint();
            }
        }

        else if (collision.gameObject.CompareTag("Couch"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // send message to the user
                OfficeManager._instance.messageText.text = "Nothing but dust in the couch...";
                OfficeManager._instance.ShowHint();
            }
        }

        else if (collision.gameObject.CompareTag("empty"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // send message to the user
                OfficeManager._instance.messageText.text = "Drawers were empty...";
                OfficeManager._instance.ShowHint();
            }
        }

        else if (collision.gameObject.CompareTag("Shelf"))
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                // send message to the user
                OfficeManager._instance.messageText.text = "The shelves are empty...";
                OfficeManager._instance.ShowHint();
            }
        }
    }
コード例 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time - lastTime >= 1)
        {
            lastTime = Time.time;
            timeCount++;
            timerText.text = "Time: " + timeCount;
        }
        // setting the text on the printer UI and vending UI
        codeText.text    = codeValue;
        vendingText.text = vendingValue;

        if (codeValue.Equals("FSPSC"))
        {
            // if the user correct inputs the code
            computerOn = true;
            codeValue  = "PC Unlocked";
        }
        if (codeValue.Length >= 6 && !computerOn)
        {
            // otherwise display error
            OfficeAudio.PlaySound("ERROR");
            codeValue = "ERROR";
        }

        if (vendingValue.Equals("736945"))
        {
            // if the user correclty inputs the code
            ceoOffice    = true;
            vendingValue = "Floor Unlocked";
        }
        if (vendingValue.Length >= 7 && !ceoOffice)
        {
            // otherwise display error
            OfficeAudio.PlaySound("ERROR");
            vendingValue = "ERROR";
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            if (openInv == false && !computer.enabled)
            {
                // give the player back their controls
                player.GetComponent <PlayerMovement>().enabled = false;
                // open the inventory
                inventoryCanvas.GetComponent <Canvas>().enabled = true;
                // inventory is now open
                openInv = true;
            }

            else
            {
                // give the player back their controls
                player.GetComponent <PlayerMovement>().enabled = true;
                // close the inventory
                inventoryCanvas.GetComponent <Canvas>().enabled = false;
                // inventory is now closed
                openInv = false;
            }
        }
    }
コード例 #11
0
    public void ButtonDown()
    {
        // lightswitch sound
        OfficeAudio.PlaySound("lightswitch");


        // very complicated way to turn off and on the lights with buttons
        switch (EventSystem.current.currentSelectedGameObject.name)
        {
        case "L1 On":
            // get all the game objects with this tag
            GameObject[] L1On = GameObject.FindGameObjectsWithTag("L1");
            foreach (GameObject light in L1On)
            {
                // set all of the lights in that list to on/off
                light.transform.GetChild(0).gameObject.SetActive(true);
            }
            // hint lights used for the password to the computer
            FLight.SetActive(false);
            SLight1.SetActive(false);

            break;

        case "L1 Off":
            // get all the game objects with this tag
            GameObject[] L1Off = GameObject.FindGameObjectsWithTag("L1");
            foreach (GameObject light in L1Off)
            {
                // set all of the lights in that list to on/off
                light.transform.GetChild(0).gameObject.SetActive(false);
            }
            // hint lights used for the password to the computer
            FLight.SetActive(true);
            SLight1.SetActive(true);

            break;

        case "L2 On":
            // get all the game objects with this tag
            GameObject[] L2On = GameObject.FindGameObjectsWithTag("L2");
            foreach (GameObject light in L2On)
            {
                // set all of the lights in that list to on/off
                light.transform.GetChild(0).gameObject.SetActive(true);
            }
            // hint lights used for the password to the computer
            PLight.SetActive(false);
            SLight2.SetActive(false);

            break;

        case "L2 Off":
            // get all the game objects with this tag
            GameObject[] L2Off = GameObject.FindGameObjectsWithTag("L2");
            foreach (GameObject light in L2Off)
            {
                // set all of the lights in that list to on/off
                light.transform.GetChild(0).gameObject.SetActive(false);
            }
            // hint lights used for the password to the computer
            PLight.SetActive(true);
            SLight2.SetActive(true);

            break;

        case "L3 On":
            // get all the game objects with this tag
            GameObject[] L3On = GameObject.FindGameObjectsWithTag("L3");
            foreach (GameObject light in L3On)
            {
                // set all of the lights in that list to on/off
                light.transform.GetChild(0).gameObject.SetActive(true);
            }
            // hint lights used for the password to the computer
            CLight.SetActive(false);

            break;

        case "L3 Off":
            // get all the game objects with this tag
            GameObject[] L3Off = GameObject.FindGameObjectsWithTag("L3");
            foreach (GameObject light in L3Off)
            {
                // set all of the lights in that list to on/off
                light.transform.GetChild(0).gameObject.SetActive(false);
            }
            // hint lights used for the password to the computer
            CLight.SetActive(true);

            break;
        }
    }