/// <summary> /// Randomly sets a pressure rating for the machine, and makes the correct gauge active, while also making the other gauges inactive /// </summary> private void CreatePressure() { //Randomly select a pressure rating PressureGauge newPressure = (PressureGauge)Random.Range(0, 5); //set the pressure rating UpdatePressure(newPressure); }
/// <summary> /// Calls base fix machine, also randomly sets a new value for all the variables /// </summary> public override void FixMachine() { //call base function base.FixMachine(); //randomly generate new variables AxleOrientation newAxles = (AxleOrientation)Random.Range(0, 2); BladeSpinDirection newSpin = (BladeSpinDirection)Random.Range(0, 2); RattlingPipe newRattle = (RattlingPipe)Random.Range(0, 4); RotationRate newRotateSpeed = (RotationRate)Random.Range(0, 5); PressureGauge newPressure = (PressureGauge)Random.Range(0, 5); //Hide variables StopRattlingPipe(); //TODO close panels //update all the variables UpdateAxle(newAxles); UpdateBlades(newSpin); UpdateRattlingPipe(newRattle); UpdateRotationRate(newRotateSpeed); UpdatePressure(newPressure); }
/// <summary> /// Sets a new pressure rating, and updates the visible gauge to match /// </summary> /// <param name="newPressure">The new pressure rating for the machine</param> private void UpdatePressure(PressureGauge newPressure) { //sets the new rating m_pressure = newPressure; //deactivate all gauges m_30PSIGauge.SetActive(false); m_45PSIGauge.SetActive(false); m_60PSIGauge.SetActive(false); m_75PSIGauge.SetActive(false); m_90PSIGauge.SetActive(false); //activate the correct one switch (m_pressure) { case (PressureGauge.PSI30): m_30PSIGauge.SetActive(true); break; case (PressureGauge.PSI45): m_45PSIGauge.SetActive(true); break; case (PressureGauge.PSI60): m_60PSIGauge.SetActive(true); break; case (PressureGauge.PSI75): m_75PSIGauge.SetActive(true); break; case (PressureGauge.PSI90): m_90PSIGauge.SetActive(true); break; } }