Exemplo n.º 1
0
    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;
        }
    }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
    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;
        }
    }
Exemplo n.º 5
0
    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();
        }
    }
Exemplo n.º 6
0
    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);
        }
    }
Exemplo n.º 7
0
 private void registerTargetPerfect(RhythmBeat rhythmBeat)
 {
     rpgManager.playerHitOccurred(1);
     destroyBeat(rhythmBeat);
     Instantiate(perfectIndicatorPrefab, rhythmTarget);
 }
Exemplo n.º 8
0
 private void registerTargetGood(RhythmBeat rhythmBeat)
 {
     rpgManager.playerHitOccurred(0);
     destroyBeat(rhythmBeat);
     Instantiate(goodIndicatorPrefab, rhythmTarget);
 }
Exemplo n.º 9
0
 public void registerTargetMiss(RhythmBeat rhythmBeat)
 {
     rpgManager.playerMissOccurred();
     Instantiate(missIndicatorPrefab, rhythmTarget);
 }