Exemple #1
0
    // Use this for initialization
    void Start()
    {
        // pair rotor models with appropriate wiring details in a dictionary
        rotorWirings.Add(RotorModel.I, rotorIWiring);
        rotorWirings.Add(RotorModel.II, rotorIIWiring);
        rotorWirings.Add(RotorModel.III, rotorIIIWiring);
        rotorWirings.Add(RotorModel.IV, rotorM3IVWiring);
        rotorWirings.Add(RotorModel.V, rotorM3VWiring);

        // pair reflector models with appropriate wiring details in a dictionary
        reflectorWirings.Add(ReflectorModel.A, reflectorAWiring);
        reflectorWirings.Add(ReflectorModel.B, reflectorBWiring);
        reflectorWirings.Add(ReflectorModel.C, reflectorCWiring);

        // adds self as invoker of the relevant events
        keyEncodedEvent = new KeyEncodedEvent();
        EventManager.AddKeyEncodedInvoker(this);
        advanceRotorEvent = new AdvanceRotorEvent();
        EventManager.AddAdvanceRotorInvoker(this);

        // adds self as listener for relevant events
        EventManager.AddRotorSetListener(DetectManualRotorShift);
        EventManager.AddWiringSetListener(DetectRotorRewiring);
        EventManager.AddReflectorSetListener(DetectReflectorRewiring);
        EventManager.AddPlugInsertedListener(DetectPlugInsertion);

        // iterate through rotors in machine
        for (int i = 0; i < 3; i++)
        {
            // set both rotor model, rotational position, and turnover points to safe defaults
            currentRotors[i]  = rotorWirings[RotorModel.I];
            rotorPositions[i] = 1;
            turnoverPos[i]    = notchMarks[0];
        }

        // set current reflector to save default
        currentReflector = reflectorAWiring;

        // pair substitution plug IDs with starting plugboard details in a dictionary
        // Note: current version of project supports 3 plug pairs
        for (int i = 0; i < 6; i++)
        {
            plugboardInfo.Add((PlugID)i, stdAlphabet[i]);
        }
    }