Skip to content
Permalink
dfa3314e63
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
119 lines (107 sloc) 3.35 KB
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)
{
Debug.Log("Puzzle Complete!");
Destroy(button1);
Destroy(button2);
Destroy(button3);
Destroy(wall);
}
}
}