public void generateBeat() { GameObject beatObject = Instantiate(beatPrefab, rhythmSpawnLocation); RhythmBeat rhythmBeat = beatObject.GetComponent <RhythmBeat>(); InputType chosenInput = (InputType)Random.Range(0, 4); Sprite spriteToUse = beatUp; switch (chosenInput) { case InputType.up: spriteToUse = beatUp; break; case InputType.down: spriteToUse = beatDown; break; case InputType.left: spriteToUse = beatLeft; break; case InputType.right: spriteToUse = beatRight; break; } rhythmBeat.setupBeat(spriteToUse, rhythmBeatsSpeed, chosenInput, this); generatedP1Beats.Add(rhythmBeat); if (rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite == null) { RhythmBeat nextBeat = generatedP1Beats[0]; rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite = nextBeat.GetComponent <SpriteRenderer>().sprite; } }
public void destroyBeat(RhythmBeat rhythmBeat) { generatedP1Beats.Remove(rhythmBeat); Destroy(rhythmBeat.gameObject); if (generatedP1Beats.Count > 0) { RhythmBeat nextBeat = generatedP1Beats[0]; rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite = nextBeat.GetComponent <SpriteRenderer>().sprite; } }
public void destroyBeat(RhythmBeat rhythmBeat) { instrumentRhythmBeats.Remove(rhythmBeat); Destroy(rhythmBeat.gameObject); if (instrumentRhythmBeats.Count > 0) { RhythmBeat nextBeat = instrumentRhythmBeats[0]; rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite = nextBeat.GetComponent <SpriteRenderer>().sprite; } else { rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite = null; } }
public void generateBeat() { //Debug.Log("Made a ins beat"); InputType chosenInput = (InputType)Random.Range(0, 4); Sprite spriteToUse = upSprite; switch (chosenInput) { case InputType.down: beatObject = Instantiate(beatPrefab, downStart); spriteToUse = downSprite; beatObject.GetComponent <Rigidbody2D>().velocity = new Vector2(0f, rhythmBeatsSpeed); break; case InputType.up: beatObject = Instantiate(beatPrefab, upStart); spriteToUse = upSprite; beatObject.GetComponent <Rigidbody2D>().velocity = new Vector2(0f, -rhythmBeatsSpeed); break; case InputType.left: beatObject = Instantiate(beatPrefab, leftStart); spriteToUse = leftSprite; beatObject.GetComponent <Rigidbody2D>().velocity = new Vector2(rhythmBeatsSpeed, 0f); break; case InputType.right: beatObject = Instantiate(beatPrefab, rightStart); spriteToUse = rightSprite; beatObject.GetComponent <Rigidbody2D>().velocity = new Vector2(-rhythmBeatsSpeed, 0f); break; } RhythmBeat rhythmBeat = beatObject.GetComponent <RhythmBeat>(); rhythmBeat.setupBeatIns(spriteToUse, rhythmBeatsSpeed, chosenInput, this); instrumentRhythmBeats.Add(rhythmBeat); if (rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite == null) { RhythmBeat nextBeat = instrumentRhythmBeats[0]; rhythmTarget.gameObject.GetComponent <SpriteRenderer>().sprite = nextBeat.GetComponent <SpriteRenderer>().sprite; } }
public void receivedPressedTypeInput(InputType inputType, ACInstrumentPlayer acInstrumentPlayer) { if (instrumentRhythmBeats.Count == 0) { return; //if there aren't any beats ignore the player's input } RhythmBeat rhythmBeatToCheck = instrumentRhythmBeats[0]; float distanceToTarget = Vector2.Distance(rhythmBeatToCheck.gameObject.transform.position, rhythmTarget.transform.position); //Debug.Log($"Distance to target is [{distanceToTarget}s]"); //if the beat is outside the nearness check, don't check it if (distanceToTarget > nearnessCheckForBeat) { Debug.Log($"Outside range Distance to target is [{distanceToTarget}]"); //it's outside out range, ignore it return; } else if (distanceToTarget > nearnessCheckForGood) { Debug.Log("Miss!"); acInstrumentPlayer.gotMiss(); } else if (inputType != rhythmBeatToCheck.inputType) { Debug.Log("Miss! Wrong Input!"); registerTargetMiss(); acInstrumentPlayer.gotMiss(); } else if (distanceToTarget > nearnessCheckForPerfect) { Debug.Log("Good!"); registerTargetGood(); acInstrumentPlayer.gotGood(); } else { Debug.Log("Perfect!"); registerTargetPerfect(); acInstrumentPlayer.gotPerfect(); } }
public void p1PressedTypeInput(InputType inputType) { if (generatedP1Beats.Count == 0) { return; //if there aren't any beats ignore the player's input } RhythmBeat rhythmBeatToCheck = generatedP1Beats[0]; float distanceToTarget = Vector2.Distance(rhythmBeatToCheck.gameObject.transform.position, rhythmTarget.transform.position); Debug.Log($"Distance to target is [{distanceToTarget}]"); //if the beat is outside the nearness check, don't check it if (distanceToTarget > nearnessCheckForBeat) { Debug.Log($"Outside range Distance to target is [{distanceToTarget}]"); //it's outside out range, ignore it return; } else if (distanceToTarget > accuracyRequirementGood) { Debug.Log("Miss!"); registerTargetMiss(rhythmBeatToCheck); } else if (inputType != rhythmBeatToCheck.inputType) { Debug.Log("Miss! Wrong Input!"); registerTargetMiss(rhythmBeatToCheck); } else if (distanceToTarget > accuracyRequirementPerfect) { Debug.Log("Good!"); registerTargetGood(rhythmBeatToCheck); } else { Debug.Log("Perfect!"); registerTargetPerfect(rhythmBeatToCheck); } }
private void registerTargetPerfect(RhythmBeat rhythmBeat) { rpgManager.playerHitOccurred(1); destroyBeat(rhythmBeat); Instantiate(perfectIndicatorPrefab, rhythmTarget); }
private void registerTargetGood(RhythmBeat rhythmBeat) { rpgManager.playerHitOccurred(0); destroyBeat(rhythmBeat); Instantiate(goodIndicatorPrefab, rhythmTarget); }
public void registerTargetMiss(RhythmBeat rhythmBeat) { rpgManager.playerMissOccurred(); Instantiate(missIndicatorPrefab, rhythmTarget); }