//When the level is won, the HighScoreCanvas is the only UI element visible
 public void YouWinScreen()
 {
     HighScoreCanvas.SetActive(true);
     hs.HighScoreUpdate();
     cs.Grid.SetActive(false);
     cs.GameCanvas.SetActive(false);
     gs.GetComponent <WinDetect>().enabled = false;
 }
    public void RotateCommandRight()
    {
        //Getting access to the ComandSelect global variables which are attached to the PlayterTerminalObject
        cs = GameObject.Find("PlayerTerminalObject").GetComponent <CommandSelect>();

        //When a pipe is magenta, the pipe is rotated clockwise of their original orientation
        if (selected)
        {
            if (this.RotationComponent.Rotation == RotationPipe.Rotations.NORTH)
            {
                this.RotationComponent.SetRotation(RotationPipe.Rotations.EAST);
            }

            else if (this.RotationComponent.Rotation == RotationPipe.Rotations.EAST)
            {
                this.RotationComponent.SetRotation(RotationPipe.Rotations.SOUTH);
            }
            else if (this.RotationComponent.Rotation == RotationPipe.Rotations.SOUTH)
            {
                this.RotationComponent.SetRotation(RotationPipe.Rotations.WEST);
            }
            else if (this.RotationComponent.Rotation == RotationPipe.Rotations.WEST)
            {
                this.RotationComponent.SetRotation(RotationPipe.Rotations.NORTH);
            }
            GameManager.Instance.SuccessCommands += 1;
            GameManager.Instance.TotalCommands   += 1;
            FindObjectOfType <AudioManager>().Play("R_Right");
        }
        //If no pipe is magenta and a command is passed, the FullSyntaxCommands and TotalCommands values increment by 1
        else
        {
            GameManager.Instance.FullSyntaxCommands += 1;
            GameManager.Instance.TotalCommands      += 1;
        }

        cs.TickDown();
        //When count becomes 0, the player loses the level and the lose screen is the only UI element visible
        if (cs.count == 0)
        {
            cs.loseScreen.SetActive(true);
            cs.GameCanvas.SetActive(false);
            GameObject.Find("Grid").SetActive(false);
            gs2.GetComponent <WinDetect>().enabled = false;
        }
    }
