/// <summary> /// Breaks a random machine, has a chance to generate a 'FIXED' issue, or break an already broken machine /// in which case, nothing will happen /// </summary> private void BreakMachine() { int machineToBreak = Random.Range(0, /*4*/ 1); MachineIssue issue = GenerateIssue(); switch (machineToBreak) { case (0): m_woodchipper.BreakMachine(issue); Debug.Log("Woodchipper broke with issue " + issue.ToString()); break; /*case (1): * m_press.BreakMachine(issue); * Debug.Log("Press broke with issue " + issue.ToString()); * break; * case (2): * m_generator.BreakMachine(issue); * Debug.Log("Generator broke with issue " + issue.ToString()); * break; * case (3): * Debug.Log("No machine was broken"); * break;*/ default: Debug.LogError("Something went horribly wrong with Random.Range"); break; } }
/// <summary> /// Calls for the machine to be broken /// </summary> /// <param name="issue">What the issue is</param> virtual public void BreakMachine(MachineIssue issue) { if (issue == MachineIssue.FIXED) //if the issue given is FIXED, don't break the machine { return; } if (!m_isWorking) //if the machine is already broken, don't rebreak it { return; } m_isWorking = false; m_issue = issue; switch (m_issue) { case (MachineIssue.ON_FIRE): m_fireParticles.Play(); break; case (MachineIssue.DUST_PLUMES): m_dustParticles.Play(); break; case (MachineIssue.SPARKING): m_sparkParticles.Play(); break; default: break; } }
/// <summary> /// Breaks the machine /// </summary> /// <param name="issue">The issue that was generated for the machine</param> public override void BreakMachine(MachineIssue issue) { //call base machine break code base.BreakMachine(issue); switch (issue) { case (MachineIssue.DUST_PLUMES): if (m_modelIsEven) { m_secondBolt.SetCorrect(true); } else { m_thirdBolt.SetCorrect(true); } break; case (MachineIssue.ON_FIRE): if (m_nozzleType == NozzleType.NARROW) { m_tightenInk.SetCorrect(true); } else if (m_nozzleType == NozzleType.WIDE) { m_loosenInk.SetCorrect(true); } else { Debug.LogError("Invalid nozzle type on press!"); } break; case (MachineIssue.SPARKING): if (m_RPMRating == RPMRating.RPM700 || m_RPMRating == RPMRating.RPM856) { m_yellowLever.SetCorrect(true); } else if (m_RPMRating == RPMRating.RPM900 || m_RPMRating == RPMRating.RPM902 || m_RPMRating == RPMRating.RPM1000) { m_orangeLever.SetCorrect(true); } else { Debug.LogError("Invalid RPM rating on press!"); } break; case (MachineIssue.FIXED): //no issue, no action needed break; default: Debug.LogError("Invalid issue generated for press!"); break; } }
/// <summary> /// Breaks the machine and sets up the correct button to hit /// </summary> /// <param name="issue">The issue that the machine has</param> public override void BreakMachine(MachineIssue issue) { //Base machine break base.BreakMachine(issue); //sets a new light colour RandomiseLight(); //Sets the correct button to press based on the variables the machine may have if (m_inputWords == InputWords.TIMBER && m_conveyorColour == ConveyorColour.BLUE) //A blue conveyor with an input labelled 'Timber' means small yellow is correct { m_smallYellowButton.SetCorrect(true, false); } else if (m_bladeOrientation == BladeOrientation.HORIZONTAL && m_inputWords == InputWords.WOOD) //A horizontal blade assembly with an input labelled 'Wood' means small black is correct { m_smallBlackButton.SetCorrect(true, false); } else if (m_conveyorColour == ConveyorColour.WHITE && m_warrantyLabel == WarrantyLabel.MISSING) //A missing warranty with a white conveyor means small cyan is correct { m_smallCyanButton.SetCorrect(true, false); } else if (m_warrantyLabel == WarrantyLabel.EXPIRED && m_bladeOrientation == BladeOrientation.VERTICAL) //An expired warranty with a vertical blade assembly means small yellow is correct { m_smallYellowButton.SetCorrect(true, false); } else if (m_conveyorColour == ConveyorColour.YELLOW) //A yellow conveyor means small magenta is correct { m_smallMagentaButton.SetCorrect(true, false); } else if (m_conveyorColour == ConveyorColour.RED && m_inputWords == InputWords.LUMBER) //A red conveyor with an input labelled 'Lumber' means small cyan is correct { m_smallCyanButton.SetCorrect(true, false); } else //If no other conditions are met, big red is correct { m_bigRedButton.SetCorrect(true, false); } }
/// <summary> /// Calls for the machine to return to a working state /// </summary> virtual public void FixMachine() { switch (m_issue) { case (MachineIssue.ON_FIRE): m_fireParticles.Stop(); break; case (MachineIssue.DUST_PLUMES): m_dustParticles.Stop(); break; case (MachineIssue.SPARKING): m_sparkParticles.Stop(); break; default: break; } m_isWorking = true; m_issue = MachineIssue.FIXED; Debug.Log(gameObject.name + " was fixed!"); }