Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        Transform noteHolder = GameObject.Find("Notes").transform;

        RhythmTracker rt = GameObject.FindGameObjectWithTag("MusicSource").GetComponent <RhythmTracker>();
        int           n  = rt.GetNoteCount();

        for (int i = 0; i < n; i++)
        {
            GameObject note;
            if (!rt.NoteIsEnemy(i))
            {
                note = Instantiate(notePrefab, transform.position, Quaternion.identity);
            }
            else
            {
                note = Instantiate(enemyNotePrefab, transform.position, Quaternion.identity);
            }

            note.transform.parent = noteHolder;
            note.SetActive(true);

            ScrollingNote sn = note.GetComponent <ScrollingNote>();
            if (sn != null)
            {
                sn.isEnemy = rt.NoteIsEnemy(i);
                sn.notePos = i;
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// ^^^^^// EDIT: Brian Dornbusch 2/15/2021///////////////////////////////////////////////////////////////////////////////////
    /// </summary>
    void Update()
    {
        enemyNoteTracking = rhythmTracker.NoteIsEnemy();
        normAccuracy      = rhythmTracker.GetNormalizedAccuracy(); //All of this is used to reference other scripts
        targetBeat        = rhythmTracker.GetTargetBeat();

        if (enemyStatsSO.enemyHealth <= 0 || playerStatsSO.currentHealth <= 0)
        {
            SceneManager.LoadScene("RewardUI");
        }
        if (normAccuracy < 1f * playerStatsSO.accuracy)   //this should allow the beat to be checked if it falls in between where the note is able to be hit...... ERROR HERE it always returns true

        {
            if (!acted)   // Makes sure the player can't act on a single note more than once
            {
                if (playerStatsSO.amplitude >= .2f)
                {
                    if (Input.GetKeyDown(KeyCode.A))
                    {
                        AttackOne();
                        Debug.Log("Attack one");
                    }
                    if (Input.GetKeyDown(KeyCode.S))
                    {
                        AttackTwo();
                        Debug.Log("Attack two");
                    }
                    if (Input.GetKeyDown(KeyCode.D))
                    {
                        AttackThree();
                        Debug.Log("Attack three");
                    }
                }

                if (Input.GetKeyDown(KeyCode.J))
                {
                    Rest();
                    Debug.Log("Rest");
                }
                else if (normAccuracy == 0 && lastBeat != targetBeat)     // if the player doesn't hit anything and the note passes the player gets these bonuses. Again not working because the note is always
                {
                    playerStatsSO.currentHealth += 5;
                    playerStatsSO.amplitude     += .01f;
                }

                if (Input.GetKeyDown(KeyCode.F))
                {
                    HealItem();
                    Debug.Log("Healing item used");
                }
                else if (Input.GetKeyDown(KeyCode.G))
                {
                    AmpItem();
                    Debug.Log("Amplitude item used");
                }
            }

            if (!blocked)
            {
                if (lastBeat != targetBeat)
                {
                    if (GetComponent <RhythmTracker>().NoteIsEnemy(lastBeat))  // Checks if the last note was an enemy note for damage
                    {
                        playerStatsSO.currentHealth -= enemyStatsSO.enemyDmg /* * TypeAdvantage*/;
                    }
                }
                else if (enemyNoteTracking && Input.GetKeyDown(KeyCode.Space))     // Checks if the current note is an enemy note and if the player pressed the block key
                {
                    Debug.Log("You blocked");
                    Guard();
                }
            }

            if (lastBeat != targetBeat)
            {
                acted   = false;
                blocked = false;
            }

            lastBeat = targetBeat;
        }
    }