Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.transform.IsChildOf(transform))
        {
            return;
        }

        if (other.gameObject.layer == LayerMask.NameToLayer("Ignore Collision"))
        {
            return;
        }

        // Keep track of what is currently on the plate
        pressers.Add(other);
        output.SetState(true);
        sr.sprite = ClosedSprite;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (ToolController.SelectedTool == ToolController.ToolType.EDITOR)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                if (Collider.OverlapPoint(mousePosition))
                {
                    Debug.Log("test");
                    GateType oldGate = Gate;
                    Gate = (GateType)(((int)Gate + 1) % Enum.GetNames(typeof(GateType)).Length);
                    Debug.Log(Gate.ToString());
                    SelectSprite();
                    if (oldGate == GateType.NOT || Gate == GateType.NOT)
                    {
                        SetInterface();
                    }
                }
            }
        }
        switch (Gate)
        {
        default:
        case GateType.NOT:
            OutputPin.SetState(!InputPins[0].GetState());
            break;

        case GateType.AND:
            OutputPin.SetState(InputPins[0].GetState() && InputPins[1].GetState());
            break;

        case GateType.OR:
            OutputPin.SetState(InputPins[0].GetState() || InputPins[1].GetState());
            break;

        case GateType.XOR:
            OutputPin.SetState(!InputPins[0].GetState() != !InputPins[1].GetState());
            break;
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        default:
        case TriStateType.OFF:
            LeftPin.SetState(false);
            RightPin.SetState(false);
            break;

        case TriStateType.RIGHT:
            LeftPin.SetState(false);
            RightPin.SetState(true);
            break;

        case TriStateType.LEFT:
            LeftPin.SetState(true);
            RightPin.SetState(false);
            break;
        }
    }