Пример #1
0
    /// <summary>
    /// Updates model display text
    /// </summary>
    /// <param name="newModel">new wiring model of rotor</param>
    void UpdateModelText(RotorModel newModel)
    {
        // alters model text according to new model
        switch (newModel)
        {
        case RotorModel.I:
            modelText.text = "I";
            break;

        case RotorModel.II:
            modelText.text = "II";
            break;

        case RotorModel.III:
            modelText.text = "III";
            break;

        case RotorModel.IV:
            modelText.text = "IV";
            break;

        case RotorModel.V:
            modelText.text = "V";
            break;

        default:
            modelText.text = "err";
            break;
        }
    }
Пример #2
0
        public EnigmaM3(
            RotorModel rotor1,
            RotorModel rotor2,
            RotorModel rotor3,
            ReflectorModel reflector)
        {
            this.Rotor1    = new Rotor(rotor1);
            this.Rotor2    = new Rotor(rotor2);
            this.Rotor3    = new Rotor(rotor3);
            this.Reflector = new Reflector(reflector);

            this.EntryRotor = EntryRotor.EtwABCDEF;
            this.Plugboard  = new Plugboard();

            this.rotors = new Rotor[] { this.Rotor1, this.Rotor2, this.Rotor3 };
            this.charactersTranslated = 0;
        }
Пример #3
0
    /// <summary>
    /// Decrements wiring model of rotor
    /// Called when user manually presses previous model button
    /// </summary>
    public void DecrementModel()
    {
        // if current model isn't first in enum
        if (model != RotorModel.I)
        {
            // decrement model as normal
            model -= 1;
        }
        // otherwise,
        else
        {
            // wrap model to be last in enum
            model = RotorModel.V;
        }

        // update displayed model text and model in enigma
        UpdateModelText(model);
        wiringSetEvent.Invoke(enigmaPosition, model);
    }
Пример #4
0
 /// <summary>
 /// Adjusts internal wiring and turnover positions of a given rotor
 /// </summary>
 /// <param name="rotorNumber">which rotor shifted wiring</param>
 /// <param name="newModel">new wiring model for given rotor</param>
 void DetectRotorRewiring(int rotorNumber, RotorModel newModel)
 {
     currentRotors[rotorNumber] = rotorWirings[newModel];
     turnoverPos[rotorNumber]   = notchMarks[(int)newModel];
 }
Пример #5
0
 public Rotor(RotorModel rotorModel)
     : base(Names[rotorModel], Mappings[rotorModel], Turnovers[rotorModel])
 {
     this.initialPosition = 0;
     this.ringPosition    = 0;
 }