public void ButtonPressed(int buttonIdentifier) { if (_emailPuzzleIsSolved) { return; } if (_buttonOrder[_index] == buttonIdentifier) { _index++; TurnLightOn(); if (_index == 4) { _emailPuzzleIsSolved = true; Debug.Log("Email puzzle solved"); } } else if (buttonIdentifier == _buttonOrder[0]) { _index = 1; } else { _index = 0; TurnLightsOff(); } _computerScreen.SetScreenContext(GetContentToDisplayOnComputerScreen()); Debug.Log("Buttons pressed in correct order: " + _index); }
// Start is called before the first frame update void Start() { _computerScreen = FindObjectOfType <ComputerScreen>(); _buttonOrder = new int[4] { 2, 1, 3, 4 }; _caesarCipher = ScriptableObject.CreateInstance <CaeserCipher>(); _originalText = _computerScreen.GetScreenContent(); var firstEncodedText = _caesarCipher.Encrypt(_originalText, 1); var secondEncodedText = _caesarCipher.Encrypt(firstEncodedText, 2); var thirdEncodedText = _caesarCipher.Encrypt(secondEncodedText, 3); var fourthEncodedText = _caesarCipher.Encrypt(thirdEncodedText, 4); _screenContents = new string[5] { fourthEncodedText, thirdEncodedText, secondEncodedText, firstEncodedText, _originalText }; _computerScreen.SetScreenContext(_screenContents[_index]); _lights = FindObjectsOfType <Led>(); SortLights(); }