/// <summary>
    /// Function to be called when the RPM rate of the Woodchipper updates
    /// </summary>
    /// <param name="newRPM">The new RPM rating of the machine</param>
    /// <param name="baseSpinSpeed">The spin speed at 500 RPM</param>
    public void UpdateMachineRPM(RotationRate newRPM, float baseSpinSpeed)
    {
        m_machineRPM = newRPM;
        switch (m_machineRPM)
        {
        case (RotationRate.RPM300):
            m_spinSpeed = baseSpinSpeed * 0.6f;
            break;

        case (RotationRate.RPM400):
            m_spinSpeed = baseSpinSpeed * 0.8f;
            break;

        case (RotationRate.RPM500):
            m_spinSpeed = baseSpinSpeed;
            break;

        case (RotationRate.RPM600):
            m_spinSpeed = baseSpinSpeed * 1.2f;
            break;

        case (RotationRate.RPM700):
            m_spinSpeed = baseSpinSpeed * 1.4f;
            break;

        default:
            Debug.LogError("Invalid RotationRate passed to SpinningBlade through UpdateMachineRPM");
            break;
        }
    }
    /// <summary>
    /// Updates the rotation rate and sets the text field to reflect the new rotation rate
    /// </summary>
    /// <param name="newRate"></param>
    private void UpdateRotationRate(RotationRate newRate)
    {
        //set the new rpm rate, and update the spinning blades
        m_RPM = newRate;
        m_leftBlades.UpdateMachineRPM(m_RPM, m_bladeSpinSpeed);
        m_rightBlades.UpdateMachineRPM(m_RPM, -m_bladeSpinSpeed);
        switch (m_RPM)         //modify the text field
        {
        case (RotationRate.RPM300):
            m_RPMField.text = m_RPM300Text;
            break;

        case (RotationRate.RPM400):
            m_RPMField.text = m_RPM400Text;
            break;

        case (RotationRate.RPM500):
            m_RPMField.text = m_RPM500Text;
            break;

        case (RotationRate.RPM600):
            m_RPMField.text = m_RPM600Text;
            break;

        case (RotationRate.RPM700):
            m_RPMField.text = m_RPM700Text;
            break;

        default:
            m_RPMField.text = "INVALID RPM";
            Debug.LogError("Invalid RPM rating passed on UpdateRotationRate for WoodchipperReworked");
            break;
        }
    }
    /// <summary>
    /// Sets up variables for rotation rate and sets the text field to reflect the rotation rate
    /// </summary>
    private void CreateRotationRate()
    {
        //randomly select an rpm rating
        m_RPM = (RotationRate)Random.Range(0, 5);

        //set the text field to the proper text
        switch (m_RPM)
        {
        case (RotationRate.RPM300):
            m_RPMField.text = m_RPM300Text;
            break;

        case (RotationRate.RPM400):
            m_RPMField.text = m_RPM400Text;
            break;

        case (RotationRate.RPM500):
            m_RPMField.text = m_RPM500Text;
            break;

        case (RotationRate.RPM600):
            m_RPMField.text = m_RPM600Text;
            break;

        case (RotationRate.RPM700):
            m_RPMField.text = m_RPM700Text;
            break;

        default:
            m_RPMField.text = "INVALID RPM";
            Debug.LogError("Randomisation went wrong for RPM rating on WoodchipperReworked");
            break;
        }
    }
 public static void Finalize_()          // "Finalize" exists in parent
 {
     using (var profile = new Profile())
     {
         profile.DeviceType = "Rotator";
         profile.WriteValue(s_sProgID, "Position", s_fPosition.ToString(CultureInfo.InvariantCulture), "");
         profile.WriteValue(s_sProgID, "RotationRate", RotationRate.ToString(CultureInfo.InvariantCulture), "");
         profile.WriteValue(s_sProgID, "CanReverse", s_bCanReverse.ToString(), "");
         profile.WriteValue(s_sProgID, "Reverse", s_bReverse.ToString(), "");
     }
 }
Beispiel #5
0
        // Write configuration to the Profile
        public static void WriteConfiguration()
        {
            using (var profile = new Profile())
            {
                profile.DeviceType = "Rotator";
                profile.WriteValue(progID, "Position", mechanicalPosition.ToString(CultureInfo.InvariantCulture), "");
                profile.WriteValue(progID, "RotationRate", RotationRate.ToString(CultureInfo.InvariantCulture), "");
                profile.WriteValue(progID, "CanReverse", canReverse.ToString(), "");
                profile.WriteValue(progID, "Reverse", reverse.ToString(), "");

                profile.WriteValue(progID, "SyncOffset", syncOffset.ToString(CultureInfo.InvariantCulture), "");
            }
        }
    /// <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);
    }