예제 #1
0
    public void Update()
    {
        if (!levelController.PerformingAction && !pauseMenuController.IsGamePaused())
        {
            if (Input.anyKeyDown)
            {
                // Key that has been pressed in the last frame
                string inputKey = Input.inputString.ToUpper();
                // If the input is valid as an action key and the number of inputs isn't more than allowed
                if (inputKey.Length == 1 && (ValidKey(inputKey) || inputKey.Equals(" ")) && inputs.Count < levelController.NumberOfActions)
                {
                    inputs.Add(inputKey);
                    inputVisualizer.AddLetter(inputKey);
                    if (debug)
                    {
                        Debug.Log("Input *" + inputKey + "* was added to the list");

                        string s = "";
                        foreach (string current in inputs)
                        {
                            s += current;
                        }

                        Debug.Log("Letter added, current input list is: " + s);
                    }
                }
                //Send inputs to PlayerController for it to start the actions
                if (Input.GetKeyDown(KeyCode.Return) && inputs.Count == levelController.NumberOfActions)
                {
                    if (debug)
                    {
                        Debug.Log("Calling StartActions from PlayerController");
                    }
                    playerController.StartActions(inputs);
                }

                if (Input.GetKeyDown(KeyCode.Backspace) && inputs.Count > 0)
                {
                    inputs.RemoveAt(inputs.Count - 1);
                    inputVisualizer.DeleteLetter();

                    if (debug)
                    {
                        string s = "";
                        foreach (string current in inputs)
                        {
                            s += current;
                        }
                        Debug.Log("Letter removed, current input list is: " + s);
                    }
                }
            }

            // TODO: Show Return button in UI if all the letters are full
        }
    }