﻿using UnityEngine;
using UnityEngine.UI;

//Adds digits to the inputfiled and listens to the voice commands for digits
public class EnterBUNO : MonoBehaviour
{
    InputField infield = null;

	// Use this for initialization
	void Start ()
    {
        infield = GetComponent<InputField>();	
	}
	
	public void AddDigit(string digit)
    {
        infield.text += digit;
    }

    public void Backspace()
    {
        infield.text = infield.text.Substring(0, infield.text.Length - 1);
    }

    public void OnEnable()
    {
        //VoiceCommands.OnVoiceRecognized += GetVoiceCommands;
    }
    public void OnDisable()
    {
        //VoiceCommands.OnVoiceRecognized -= GetVoiceCommands;
    }

    public void GetVoiceCommands(string command)
    {
        switch (command)
        {
            case "backspace": Backspace(); break;
            case "one": AddDigit("1"); break;
            case "two": AddDigit("2"); break;
            case "three": AddDigit("3"); break;
            case "four": AddDigit("4"); break;
            case "five": AddDigit("5"); break;
            case "six": AddDigit("6"); break;
            case "seven": AddDigit("7"); break;
            case "eight": AddDigit("8"); break;
            case "nine": AddDigit("9"); break;
            case "zero": AddDigit("0"); break;
        }
    }
}
