Beispiel #1
0
 public void Select(SelectableGate gate)
 {
     if (!targetMode)
     {
         selected = gate;
         selected.ActivateVisuals();
         currentGate.First = selected.PosY;
         ShowUI();
     }
     else
     {
         targetMode = false;
         allGates[selected.PosX][gate.PosY].SetName("T");
         allGates[selected.PosX][gate.PosY].SetRotation("");
         allGates[selected.PosX][gate.PosY].ActivateVisuals();
         currentGate.Second = gate.PosY;
         if (nextIsCRX)
         {
             gate.ActivateRX();
         }
         else
         {
             gate.ActivateX();
         }
         Apply();
     }
 }
Beispiel #2
0
    public void Test()
    {
        int numQUbits = 10;
        int maxgates  = 10;

        if (Target == null)
        {
            Target = this.transform;
        }

        operations = new Gate[maxgates];
        for (int i = 0; i < maxgates; i++)
        {
            operations[i]             = new Gate();
            operations[i].CircuitType = CircuitType.M;
        }

        allGates = new SelectableGate[maxgates][];
        for (int i = 0; i < maxgates; i++)
        {
            allGates[i] = new SelectableGate[numQUbits];
        }

        for (int i = 0; i < maxgates; i++)
        {
            for (int j = 0; j < numQUbits; j++)
            {
                //allGates[i][j] = Instantiate<SelectableGate>(GatePrefab, Target.position + new Vector3(i * cellSizeX, -j * cellSizeY, 0), Quaternion.identity, this.transform);
                allGates[i][j] = Instantiate <SelectableGate>(GatePrefab, Target.position, Quaternion.identity, this.transform);
                allGates[i][j].transform.localPosition += new Vector3(i * cellSizeX, -j * cellSizeY, 0);
                //allGates[i][j].transform.localRotation = Quaternion.Euler(0, 180, 0);
                allGates[i][j].Initialise(i, j);
                allGates[i][j].Reset();
                //allGates[i][j].ActivateVisuals();
            }
        }

        for (int i = 0; i < 5; i++)
        {
            Select(allGates[i][i]);
            if (i % 2 == 0)
            {
                SelectRX();
            }
            else if (i == 3 || i == 5)
            {
                SelectH();
            }
            else
            {
                SelectX();
            }
        }
        Generator?.gameObject.SetActive(true);
        ApplyGates();
        Generator?.gameObject.SetActive(false);
    }
Beispiel #3
0
    public void Initialize(int numQUbits, int maxgates)
    {
        if (Target == null)
        {
            Target = this.transform;
        }

        operations = new Gate[maxgates];
        for (int i = 0; i < maxgates; i++)
        {
            operations[i]             = new Gate();
            operations[i].CircuitType = CircuitType.M;
        }

        allGates = new SelectableGate[maxgates][];
        for (int i = 0; i < maxgates; i++)
        {
            allGates[i] = new SelectableGate[numQUbits];
        }

        for (int i = 0; i < Lines.Length; i++)
        {
            if (i >= numQUbits)
            {
                Lines[i].gameObject.SetActive(false);
            }
        }

        for (int i = 0; i < maxgates; i++)
        {
            for (int j = 0; j < numQUbits; j++)
            {
                //allGates[i][j] = Instantiate<SelectableGate>(GatePrefab, Target.position + new Vector3(i * cellSizeX, -j * cellSizeY, 0), Quaternion.identity, this.transform);
                allGates[i][j] = Instantiate <SelectableGate>(GatePrefab, Target.position, Quaternion.identity, this.transform);
                allGates[i][j].transform.localPosition += new Vector3(i * cellSizeX, -j * cellSizeY, 0);
                //allGates[i][j].transform.localRotation = Quaternion.Euler(0, 180, 0);
                allGates[i][j].Initialise(i, j);
                allGates[i][j].Reset();
                //allGates[i][j].ActivateVisuals();
            }
        }

        HideUI();

        Invoke(nameof(ApplyGates), 0.1f);
    }
Beispiel #4
0
 public void Close()
 {
     selected = null;
     HideUI();
 }