Пример #1
0
    // Use this for initialization



    void Start()
    {
        logicManager    = GameObject.Find("LogicManager").GetComponent <LogicManager>();
        MarksList       = new List <GameObject>();
        checkMarkSprite = Resources.Load <Sprite>("Sprites/002-tick");
        crossMarkSprite = Resources.Load <Sprite>("Sprites/001-close");
        for (int i = 0; i < this.gameObject.transform.childCount; i++)
        {
            switch (this.gameObject.transform.GetChild(i).name)
            {
            case "InputA":
                InputA = this.gameObject.transform.GetChild(i).gameObject;
                InputA.GetComponent <CheckerTagScript>().Type = GradingCONSTANTS.INPUT;
                break;

            case "InputB":
                InputB = this.gameObject.transform.GetChild(i).gameObject;
                InputB.GetComponent <CheckerTagScript>().Type = GradingCONSTANTS.INPUT;
                break;

            case "InputC":
                InputC = this.gameObject.transform.GetChild(i).gameObject;
                InputC.GetComponent <CheckerTagScript>().Type = GradingCONSTANTS.INPUT;
                break;

            case "OutputF":
                OutputF = this.gameObject.transform.GetChild(i).gameObject;
                OutputF.GetComponent <CheckerTagScript>().Type = GradingCONSTANTS.OUTPUT;
                break;
            }
        }
        Finish.onClick.AddListener(GradeCheckInitializer);
    }
Пример #2
0
 public Machine()
 {
     Position      = 0;
     RelativeIndex = 0;
     Inputs        = new Queue <BigInteger>();
     Output        = (x) => System.Console.WriteLine("OUTPUT: " + x);
     Memory        = new Dictionary <BigInteger, BigInteger>();
 }
    // Use this for initialization



    void Start()
    {
        logicManager    = GameObject.Find("LogicManager").GetComponent <LogicManager>();
        MarksList       = new List <GameObject>();
        checkMarkSprite = Resources.Load <Sprite>("Sprites/002-tick");
        crossMarkSprite = Resources.Load <Sprite>("Sprites/001-close");
        InputA.GetComponent <CheckerTagScript>().Type  = GradingCONSTANTS.INPUT;
        InputB.GetComponent <CheckerTagScript>().Type  = GradingCONSTANTS.INPUT;
        InputC.GetComponent <CheckerTagScript>().Type  = GradingCONSTANTS.INPUT;
        OutputF.GetComponent <CheckerTagScript>().Type = GradingCONSTANTS.OUTPUT;


        Finish.onClick.AddListener(GradeCheckInitializer);
    }
Пример #4
0
    IEnumerator FinishChecker()
    {
        for (int i = 0; i < MarksList.Count; i++)
        {
            Destroy(MarksList[i]);
        }
        MarksList.Clear();
        CheckerTagScript InputATag  = InputA.GetComponent <CheckerTagScript>();
        CheckerTagScript InputBTag  = InputB.GetComponent <CheckerTagScript>();
        CheckerTagScript InputCTag  = InputC.GetComponent <CheckerTagScript>();
        CheckerTagScript OutputFTag = OutputF.GetComponent <CheckerTagScript>();

        if (InputATag.GetCollidingObject() == null || InputBTag.GetCollidingObject() == null ||
            InputCTag.GetCollidingObject() == null || OutputFTag.GetCollidingObject() == null)
        {
            Debug.Log("All tags are not SNAPPED!");
            yield break;
        }
        Switch    InputASwitch = InputATag.GetCollidingObject().GetComponent <Switch>();
        Switch    InputBSwitch = InputBTag.GetCollidingObject().GetComponent <Switch>();
        Switch    InputCSwitch = InputCTag.GetCollidingObject().GetComponent <Switch>();
        LEDScript OutputFLED   = OutputFTag.GetCollidingObject().GetComponent <LEDScript>();



        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(false); InputCSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(false); InputCSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(true); InputCSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(true); InputCSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(false); InputCSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(false); InputCSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(true); InputCSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(true); InputCSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputFLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            LabOneGrade -= 5;
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);


        Debug.Log("Correct output!");
        DataInsert.inputLab1Grade += LabOneGrade;
        yield return(new WaitForSecondsRealtime(5));

        SceneManager.LoadScene("Scenes/Postlab1");
    }