Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Intro_Scritping/Test_CYOA/Assets/Scripts/Puzzle_231.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
118 lines (106 sloc)
3.31 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Puzzle_231 : MonoBehaviour { | |
//Mouse-Camera Controlls | |
public Ray ray; | |
public RaycastHit hit; | |
public GameObject button1; | |
public GameObject button2; | |
public GameObject button3; | |
public GameObject wall; | |
//Counters | |
public int first = 0; | |
public int second = 0; | |
public int third = 0; | |
public int total = 0; | |
// Update is called once per frame | |
void Update () { | |
ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
total = first + second + third; | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Switch2") | |
{ | |
second = 1; | |
} | |
//Switch Statment - Correct Order | |
switch (total) | |
{ | |
case 1: | |
if (hit.transform.name == "Switch3") | |
{ | |
third = 1; | |
} | |
break; | |
case 2: | |
if (hit.transform.name == "Switch1") | |
{ | |
first = 1; | |
} | |
break; | |
} | |
//Switch Statement - False Order - Double 2's | |
switch (total) | |
{ | |
case 1: | |
if (hit.transform.name == "Switch2") | |
{ | |
first = 0; | |
second = 0; | |
third = 0; | |
} | |
break; | |
case 2: | |
if (hit.transform.name == "Switch2") | |
{ | |
first = 0; | |
second = 0; | |
third = 0; | |
} | |
break; | |
} | |
//Switch Statement - False Order - Double 3's | |
switch (total) | |
{ | |
case 2: | |
if (hit.transform.name == "Switch3") | |
{ | |
first = 0; | |
second = 0; | |
third = 0; | |
} | |
break; | |
} | |
//Switch Statement - False Order - Stray 1's | |
switch (total) | |
{ | |
case 0: | |
if (hit.transform.name == "Switch1") | |
{ | |
first = 0; | |
second = 0; | |
third = 0; | |
} | |
break; | |
case 1: | |
if (hit.transform.name == "Switch1") | |
{ | |
first = 0; | |
second = 0; | |
third = 0; | |
} | |
break; | |
} | |
} | |
} | |
if (total == 3) | |
{ | |
Destroy(button1); | |
Destroy(button2); | |
Destroy(button3); | |
Destroy(wall); | |
} | |
} | |
} |