protected void randomInput() { if (sinceLastDecision > decisionCadence) { bool positionChange = Random.Range(0.0f, 1.0f) < stateChangeProbability; if (positionChange) { inputBroker.clearInputs(); float randomAxis = Random.Range(0.0f, 1.0f); if (randomAxis < axisProbability) // left { verticalPressDuration = 0.0f; if (!inputBroker.HorizontalPressed()) { inputBroker.setHorizontal(-1.0f); } else { inputBroker.setHorizontal(0.0f); } } else if (randomAxis < (2 * axisProbability)) // right { verticalPressDuration = 0.0f; if (!inputBroker.HorizontalPressed()) { inputBroker.setHorizontal(1.0f); } else { inputBroker.setHorizontal(0.0f); } } else // down { horizontalPressDuration = 0.0f; if (!inputBroker.VerticalPressed()) { inputBroker.setVertical(-1.0f); } else { inputBroker.setVertical(0.0f); } } } sinceLastDecision = 0.0f; } if (horizontalPressDuration > maxPressDuration) { inputBroker.setHorizontal(0.0f); sinceLastDecision = 0.0f; } if (verticalPressDuration > maxPressDuration) { inputBroker.setVertical(0.0f); sinceLastDecision = 0.0f; } }
protected void randomInput() { if (sinceLastDecision > decisionCadence) { bool horizontalChange = Random.Range(0.0f, 1.0f) > stateChangeProbability; if (horizontalChange) { if (!inputBroker.HorizontalPressed()) { inputBroker.setHorizontal(Random.Range(-1.0f, 1.0f)); } else { inputBroker.setHorizontal(0.0f); } } bool verticalChange = Random.Range(0.0f, 1.0f) > stateChangeProbability; if (verticalChange) { if (!inputBroker.VerticalPressed()) { inputBroker.setVertical(Random.Range(-1.0f, 1.0f)); } else { inputBroker.setVertical(0.0f); } } sinceLastDecision = 0.0f; } if (horizontalPressDuration > maxPressDuration) { inputBroker.setHorizontal(0.0f); sinceLastDecision = 0.0f; } if (verticalPressDuration > maxPressDuration) { inputBroker.setVertical(0.0f); sinceLastDecision = 0.0f; } }