/// <summary> /// Updates the blade's spin direction /// </summary> /// <param name="newSpin">The new spin direction</param> private void UpdateBlades(BladeSpinDirection newSpin) { m_bladeSpinDirection = newSpin; m_leftBlades.UpdateSpinDirection(newSpin); m_rightBlades.UpdateSpinDirection(newSpin); }
/// <summary> /// Sets initial variables on the blades /// </summary> private void CreateBlades() { m_bladeSpinDirection = (BladeSpinDirection)Random.Range(0, 2); m_leftBlades.Create(m_bladeSpinDirection, m_bladeSpinSpeed, m_brokenBladeMultiplier, m_RPM); m_rightBlades.Create(m_bladeSpinDirection, -m_bladeSpinSpeed, m_brokenBladeMultiplier, m_RPM); }
/// <summary> /// Function to be called when the spin direction updates /// </summary> /// <param name="newSpin">The new spin direction</param> public void UpdateSpinDirection(BladeSpinDirection newSpin) { if (m_spinDirection == BladeSpinDirection.CORRECT) { m_currentSpinSpeed = m_spinSpeed; } else if (m_spinDirection == BladeSpinDirection.INCORRECT) { m_currentSpinSpeed = m_spinSpeed * -1.0f; } }
/// <summary> /// Sets up variables for the spinning blades /// </summary> /// <param name="spinDirection">What direction these spin</param> /// <param name="spinSpeed">How fast these should spin</param> /// <param name="brokenMulti">How much slower these should go if machine is broken</param> public void Create(BladeSpinDirection spinDirection, float spinSpeed, float brokenMulti, RotationRate rotationRate) { m_spinDirection = spinDirection; m_spinSpeed = spinSpeed; m_brokenSpeedMultiplier = brokenMulti; m_machineRPM = rotationRate; switch (m_machineRPM) //modify the spin speed based on machine RPM { case (RotationRate.RPM300): m_spinSpeed *= 0.6f; break; case (RotationRate.RPM400): m_spinSpeed *= 0.8f; break; case (RotationRate.RPM500): //do nothing, as this is the base speed rating break; case (RotationRate.RPM600): m_spinSpeed *= 1.2f; break; case (RotationRate.RPM700): m_spinSpeed *= 1.4f; break; default: break; } if (m_spinDirection == BladeSpinDirection.CORRECT) { m_currentSpinSpeed = m_spinSpeed; } else if (m_spinDirection == BladeSpinDirection.INCORRECT) { m_currentSpinSpeed = m_spinSpeed * -1.0f; } }
/// <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); }