private void CheckInput() { volume = GetAverageVolume() * MIC_SENSITIVITY; detectedClap = lastFrameVolume <= ambientVolume && volume >= clapVolume; if (detectedClap) { ResourcesMaster.AddResource(generatedResourceName, ResourcesMaster.instance.resourcePerMicThreshold); } lastFrameVolume = volume; }
private void CheckInput() { // If manager wasn't initialized or no button was pressed, do nothing. if (!DanceMatInputManager.isInitialized || !DanceMatInputManager.GetAnyInput()) { return; } // Gets which button was pressed on current frame DanceMatInput pressedButton = GetDanceMatKeyDown(); // If the pressed button is different than the last pressed button, // increases the score if (pressedButton != lastPressedInput) { DoFootStep(); Grape closestGrape = GetClosestGrape(); if (closestGrape) { float hitRadius = ResourcesMaster.instance.hitRadius; if ((closestGrape.transform.position - target.position).sqrMagnitude < hitRadius * hitRadius) { audioSource.PlayOneShot(grapeSquashing); float resourcePerTap = ResourcesMaster.instance.resourcesPerTap; ResourcesMaster.AddResource(generatedResourceName, resourcePerTap); steppedGrapesColors.Add(closestGrape.colorSpectrumValue); if (steppedGrapesColors.Count > 10) { steppedGrapesColors.RemoveAt(0); } } else { feedbackPanel.SetAlpha(0f); feedbackPanel.DOFade(0.5f, 0.5f).From(); //float resourcePerTap = ResourcesMaster.instance.danceMatProperties.resourcesPerTap; //float usedResources = ResourcesMaster.GetResourceData(generatedResourceName).requiredToGeneratedRatio * resourcePerTap; //ResourcesMaster.RemoveRequiredResource(generatedResourceName, usedResources); } fallingGrapes.Remove(closestGrape); Destroy(closestGrape.gameObject); GameMaster.instance.collectActivity.RemoveGrapeByColor(closestGrape.colorSpectrumValue); } } // Saves current button as last pressed button for next frame. lastPressedInput = pressedButton; }
private void CheckInput() { JoystickPosition currentDirection = GetCurrentJostickPosition(); JoystickPosition lastDirection = latestDirections.GetLast(); // Waits for direction to change so it doesn't accumulate a bunch of equal directions if (currentDirection != lastDirection && currentDirection != JoystickPosition.None) { latestDirections.Add(currentDirection); // We are only interested in the latest 4 directions. if (latestDirections.Count > 4) { latestDirections.RemoveAt(0); } // Generates resources whenever player completed a full spin if (CounterClockwiseCheck() || ClockwiseCheck()) { ResourcesMaster.AddResource(generatedResource, resourcePerSpin); } } }