void OnEnable()
    {
        solveState = puzzleState.inProgress;

        //Get the current state of the Laser Countdown Timer (to hold as a variable to return to later),
        //then deactivate it while the player tries to solve the puzzle
        isTimerActive           = LevelManager.timerState.ToString();
        LevelManager.timerState = LevelManager.TimerOn.timerDeactivated;

        if (puzzleChoice == whichPuzzle.glassCutter)
        {
            if (glassPuzz == null)
            {
                glassPuzz = gameObject.AddComponent <Puzzle_GlassCutter>();
            }
            else
            {
                glassPuzz.enabled = true;
            }
        }
        else if (puzzleChoice == whichPuzzle.pressurePlate)
        {
            //gameObject.GetComponent<Puzzle_PressurePlate> ().enabled = true;
        }
    }
示例#2
0
    void Update()
    {
        if (puzzState == puzzleState.cutting)
        {
            Cutting();
        }
        else if (puzzState == puzzleState.solved)
        {
            GlassWin();
        }
        else if (puzzState == puzzleState.failed)
        {
            GlassFail();
        }
        else if (puzzState == puzzleState.unsolved)
        {
            GlassUnsolved();
        }

        //Leave the puzzle "unsolved" for now, and allow the player to return later (DO NOT DESTROY EVERYTHING)
        if (Input.GetKeyDown(KeyCode.Q))
        {
            puzzState = puzzleState.unsolved;
        }
    }
示例#3
0
    void OnEnable()
    {
        puzzState = puzzleState.cutting;

        //if (mainCam != null && glassCam != null) {
        mainCam.enabled  = false;
        glassCam.enabled = true;
        //}
    }
示例#4
0
    void Cutting()
    {
        if (glassCamEmpty.GetComponent <Camera> () != null && Input.mousePosition != null)
        {
            Ray        cutter = glassCamEmpty.GetComponent <Camera> ().ScreenPointToRay(Input.mousePosition);
            RaycastHit cutHit;

            if (Physics.Raycast(cutter, out cutHit, 10))
            {
                print(cutHit.collider.gameObject.name);
                if (cutHit.collider.gameObject.name == "GlassLine")
                {
                    cutTimer -= 1.0f * Time.deltaTime;

                    if (cutTimer <= 0.0f)
                    {
                        cutHit.collider.gameObject.GetComponent <MeshRenderer> ().material.color = Color.blue;
                        lineSegments.Remove(cutHit.collider.gameObject);
                        cutSegments.Add(cutHit.collider.gameObject);
                        cutHit.collider.gameObject.name = "CutLine";
                    }
                }
                else if (cutHit.collider.gameObject.name == "CutLine")
                {
                    cutTimer -= 1.0f * Time.deltaTime;
                    if (cutTimer < crackTimer)
                    {
                        cutSegments.Remove(cutHit.collider.gameObject);
                        crackedSegments.Add(cutHit.collider.gameObject);
                    }
                }

                if (crackedSegments.Count > 0)
                {
                    print("You fail");
                    puzzState = puzzleState.failed;
                }
                else if (cutSegments.Count == lineNum && crackedSegments.Count == 0)
                {
                    print("You win");
                    puzzState = puzzleState.solved;
                }
            }
            else
            {
                cutTimer = 0.5f;
            }
        }
    }
示例#5
0
 void GlassFail()
 {
     if (timesFailed < 2)
     {
         print("Puzzle FAILED! Press SPACE TO RETRY");
         if (Input.GetKeyDown(KeyCode.Space))
         {
             timesFailed++;
             DestroyLines();
             ResetLines();
             puzzState = puzzleState.cutting;
         }
     }
     else if (timesFailed >= 2)
     {
         DestroyLines();
         Destroy(glass);
         mainCam.enabled    = true;
         puzzMan.solveState = PuzzleManager.puzzleState.failed;
         Destroy(this);
     }
 }