void OnMouseDown() { //Check to see if the command is to press the button (rCommand == 0) //send command tapped to the Console_Text_Script mastermindScript.TappedWaitForSecondsOrTap(rCommand); anim.Play("Button_Press_Anim"); }
void OnMouseDown() { //Check to see if the command is to pull the L_Lever (rCommand == 1) //send command tapped to the Console_Text_Script mastermindScript.TappedWaitForSecondsOrTap(Mastermind_Script.lLeverCommand); if (isLLeverUp) { anim.Play("L_Lever_Down_Anim"); isLLeverUp = false; } else { anim.Play("L_Lever_Up_Anim"); isLLeverUp = true; } }
private void Update() { //snap lever into place near edges (on = transform.eulerAngles.x == 0; off = transform.eulerAngles.x == 45) if (transform.eulerAngles.x < 1.5) { transform.eulerAngles = new Vector3( 0, transform.eulerAngles.y, transform.eulerAngles.z ); //If the last position of the handle was in the middle, and now we are at the up position, then send the command that the L_Lever is now Up if (lastHandlePosition == middlePosition) { //send command tapped to the Console_Text_Script with the lLeverUpCommand int rCommandUp = (rCommand * 100) + 1; mastermindScript.TappedWaitForSecondsOrTap(rCommandUp); //Lever changed positions isLLeverUp = true; } //update last handle position lastHandlePosition = upPosition; } else if (transform.eulerAngles.x > 43.5) { transform.eulerAngles = new Vector3( 45, transform.eulerAngles.y, transform.eulerAngles.z ); //If the last position of the handle was in the middle, and now we are at the down position, then send the command that the L_Lever is now Down if (lastHandlePosition == middlePosition) { //send command tapped to the Console_Text_Script with the lLeverDownCommand int rCommandDown = (rCommand * 100) + 2; mastermindScript.TappedWaitForSecondsOrTap(rCommandDown); //Lever changed positions isLLeverUp = false; } //update last handle position lastHandlePosition = downPosition; } else { lastHandlePosition = middlePosition; } //push lever in direction to go towards edges if (transform.eulerAngles.x < 22.5) { JointMotor motor = m_HingeJoint.motor; motor.targetVelocity = 20; m_HingeJoint.motor = motor; } else { JointMotor motor = m_HingeJoint.motor; motor.targetVelocity = -20; m_HingeJoint.motor = motor; } }