Example #1
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;
        }
Example #2
0
    /// <summary>
    /// Updates wiring model display text
    /// </summary>
    /// <param name="newWiring">new wiring model to display</param>
    void UpdateWiringText(ReflectorModel newWiring)
    {
        // alters model display text according to new wiring model
        switch (newWiring)
        {
        case ReflectorModel.A:
            modelDisplayText.text = "A";
            break;

        case ReflectorModel.B:
            modelDisplayText.text = "B";
            break;

        case ReflectorModel.C:
            modelDisplayText.text = "C";
            break;

        default:
            modelDisplayText.text = "err";
            break;
        }
    }
Example #3
0
    /// <summary>
    /// Shifts wiring model of reflector up or down by one
    /// Called when user presses "Next Model" or "Prev Model" buttons
    /// </summary>
    /// <param name="shiftToNextModel">whether model should increment to next model</param>
    public void ChangeReflectorWiring(bool shiftToNextModel)
    {
        // if user shifts to next model
        if (shiftToNextModel)
        {
            // if current model isn't last in enum
            if (model != ReflectorModel.C)
            {
                // increment as normal
                model += 1;
            }
            // otherwise, wrap model to first in enum
            else
            {
                model = ReflectorModel.A;
            }
        }
        // otherwise (i.e., user shifts to prev model)
        else
        {
            // if current model isn't first in enum
            if (model != ReflectorModel.A)
            {
                // decrement as normal
                model -= 1;
            }
            // otherwise, wrap model to last in enum
            else
            {
                model = ReflectorModel.C;
            }
        }

        // update displayed model
        UpdateWiringText(model);
        reflectorSetEvent.Invoke(model);
    }
Example #4
0
 /// <summary>
 /// Adjusts internal wiring of reflector
 /// </summary>
 /// <param name="newModel">new wiring model for reflector</param>
 void DetectReflectorRewiring(ReflectorModel newModel)
 {
     currentReflector = reflectorWirings[newModel];
 }
Example #5
0
 public Reflector(ReflectorModel reflectorModel)
     : base(Names[reflectorModel], Mappings[reflectorModel], string.Empty)
 {
 }