Beispiel #3
0
    //When Enter Button is selected, the console text is updated based on the syntax of the command and a pipe being selected
    public void EnterSelect()
    {
        if (inputText.text == "Waiting for command...")
        {
            consoleText.text = "No command is in the terminal";
            GameManager.Instance.FailCommands  += 1;
            GameManager.Instance.TotalCommands += 1;
            TickDown();
        }
        else if (command == "/s ")
        {
            consoleText.text = "This command could not be recognized.";
            inputText.text   = "Waiting for command...";
            SlideCommandsPanel.SetActive(false);
            SlideRotatePanel.SetActive(true);
            TickDown();
            GameManager.Instance.PartialSyntaxCommands += 1;
            GameManager.Instance.TotalCommands         += 1;
        }
        else if (command == "/r ")
        {
            consoleText.text = "This command could not be recognized.";
            inputText.text   = "Waiting for command...";
            RotateCommandsPanel.SetActive(false);
            SlideRotatePanel.SetActive(true);
            TickDown();
            GameManager.Instance.PartialSyntaxCommands += 1;
            GameManager.Instance.TotalCommands         += 1;
        }
        //If a pipe is magenta and the command in the terminal is "/r pipe left," the pipe is rotated
        else if (command == "/r pipe left")
        {
            Debug.Log("RotateLeft");
            pipe1.GetComponent <GamePipe>().RotateCommandLeft();
            inputText.text = "Waiting for command...";
            RotateCommandsPanel.SetActive(false);
            SlideRotatePanel.SetActive(true);
            if (GamePipe.pipeRenderer1.color == Color.magenta)
            {
                consoleText.text = "Pipe " + pipe1Name + " has been rotated left";
            }
            else if (GamePipe.pipeRenderer1.color == Color.white)
            {
                consoleText.text = "No pipe has been selected";
            }
        }
        else if (command == "/r pipe right")
        {
            Debug.Log("RotateRight");
            pipe1.GetComponent <GamePipe>().RotateCommandRight();
            inputText.text = "Waiting for command...";
            RotateCommandsPanel.SetActive(false);
            SlideRotatePanel.SetActive(true);
            if (GamePipe.pipeRenderer1.color == Color.magenta)
            {
                consoleText.text = "Pipe " + pipe1Name + " has been rotated right";
            }
            else if (GamePipe.pipeRenderer1.color == Color.white)
            {
                consoleText.text = "No pipe has been selected";
            }
        }
        //If a pipe is magenta, a collided pipe and grid boundary is not in the magenta pipe's path,
        //and the command is "/s pipe (direction) increment" then hhe pipe can be moved.
        else if (command == "/s pipe right " + increment)
        {
            Debug.Log("Slide Right");
            pipe1.GetComponent <GamePipe>().SlideCommandRight();
            increment      = 1;
            inputText.text = "Waiting for command...";
            bool isActive = true;
            if (SlideCommandsPanel.activeSelf == isActive)
            {
                SlideCommandsPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            else if (AddSubstractPanel.activeSelf == isActive)
            {
                AddSubstractPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }

            if (collideInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " has moved right";
                collideInput     = false;
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.white)
            {
                consoleText.text = "No pipe has been selected";
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.cyan && borderInput == false)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with " + "Pipe " + GamePipe.collidedPipe1.name;
            }
            else if (borderInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with the grid";
                borderInput      = false;
            }
        }
        else if (command == "/s pipe left " + increment)
        {
            Debug.Log("Slide Left");
            pipe1.GetComponent <GamePipe>().SlideCommandLeft();
            increment      = 1;
            inputText.text = "Waiting for command...";
            bool isActive = true;
            if (SlideCommandsPanel.activeSelf == isActive)
            {
                SlideCommandsPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            else if (AddSubstractPanel.activeSelf == isActive)
            {
                AddSubstractPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            if (collideInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " has moved left";
                collideInput     = false;
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.white)
            {
                consoleText.text = "No pipe has been selected";
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.cyan && borderInput == false)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with " + "Pipe " + GamePipe.collidedPipe1.name;
            }
            else if (borderInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with the grid";
                borderInput      = false;
            }
        }
        else if (command == "/s pipe up " + increment)
        {
            Debug.Log("Slide Up");
            pipe1.GetComponent <GamePipe>().SlideCommandUp();
            increment      = 1;
            inputText.text = "Waiting for command...";
            bool isActive = true;
            if (SlideCommandsPanel.activeSelf == isActive)
            {
                SlideCommandsPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            else if (AddSubstractPanel.activeSelf == isActive)
            {
                AddSubstractPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            if (collideInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " has moved up";
                collideInput     = false;
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.white)
            {
                consoleText.text = "No pipe has been selected";
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.cyan && borderInput == false)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with " + "Pipe " + GamePipe.collidedPipe1.name;
            }
            else if (borderInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with the grid";
                borderInput      = false;
            }
        }
        else if (command == "/s pipe down " + increment)
        {
            Debug.Log("Slide Down");
            pipe1.GetComponent <GamePipe>().SlideCommandDown();
            increment      = 1;
            inputText.text = "Waiting for command...";
            bool isActive = true;
            if (SlideCommandsPanel.activeSelf == isActive)
            {
                SlideCommandsPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            else if (AddSubstractPanel.activeSelf == isActive)
            {
                AddSubstractPanel.SetActive(!isActive);
                SlideRotatePanel.SetActive(isActive);
            }
            if (collideInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " has moved down";
                collideInput     = false;
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.white)
            {
                consoleText.text = "No pipe has been selected";
            }
            else if (collideInput == false && GamePipe.pipeRenderer1.color == Color.cyan && borderInput == false)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with " + "Pipe " + GamePipe.collidedPipe1.name;
            }
            else if (borderInput == true)
            {
                consoleText.text = "Pipe " + pipe1Name + " is colliding with the grid";
                borderInput      = false;
            }
        }

        if (count == 0)
        {
            loseScreen.SetActive(true);
            GameCanvas.SetActive(false);
            GameObject.Find("Grid").SetActive(false);
            gs2.GetComponent <WinDetect>().enabled = false;
        }
    }