Esempio n. 1
0
    public static void InputToTape(InputField input, GameObject cellTapePrefab)
    {
        ClearTape();

        TuringMachine tm = GameObject.FindGameObjectWithTag("GameController").GetComponent <TuringMachine>();

        GameObject.FindGameObjectWithTag("processButton").GetComponent <Button>().interactable      = true;
        GameObject.FindGameObjectWithTag("startMachineButton").GetComponent <Button>().interactable = true;
        GameObject.FindGameObjectWithTag("tapeInput").GetComponent <Dropdown>().interactable        = true;
        GameObject.FindGameObjectWithTag("StepButtonLight").GetComponent <Light>().intensity        = 2.5f;

        GameObject.FindGameObjectWithTag("StartButtonLight").GetComponent <Light>().color = Color.green;

        char[] cellsInChar = input.GetComponent <InputField>().text.ToCharArray();


        foreach (char c in cellsInChar)
        {
            if (!tm.GetAlphabet().LookForSymbol(c))
            {
                GameObject.FindGameObjectWithTag("GameController").GetComponent <Utils>().showWait = true;
                return;
            }
        }

        //cria as celulas da fita
        for (int i = 0; i < cellsInChar.Length; i++)
        {
            GameObject cell = Instantiate(cellTapePrefab);
            cell.GetComponentInChildren <TextMesh>().text = "" + cellsInChar[i];
            cell.transform.position = new Vector3((1.5f * i), 0, 0);
        }

        GameObject.FindGameObjectWithTag("TuringMachine").transform.position = new Vector3(0, 0, 0);
    }