void CheckInput() { for (int i = 0; i < playerKeys.Count; i++) { if (Input.GetKeyDown(playerKeys[i])) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputKey = playerKeys[i]; _rhythmInput.inputTime = Clock.Instance.TimeMS; CachedInputs.Add(_rhythmInput); } } }
// Update is called once per frame void Update() { //check for inputs and log them for (int i = 0; i < currentBeatmap.playerInputKeys.Length; i++) { if (Input.GetKeyDown(currentBeatmap.playerInputKeys[i])) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputKey = currentBeatmap.playerInputKeys[i]; _rhythmInput.inputTime = Clock.Instance.TimeMS; CachedInputs.Add(_rhythmInput); } } //compare inputs to current beatMap windows //first find any non-destroyed cues FallingGem[] allGems = FindObjectsOfType <FallingGem>(); activeGems.AddRange(allGems); for (int i = 0; i < activeGems.Count; i++) { //we're not going to do anything with early inputs if (activeGems[i].gemCueState != FallingGem.CueState.Early) { //if player hasn't input anything, don't do anything if (CachedInputs.Count == 0) { break; } //go through each of our inputs from this frame, and check them against this gem for (int j = 0; j < CachedInputs.Count; j++) { if (CachedInputs[j].inputKey == activeGems[i].bmEvent.inputKey) { ScoreGem(activeGems[i]); } } } } //clear Lists activeGems.Clear(); CachedInputs.Clear(); }
void Update() { if (usingUnityInputManager) { for (int i = 0; i < currentBeatmap.frogGameCues.Length; i++) { if (Input.GetButtonDown(currentBeatmap.frogGameCues[i].playerInput)) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputString = currentBeatmap.frogGameCues[i].playerInput; _rhythmInput.inputTime = Clock.Instance.TimeMS; CachedInputs.Add(_rhythmInput); } } } else { for (int i = 0; i < currentBeatmap.playerInputKeys.Length; i++) { if (Input.GetKeyDown(currentBeatmap.playerInputKeys[i])) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputKey = currentBeatmap.playerInputKeys[i]; _rhythmInput.inputTime = Clock.Instance.TimeMS; CachedInputs.Add(_rhythmInput); } } } //compare inputs to current beatMap windows //first find any non-destroyed cues FrogGameCueBug[] allBugs = FindObjectsOfType <FrogGameCueBug>(); activeBugs.AddRange(allBugs); //go through each of our inputs from this frame, and check them against this gem for (int j = 0; j < CachedInputs.Count; j++) { //want to register an early input if //there's no other (non-early) active bug in this lane bool earlyInput = true; for (int i = 0; i < activeBugs.Count; i++) { if (activeBugs[i].bugCueState != FrogGameCueBug.CueState.Early) { if (CachedInputs[j].inputKey == activeBugs[i].bmEvent.inputKey || CachedInputs[j].inputString == activeBugs[i].bmEvent.unityInput) { ScoreGem(activeBugs[i]); earlyInput = false; } } } if (earlyInput) { PlayFeedbackSound(missedClips[Random.Range(0, missedClips.Length)]); } } //check //clear Lists activeBugs.Clear(); CachedInputs.Clear(); }
void Update() { float wwiseTime = wwiseSync.GetMusicTimeInMS(); //every frame, we do two things: //1: cache all of our inputs, so we know what the player pressed //2: evaluate every gem that's in play if (Input.GetButtonDown(gemGenerator.fallingGemQ.playerInput)) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputString = gemGenerator.fallingGemQ.playerInput; //might not be necessary? _rhythmInput.inputTime = wwiseTime; CachedInputs.Add(_rhythmInput); Debug.Log("Cached Input: " + _rhythmInput.inputString); } if (Input.GetButtonDown(gemGenerator.fallingGemW.playerInput)) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputString = gemGenerator.fallingGemW.playerInput; _rhythmInput.inputTime = wwiseTime; CachedInputs.Add(_rhythmInput); } if (Input.GetButtonDown(gemGenerator.fallingGemO.playerInput)) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputString = gemGenerator.fallingGemO.playerInput; _rhythmInput.inputTime = wwiseTime; CachedInputs.Add(_rhythmInput); } if (Input.GetButtonDown(gemGenerator.fallingGemP.playerInput)) { RhythmInput _rhythmInput = new RhythmInput(); _rhythmInput.inputString = gemGenerator.fallingGemP.playerInput; _rhythmInput.inputTime = wwiseTime; CachedInputs.Add(_rhythmInput); } //compare inputs to current beatMap windows //first find any non-destroyed cues FallingGem[] allGems = FindObjectsOfType <FallingGem>(); activeGems.AddRange(allGems); for (int i = 0; i < activeGems.Count; i++) { //we're not going to do anything with early inputs if (activeGems[i].gemCueState != FallingGem.CueState.Early) { //if player hasn't input anything, don't do anything if (CachedInputs.Count == 0) { break; } //go through each of our inputs from this frame, and check them against this gem for (int j = 0; j < CachedInputs.Count; j++) { if (CachedInputs[j].inputString == activeGems[i].playerInput) { ScoreGem(activeGems[i]); } } } } //clear Lists activeGems.Clear(); CachedInputs.Clear(); }
void Start() { rInput = gameObject.GetComponent<RhythmInput>(); musicSource = gameObject.GetComponent<AudioSource>(); LoadSong(PlayerInformation.Instance.songToLoad); PlayerInformation.Instance.FinishedLoading (); CalculateLength(); timeOffset = 1f / lengthRatio; timeLapsed -= timeOffset; }
void Start() { rhythmInput = GameObject.FindGameObjectWithTag("GameController").GetComponent<RhythmInput>(); keyCodes = rhythmInput.colorKeys; }
void Awake() { instance = this; }