コード例 #1
0
 void Start()
 {
     Dial      = GameObject.Find("RotaryDial");
     comboNum1 = Random.Range(0, 360);
     comboNum2 = Random.Range(0, 360);
     comboNum3 = Random.Range(0, 360);
     //myState = comboStates.traversing_level;
     myState = comboStates.seeking_combo1;
 }
コード例 #2
0
    void SeekingCombo1()
    {
/*Put in an arrow prompt to let Player know which direction to rotate Dial
 */
        //Determine if the Dial is being rotated in the wrong direction
        if (Input.GetAxis("Horizontal") < 0.0f)
        {
            Debug.Log("Wrong Direction. Attempt FAILED");
            //If so, then the attempt at unlocking the door is failed
            attemptsRemaining--;
            myState = comboStates.attempt_failed;
        }
        if (comboNum1Reached == false && (int)dialAngle <= comboNum1 + 5 && (int)dialAngle >= comboNum1)
        {
            //When in range of first combo number, notify player via vibration/sound/something
            Debug.Log("Getting closer");
            if ((int)dialAngle <= comboNum1 + 1 && (int)dialAngle >= comboNum1 - 1)
            {
                /*Then, when they reach the proximity of the exact combo number,
                 * signify proximity to success with an appropriate increase in sound/vibration/whatever
                 * Then, if the player maintains the Dial's rotation at the correct angle for just a second(measured by a simple timer),
                 * the current combo# will unlock
                 */
                if (comboTimer > 0.0f)
                {
                    comboTimer = comboTimer - 0.5f * Time.deltaTime;
                }
                else if (comboTimer <= 0.0f)
                {
                    Debug.Log("*Click*");
                    comboNum1Reached = true;
                    myState          = comboStates.seeking_combo2;
                }
            }
        }
        else if ((int)dialAngle < comboNum1 - 1 && (int)dialAngle >= comboNum1 - 2)
        {
            //If the Player rotates the Dial too far, then the attempt at unlocking the door is failed
            Debug.Log("You rotated too far. Attempt FAILED");
            attemptsRemaining--;
            myState = comboStates.attempt_failed;
        }
        else
        {
            comboTimer = 1.0f;
        }
    }
コード例 #3
0
 void AttemptFailed()
 {
     if (attemptsRemaining > 0)
     {
         Debug.Log("Attempts Remaining: " + attemptsRemaining + ". Press R to Retry");
         if (Input.GetKeyDown(KeyCode.R))
         {
             Dial.transform.Rotate(0.0f, 0.0f, -dialAngle);
             dialAngle = 0.0f;
             myState   = comboStates.seeking_combo1;
         }
     }
     else
     {
         Debug.Log("No attempts Left. YOU LOSE");
         //GameOver();
     }
 }