private void OnClick() { // Delay stops the player from spawning the button to bring gus to full health/pressure/etc. if (resource.getDelay() <= 0.0f) { resource.AddResourceValue(); } }
private void OnClick() { // Check if the cooldown of the lever is ready if (resource.getDelay() <= 0.0f) { // Add the resource value to the time/scale of the pressure bar resource.AddResourceValue(); if (resource.getResourceScale() >= maxVal) { // Clamp to max value if greater // Also clamp the needle to the max pressure value resource.setResourceScale(maxVal); pressureNeedle.transform.rotation = Quaternion.AngleAxis(0.0f, new Vector3(0.0f, 0.0f, 1.0f)); } else { // Calculate the precentage of the added time/scale over 180 // Then rotate the needle to the correct added value float percentage = ((180 * resource.getResourceScale()) / 100); pressureNeedle.transform.eulerAngles = new Vector3(0.0f, 0.0f, (percentage - 180)); } } }