/// <summary>
 /// Method that invokes KeyID event.
 /// </summary>
 /// <param name="keyID">ID of the piano key.</param>
 protected virtual void OnKeyID(PianoKeyID keyID) => KeyID?.Invoke(keyID);
示例#2
0
    /// <summary>
    /// Changes the Player's Input based on the playCounter and PianoKeyID
    /// </summary>
    /// <param name="id">The id of the played piano key</param>
    private void GetPianoKeyPressed(PianoKeyID id)
    {
        //Checks if the player has finished the puzzle
        if (room4.FinishedPuzzle == false)
        {
            //If its 1st time playing a key it changes the 1st input value
            if (playCounter == 0)
            {
                //Changes the input value based on the key's Id and
                //increments the counter
                switch (id)
                {
                case PianoKeyID.Key1:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(1, 0, 0);
                    break;

                case PianoKeyID.Key2:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(2, 0, 0);
                    break;

                case PianoKeyID.Key3:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(3, 0, 0);
                    break;
                }
            }

            //If its 2nd time playing a key it changes the 2nd input value
            else if (playCounter == 1)
            {
                //Changes the input value based on the key's Id and
                //increments the counter
                switch (id)
                {
                case PianoKeyID.Key1:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(0, 1, 0);
                    break;

                case PianoKeyID.Key2:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(0, 2, 0);
                    break;

                case PianoKeyID.Key3:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(0, 3, 0);
                    break;
                }
            }

            //If its 3rd time playing a key it changes the 3rd input value
            //resets the play counter and player's input
            //and checks if the player solved the puzzle
            else if (playCounter == 2)
            {
                //Changes the input value based on the key's Id and
                //increments the counter
                switch (id)
                {
                case PianoKeyID.Key1:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(0, 0, 1);
                    break;

                case PianoKeyID.Key2:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(0, 0, 2);
                    break;

                case PianoKeyID.Key3:
                    playCounter++;
                    PianoPlayerInput += new CustomVector3(0, 0, 3);
                    break;
                }
                playCounter = 0;
                room4.VictoryCheck();
                PianoPlayerInput = new CustomVector3(0, 0, 0);
            }
        }
    }