/// <summary> /// Upon the ball hitting the ground, the rigidbody becomes no longer /// kinematic, so it can become the largest domino /// </summary> /// <param name="theState">the current state of the machien</param> public override void receiveUpdate(rubeState theState) { if (theState == rubeState.dominoStart) { GetComponent <Rigidbody>().isKinematic = false; } }
/// <summary> /// Upon the ball hitting the ground, the rigidbody becomes no longer /// kinematic, so it can become the largest domino /// </summary> /// <param name="theState">the current state of the machien</param> public override void receiveUpdate(rubeState theState) { if(theState == rubeState.dominoStart) { GetComponent<Rigidbody>().isKinematic = false; } }
public override void receiveUpdate(rubeState theState) { if(theState == rubeState.targetDestroyed) { gameObject.GetComponent<Rigidbody>().useGravity = true; gameObject.GetComponent<Rigidbody>().isKinematic = false; gameObject.GetComponent<Rigidbody>().AddForce(0, 20, 20); } }
public override void receiveUpdate(rubeState theState) { if (theState == rubeState.targetDestroyed) { gameObject.GetComponent <Rigidbody>().useGravity = true; gameObject.GetComponent <Rigidbody>().isKinematic = false; gameObject.GetComponent <Rigidbody>().AddForce(0, 20, 20); } }
/// <summary> /// Implements the receive update for the catapult, applying a force to /// the end of the lever. This causes the payload to be launched. /// </summary> /// <param name="theState">the state passed by the manager</param> public override void receiveUpdate(rubeState theState) { if(theState == rubeState.catapultFired) { gameObject.GetComponent<Rigidbody>().AddForceAtPosition( new Vector3(15, -750, 0), transform.position + new Vector3(5,0,0)); Debug.Log("Firing!"); } }
/// <summary> /// Implements the receive update for the catapult, applying a force to /// the end of the lever. This causes the payload to be launched. /// </summary> /// <param name="theState">the state passed by the manager</param> public override void receiveUpdate(rubeState theState) { if (theState == rubeState.catapultFired) { gameObject.GetComponent <Rigidbody>().AddForceAtPosition( new Vector3(15, -750, 0), transform.position + new Vector3(5, 0, 0)); Debug.Log("Firing!"); } }
/// <summary> /// This function makes the button look pressed if the targetState /// is met. /// </summary> /// <param name="theState">the current state</param> public override void receiveUpdate(rubeState theState) { if (theState == targetState) { transform.position += new Vector3(0, .1f, 0); transform.localScale = new Vector3( transform.localScale.x, transform.localScale.y - .5f * transform.localScale.y, transform.localScale.z); gameObject.GetComponent<SphereCollider>().center = new Vector3(0, -.5f, 0); } }
/// <summary> /// This function makes the button look pressed if the targetState /// is met. /// </summary> /// <param name="theState">the current state</param> public override void receiveUpdate(rubeState theState) { if (theState == targetState) { transform.position += new Vector3(0, .1f, 0); transform.localScale = new Vector3( transform.localScale.x, transform.localScale.y - .5f * transform.localScale.y, transform.localScale.z); gameObject.GetComponent <SphereCollider>().center = new Vector3(0, -.5f, 0); } }
/// <summary> /// This implements the receieve update function for the GUI. /// When the state is no longer init, we will blank the GUI out. /// </summary> /// <param name="theState">current state</param> public override void receiveUpdate(rubeState theState) { if(theState == rubeState.started) { gameObject.GetComponent<Text>().text = ""; } else if (theState == rubeState.targetDestroyed) { gameObject.GetComponent<Text>().color = Color.black; gameObject.GetComponent<Text>().fontSize = 80; gameObject.GetComponent<Text>().alignment = TextAnchor.MiddleCenter; gameObject.GetComponent<Text>().text = @"(╯°□°)╯︵ ┻━┻)"; } }
/// <summary> /// This implements the receieve update function for the GUI. /// When the state is no longer init, we will blank the GUI out. /// </summary> /// <param name="theState">current state</param> public override void receiveUpdate(rubeState theState) { if (theState == rubeState.started) { gameObject.GetComponent <Text>().text = ""; } else if (theState == rubeState.targetDestroyed) { gameObject.GetComponent <Text>().color = Color.black; gameObject.GetComponent <Text>().fontSize = 80; gameObject.GetComponent <Text>().alignment = TextAnchor.MiddleCenter; gameObject.GetComponent <Text>().text = @"(╯°□°)╯︵ ┻━┻)"; } }
/// <summary> /// When the button is pressed, /// force is applied to the rocket so that it will hit the table. When the /// table destroyed trigger is hit, and the machine enters the /// "targetDestroyed" state, the rocket begins to use gravity so it falls /// </summary> /// <param name="theState">The current state</param> public override void receiveUpdate(rubeState theState) { if(theState == rubeState.buttonPressed) { gameObject.GetComponent<Rigidbody>().isKinematic = false; gameObject.GetComponent<Rigidbody>().AddForce( transform.up * 7500 ); } if(theState == rubeState.targetDestroyed) { gameObject.GetComponent<Rigidbody>().useGravity = true; } }
/// <summary> /// When the button is pressed, /// force is applied to the rocket so that it will hit the table. When the /// table destroyed trigger is hit, and the machine enters the /// "targetDestroyed" state, the rocket begins to use gravity so it falls /// </summary> /// <param name="theState">The current state</param> public override void receiveUpdate(rubeState theState) { if (theState == rubeState.buttonPressed) { gameObject.GetComponent <Rigidbody>().isKinematic = false; gameObject.GetComponent <Rigidbody>().AddForce( transform.up * 7500 ); } if (theState == rubeState.targetDestroyed) { gameObject.GetComponent <Rigidbody>().useGravity = true; } }
/// <summary> /// This function defines which states an object reacts to, as well as /// the actual functionality of that reaction. /// </summary> /// <param name="theState">this is the state the object will react to /// </param> public abstract void receiveUpdate(rubeState theState);
public override void receiveUpdate(rubeState theState) { this.currentState = theState; timeSinceTransition = 0f; }