Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            if (CurrentRoom == 2)
            {
                CurrentRoom        = 3;
                transform.position = RoomCoords[CurrentRoom - 1];
                Play();
            }
        }
        else if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            if (CurrentRoom == 3)
            {
                CurrentRoom        = 2;
                transform.position = RoomCoords[CurrentRoom - 1];
                Play();
            }
            else if (CurrentRoom == 2)
            {
                CurrentRoom        = 1;
                transform.position = RoomCoords[CurrentRoom - 1];
                Play();
            }
        }
        else if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            if (CurrentRoom == 1)
            {
                if (completable == true)
                {
                    Vector3 FinalCredits = new Vector3(-13.568f, 0, -10);
                    transform.position = FinalCredits;
                }
            }
        }

        //Check if youre able to win the game
        else if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            if (CurrentRoom == 1)
            {
                GameObject[] Circuits;
                bool         tempCheck = true;
                Circuits = GameObject.FindGameObjectsWithTag("Circuit");
                foreach (GameObject CircuitObj in Circuits)
                {
                    Circuit tempCircuit = CircuitObj.GetComponent <Circuit>();
                    if (tempCircuit.isComplete == false)
                    {
                        tempCheck = false;
                    }
                }
                if (tempCheck == true)
                {
                    CurrentRoom        = 2;
                    transform.position = RoomCoords[CurrentRoom - 1];
                }
                Play();
            }
        }
    }
Example #2
0
    public void TriggerPill()
    {
        GameObject Doors;

        Doors = GameObject.FindGameObjectWithTag("MainCamera");
        Door tempDoor = Doors.GetComponent <Door>();

        GameObject[] Pills;
        if (count == 0)
        {
            GameObject[] redObjects;
            redObjects = GameObject.FindGameObjectsWithTag("RedObjects");
            foreach (GameObject RedObjects in redObjects)
            {
                SpriteRenderer redObjectsRenderer = RedObjects.GetComponent <SpriteRenderer>();
                redObjectsRenderer.enabled = true;
            }
            count++;
        }
        else if (count == 1 && tempDoor.CurrentRoom == 3)
        {
            GameObject[] BluePills;
            BluePills = GameObject.FindGameObjectsWithTag("BluePill");
            foreach (GameObject BluePillObjs in BluePills)
            {
                SpriteRenderer BluePillRenderer = BluePillObjs.GetComponent <SpriteRenderer>();
                BluePillRenderer.enabled = false;
            }
            GameObject[] BluePills2;
            BluePills2 = GameObject.FindGameObjectsWithTag("BluePill2");
            foreach (GameObject BluePill2Objs in BluePills2)
            {
                SpriteRenderer BluePill2Renderer = BluePill2Objs.GetComponent <SpriteRenderer>();
                BluePill2Renderer.enabled = false;
            }
            GameObject[] blueObjects;
            blueObjects = GameObject.FindGameObjectsWithTag("BlueObjects");
            foreach (GameObject BlueObjects in blueObjects)
            {
                SpriteRenderer blueObjectsRenderer = BlueObjects.GetComponent <SpriteRenderer>();
                blueObjectsRenderer.enabled = true;
            }
            count++;
        }
        else if (count == 2 && tempDoor.CurrentRoom == 2)
        {
            GameObject[] GreenPills;
            GreenPills = GameObject.FindGameObjectsWithTag("GreenPill");
            foreach (GameObject GreenPillObjs in GreenPills)
            {
                SpriteRenderer GreenPillRenderer = GreenPillObjs.GetComponent <SpriteRenderer>();
                GreenPillRenderer.enabled = false;
            }
            GameObject[] greenObjects;
            greenObjects = GameObject.FindGameObjectsWithTag("GreenObjects");
            foreach (GameObject GreenObjects in greenObjects)
            {
                SpriteRenderer greenObjectsRenderer = GreenObjects.GetComponent <SpriteRenderer>();
                greenObjectsRenderer.enabled = true;
            }
            count++;
        }
        Pills = GameObject.FindGameObjectsWithTag("Pill");
        foreach (GameObject PillInstance in Pills)
        {
            SpriteRenderer PillRenderer = PillInstance.GetComponent <SpriteRenderer>();
            PillRenderer.enabled = false;
        }
        GameObject[] Circuits;
        Circuits = GameObject.FindGameObjectsWithTag("Circuit");
        foreach (GameObject CircuitObj in Circuits)
        {
            Circuit tempCircuit = CircuitObj.GetComponent <Circuit>();
            if (tempCircuit.isComplete == false)
            {
                tempCircuit.isEnabled = true;
            }
        }
    }