Example #1
0
    private DanceMatInputCode GetCurrentDanceMatInputCode()
    {
        DanceMatInputCode inputCode      = null;
        KeyCode           currentKeycode = GetCurrentKeycode();

        if (currentKeycode != DanceMatInputCode.NULL_KEYCODE)
        {
            inputCode         = new DanceMatInputCode();
            inputCode.type    = InputType.Key;
            inputCode.keycode = currentKeycode;
        }
        else
        {
            float horizontalInput = Input.GetAxisRaw("Horizontal");
            float verticalInput   = Input.GetAxisRaw("Vertical");

            if (horizontalInput != 0f)
            {
                inputCode               = new DanceMatInputCode();
                inputCode.type          = InputType.Axis;
                inputCode.axisName      = "Horizontal";
                inputCode.axisDirection = horizontalInput > 0f ? 1 : -1;
            }
            else if (verticalInput != 0f)
            {
                inputCode               = new DanceMatInputCode();
                inputCode.type          = InputType.Axis;
                inputCode.axisName      = "Vertical";
                inputCode.axisDirection = verticalInput > 0f ? 1 : -1;
            }
        }

        return(inputCode);
    }
Example #2
0
 private void Awake()
 {
     pressedCode             = null;
     countdown               = 3f;
     currentCalibratedButton = DanceMatInput.Up;
     numberOfButtons         = System.Enum.GetValues(typeof(DanceMatInput)).Length;
     DanceMatInputManager.inputToCode.Clear();
 }
Example #3
0
    private IEnumerator CalibrateKeys()
    {
        while ((int)currentCalibratedButton < numberOfButtons)
        {
            while (pressedCode == null || ButtonHasBeenRegistered())
            {
                yield return(new WaitForEndOfFrame());
            }

            switch (currentCalibratedButton)
            {
            case DanceMatInput.Up:
                messageDisplay.text = "Agora aperte a seta para baixo";
                break;

            case DanceMatInput.Down:
                messageDisplay.text = "Aperte para esquerda";
                break;

            case DanceMatInput.Left:
                messageDisplay.text = "E para direita";
                break;

            case DanceMatInput.Right:
                messageDisplay.text = "Aperte X";
                break;

            case DanceMatInput.Cross:
                messageDisplay.text = "Aperte quadrado";
                break;

            case DanceMatInput.Square:
                messageDisplay.text = "Aperte triângulo";
                break;

            case DanceMatInput.Triangle:
                messageDisplay.text = "Aperte círculo";
                break;

            case DanceMatInput.Circle:
                messageDisplay.text = "Calibragem completa.\nAperte qualquer botão para começar";
                break;
            }

            DanceMatInputManager.inputToCode.Add(currentCalibratedButton, pressedCode);
            pressedCode             = null;
            currentCalibratedButton = (DanceMatInput)((int)currentCalibratedButton + 1);
        }

        DanceMatInputManager.isInitialized = true;
    }
Example #4
0
    private bool IsInputPressed(DanceMatInput input)
    {
        DanceMatInputCode code = inputToCode[input];

        if (code.type == InputType.Axis)
        {
            return(Input.GetAxisRaw(code.axisName) == code.axisDirection);
        }
        else if (code.type == InputType.Key)
        {
            return(Input.GetKey(code.keycode));
        }

        Debug.Log(string.Concat(input.ToString(), " is undefined."));
        return(false);
    }
Example #5
0
 private void Update()
 {
     if (countdown > 0f)
     {
         messageDisplay.text = string.Concat("Não aperte nenhum botão. Calibragem começará em ", Mathf.CeilToInt(countdown).ToString("0"));
         countdown          -= Time.deltaTime;
         if (countdown <= 0f)
         {
             messageDisplay.text = "Aperte a seta para cima no tapete de dança";
             StartCoroutine(CalibrateKeys());
         }
     }
     else
     {
         if ((int)currentCalibratedButton < numberOfButtons)
         {
             pressedCode = GetCurrentDanceMatInputCode();
         }
         else if (Input.anyKeyDown)
         {
             SceneManager.LoadScene("CalibrationChecker");
         }
     }
 }